diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-16 09:59:13 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-20 10:28:53 +0000 |
commit | 6c11fb357ec39bf087b8b632e2b1e375aef1b38b (patch) | |
tree | c8315530db18a8ee566521c39ab8a6af4f72bc03 /chromium/components/consent_auditor | |
parent | 3ffaed019d0772e59d6cdb2d0d32fe4834c31f72 (diff) | |
download | qtwebengine-chromium-6c11fb357ec39bf087b8b632e2b1e375aef1b38b.tar.gz |
BASELINE: Update Chromium to 74.0.3729.159
Change-Id: I8d2497da544c275415aedd94dd25328d555de811
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/consent_auditor')
7 files changed, 84 insertions, 68 deletions
diff --git a/chromium/components/consent_auditor/consent_auditor_impl.cc b/chromium/components/consent_auditor/consent_auditor_impl.cc index 665cbad50de..860303dfe5e 100644 --- a/chromium/components/consent_auditor/consent_auditor_impl.cc +++ b/chromium/components/consent_auditor/consent_auditor_impl.cc @@ -46,7 +46,7 @@ std::unique_ptr<sync_pb::UserConsentSpecifics> CreateUserConsentSpecifics( ConsentAuditorImpl::ConsentAuditorImpl( PrefService* pref_service, - std::unique_ptr<syncer::ConsentSyncBridge> consent_sync_bridge, + std::unique_ptr<ConsentSyncBridge> consent_sync_bridge, const std::string& app_version, const std::string& app_locale, base::Clock* clock) diff --git a/chromium/components/consent_auditor/consent_auditor_impl.h b/chromium/components/consent_auditor/consent_auditor_impl.h index 8a9be1e4ba8..e10671d7b9a 100644 --- a/chromium/components/consent_auditor/consent_auditor_impl.h +++ b/chromium/components/consent_auditor/consent_auditor_impl.h @@ -28,12 +28,11 @@ namespace consent_auditor { class ConsentAuditorImpl : public ConsentAuditor { public: - ConsentAuditorImpl( - PrefService* pref_service, - std::unique_ptr<syncer::ConsentSyncBridge> consent_sync_bridge, - const std::string& app_version, - const std::string& app_locale, - base::Clock* clock); + ConsentAuditorImpl(PrefService* pref_service, + std::unique_ptr<ConsentSyncBridge> consent_sync_bridge, + const std::string& app_version, + const std::string& app_locale, + base::Clock* clock); ~ConsentAuditorImpl() override; // KeyedService (through ConsentAuditor) implementation. @@ -79,7 +78,7 @@ class ConsentAuditorImpl : public ConsentAuditor { ConsentStatus status); PrefService* pref_service_; - std::unique_ptr<syncer::ConsentSyncBridge> consent_sync_bridge_; + std::unique_ptr<ConsentSyncBridge> consent_sync_bridge_; std::string app_version_; std::string app_locale_; base::Clock* clock_; diff --git a/chromium/components/consent_auditor/consent_auditor_impl_unittest.cc b/chromium/components/consent_auditor/consent_auditor_impl_unittest.cc index 5974822b28d..8a8cc9fe272 100644 --- a/chromium/components/consent_auditor/consent_auditor_impl_unittest.cc +++ b/chromium/components/consent_auditor/consent_auditor_impl_unittest.cc @@ -75,7 +75,7 @@ void LoadEntriesFromLocalConsentRecord(const base::Value* consents, *locale = locale_entry->GetString(); } -class FakeConsentSyncBridge : public syncer::ConsentSyncBridge { +class FakeConsentSyncBridge : public ConsentSyncBridge { public: ~FakeConsentSyncBridge() override = default; @@ -135,7 +135,7 @@ class ConsentAuditorImplTest : public testing::Test { void SetAppLocale(const std::string& new_app_locale) { app_locale_ = new_app_locale; } - void SetConsentSyncBridge(std::unique_ptr<syncer::ConsentSyncBridge> bridge) { + void SetConsentSyncBridge(std::unique_ptr<ConsentSyncBridge> bridge) { consent_sync_bridge_ = std::move(bridge); } void SetClock(base::Clock* clock) { clock_ = clock; } @@ -150,7 +150,7 @@ class ConsentAuditorImplTest : public testing::Test { std::unique_ptr<TestingPrefServiceSimple> pref_service_; std::string app_version_; std::string app_locale_; - std::unique_ptr<syncer::ConsentSyncBridge> consent_sync_bridge_; + std::unique_ptr<ConsentSyncBridge> consent_sync_bridge_; }; TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) { diff --git a/chromium/components/consent_auditor/consent_sync_bridge.h b/chromium/components/consent_auditor/consent_sync_bridge.h index b14012d8e95..bc3eb8f6875 100644 --- a/chromium/components/consent_auditor/consent_sync_bridge.h +++ b/chromium/components/consent_auditor/consent_sync_bridge.h @@ -10,7 +10,7 @@ #include "base/memory/weak_ptr.h" #include "components/sync/model/model_type_controller_delegate.h" -namespace syncer { +namespace consent_auditor { class ConsentSyncBridge { public: @@ -23,8 +23,11 @@ class ConsentSyncBridge { // Returns the delegate for the controller, i.e. sync integration point. virtual base::WeakPtr<syncer::ModelTypeControllerDelegate> GetControllerDelegate() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(ConsentSyncBridge); }; -} // namespace syncer +} // namespace consent_auditor #endif // COMPONENTS_CONSENT_AUDITOR_CONSENT_SYNC_BRIDGE_H_ diff --git a/chromium/components/consent_auditor/consent_sync_bridge_impl.cc b/chromium/components/consent_auditor/consent_sync_bridge_impl.cc index cb4ee3b032b..4338d25fb0f 100644 --- a/chromium/components/consent_auditor/consent_sync_bridge_impl.cc +++ b/chromium/components/consent_auditor/consent_sync_bridge_impl.cc @@ -22,9 +22,20 @@ #include "components/sync/model/mutable_data_batch.h" #include "components/sync/protocol/sync.pb.h" -namespace syncer { +namespace consent_auditor { using sync_pb::UserConsentSpecifics; +using syncer::EntityChange; +using syncer::EntityChangeList; +using syncer::EntityData; +using syncer::MetadataBatch; +using syncer::MetadataChangeList; +using syncer::ModelError; +using syncer::ModelTypeChangeProcessor; +using syncer::ModelTypeStore; +using syncer::ModelTypeSyncBridge; +using syncer::MutableDataBatch; +using syncer::OnceModelTypeStoreFactory; using IdList = ModelTypeStore::IdList; using Record = ModelTypeStore::Record; using RecordList = ModelTypeStore::RecordList; @@ -46,7 +57,7 @@ std::unique_ptr<EntityData> MoveToEntityData( std::unique_ptr<UserConsentSpecifics> specifics) { auto entity_data = std::make_unique<EntityData>(); entity_data->non_unique_name = - base::Int64ToString(specifics->client_consent_time_usec()); + base::NumberToString(specifics->client_consent_time_usec()); entity_data->specifics.set_allocated_user_consent(specifics.release()); return entity_data; } @@ -59,8 +70,9 @@ ConsentSyncBridgeImpl::ConsentSyncBridgeImpl( : ModelTypeSyncBridge(std::move(change_processor)), weak_ptr_factory_(this) { std::move(store_factory) - .Run(USER_CONSENTS, base::BindOnce(&ConsentSyncBridgeImpl::OnStoreCreated, - weak_ptr_factory_.GetWeakPtr())); + .Run(syncer::USER_CONSENTS, + base::BindOnce(&ConsentSyncBridgeImpl::OnStoreCreated, + weak_ptr_factory_.GetWeakPtr())); } ConsentSyncBridgeImpl::~ConsentSyncBridgeImpl() { @@ -123,8 +135,7 @@ std::string ConsentSyncBridgeImpl::GetStorageKey( return GetStorageKeyFromSpecifics(entity_data.specifics.user_consent()); } -ModelTypeSyncBridge::StopSyncResponse -ConsentSyncBridgeImpl::ApplyStopSyncChanges( +void ConsentSyncBridgeImpl::ApplyStopSyncChanges( std::unique_ptr<MetadataChangeList> delete_metadata_change_list) { // Sync can only be stopped after initialization. DCHECK(deferred_consents_while_initializing_.empty()); @@ -143,8 +154,6 @@ ConsentSyncBridgeImpl::ApplyStopSyncChanges( base::BindOnce(&ConsentSyncBridgeImpl::OnCommit, weak_ptr_factory_.GetWeakPtr())); } - - return StopSyncResponse::kModelStillReadyToSync; } void ConsentSyncBridgeImpl::ReadAllDataAndResubmit() { @@ -311,4 +320,4 @@ void ConsentSyncBridgeImpl::OnReadAllData( std::move(callback).Run(std::move(batch)); } -} // namespace syncer +} // namespace consent_auditor diff --git a/chromium/components/consent_auditor/consent_sync_bridge_impl.h b/chromium/components/consent_auditor/consent_sync_bridge_impl.h index 972c04922ed..be0ace22e9c 100644 --- a/chromium/components/consent_auditor/consent_sync_bridge_impl.h +++ b/chromium/components/consent_auditor/consent_sync_bridge_impl.h @@ -19,30 +19,31 @@ #include "components/sync/model/model_type_store.h" #include "components/sync/model/model_type_sync_bridge.h" -namespace syncer { +namespace consent_auditor { class ConsentSyncBridgeImpl : public ConsentSyncBridge, - public ModelTypeSyncBridge { + public syncer::ModelTypeSyncBridge { public: ConsentSyncBridgeImpl( - OnceModelTypeStoreFactory store_factory, - std::unique_ptr<ModelTypeChangeProcessor> change_processor); + syncer::OnceModelTypeStoreFactory store_factory, + std::unique_ptr<syncer::ModelTypeChangeProcessor> change_processor); ~ConsentSyncBridgeImpl() override; // ModelTypeSyncBridge implementation. - std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; - base::Optional<ModelError> MergeSyncData( - std::unique_ptr<MetadataChangeList> metadata_change_list, - EntityChangeList entity_data) override; - base::Optional<ModelError> ApplySyncChanges( - std::unique_ptr<MetadataChangeList> metadata_change_list, - EntityChangeList entity_changes) override; + std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() + override; + base::Optional<syncer::ModelError> MergeSyncData( + std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, + syncer::EntityChangeList entity_data) override; + base::Optional<syncer::ModelError> ApplySyncChanges( + std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, + syncer::EntityChangeList entity_changes) override; void GetData(StorageKeyList storage_keys, DataCallback callback) override; void GetAllDataForDebugging(DataCallback callback) override; - std::string GetClientTag(const EntityData& entity_data) override; - std::string GetStorageKey(const EntityData& entity_data) override; - StopSyncResponse ApplyStopSyncChanges( - std::unique_ptr<MetadataChangeList> delete_metadata_change_list) override; + std::string GetClientTag(const syncer::EntityData& entity_data) override; + std::string GetStorageKey(const syncer::EntityData& entity_data) override; + void ApplyStopSyncChanges(std::unique_ptr<syncer::MetadataChangeList> + delete_metadata_change_list) override; // ConsentSyncBridge implementation. void RecordConsent( @@ -52,7 +53,7 @@ class ConsentSyncBridgeImpl : public ConsentSyncBridge, static std::string GetStorageKeyFromSpecificsForTest( const sync_pb::UserConsentSpecifics& specifics); - std::unique_ptr<ModelTypeStore> StealStoreForTest(); + std::unique_ptr<syncer::ModelTypeStore> StealStoreForTest(); private: void RecordConsentImpl( @@ -60,31 +61,33 @@ class ConsentSyncBridgeImpl : public ConsentSyncBridge, // Record events in the deferred queue and clear the queue. void ProcessQueuedEvents(); - void OnStoreCreated(const base::Optional<ModelError>& error, - std::unique_ptr<ModelTypeStore> store); - void OnReadAllMetadata(const base::Optional<ModelError>& error, - std::unique_ptr<MetadataBatch> metadata_batch); - void OnCommit(const base::Optional<ModelError>& error); - void OnReadData(DataCallback callback, - const base::Optional<ModelError>& error, - std::unique_ptr<ModelTypeStore::RecordList> data_records, - std::unique_ptr<ModelTypeStore::IdList> missing_id_list); - void OnReadAllData(DataCallback callback, - const base::Optional<ModelError>& error, - std::unique_ptr<ModelTypeStore::RecordList> data_records); + void OnStoreCreated(const base::Optional<syncer::ModelError>& error, + std::unique_ptr<syncer::ModelTypeStore> store); + void OnReadAllMetadata(const base::Optional<syncer::ModelError>& error, + std::unique_ptr<syncer::MetadataBatch> metadata_batch); + void OnCommit(const base::Optional<syncer::ModelError>& error); + void OnReadData( + DataCallback callback, + const base::Optional<syncer::ModelError>& error, + std::unique_ptr<syncer::ModelTypeStore::RecordList> data_records, + std::unique_ptr<syncer::ModelTypeStore::IdList> missing_id_list); + void OnReadAllData( + DataCallback callback, + const base::Optional<syncer::ModelError>& error, + std::unique_ptr<syncer::ModelTypeStore::RecordList> data_records); // Resubmit all the consents persisted in the store to sync consents, which // were preserved when sync was disabled. This may resubmit entities that the // processor already knows about (i.e. with metadata), but it is allowed. void ReadAllDataAndResubmit(); void OnReadAllDataToResubmit( - const base::Optional<ModelError>& error, - std::unique_ptr<ModelTypeStore::RecordList> data_records); + const base::Optional<syncer::ModelError>& error, + std::unique_ptr<syncer::ModelTypeStore::RecordList> data_records); // Persistent storage for in flight consents. Should remain quite small, as we // delete upon commit confirmation. May contain consents without metadata // (e.g. persisted when sync was disabled). - std::unique_ptr<ModelTypeStore> store_; + std::unique_ptr<syncer::ModelTypeStore> store_; // Used to store consents while the store or change processor are not // ready. @@ -96,6 +99,6 @@ class ConsentSyncBridgeImpl : public ConsentSyncBridge, DISALLOW_COPY_AND_ASSIGN(ConsentSyncBridgeImpl); }; -} // namespace syncer +} // namespace consent_auditor #endif // COMPONENTS_CONSENT_AUDITOR_CONSENT_SYNC_BRIDGE_IMPL_H_ diff --git a/chromium/components/consent_auditor/consent_sync_bridge_impl_unittest.cc b/chromium/components/consent_auditor/consent_sync_bridge_impl_unittest.cc index 8bee16056a1..1e258365ce3 100644 --- a/chromium/components/consent_auditor/consent_sync_bridge_impl_unittest.cc +++ b/chromium/components/consent_auditor/consent_sync_bridge_impl_unittest.cc @@ -19,10 +19,20 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -namespace syncer { +namespace consent_auditor { namespace { using sync_pb::UserConsentSpecifics; +using syncer::DataBatch; +using syncer::EntityChange; +using syncer::EntityChangeList; +using syncer::EntityData; +using syncer::MetadataChangeList; +using syncer::MockModelTypeChangeProcessor; +using syncer::ModelTypeStore; +using syncer::ModelTypeStoreTestUtil; +using syncer::ModelTypeSyncBridge; +using syncer::OnceModelTypeStoreFactory; using testing::_; using testing::ElementsAre; using testing::Eq; @@ -187,9 +197,7 @@ TEST_F(ConsentSyncBridgeImplTest, ShouldNotDeleteConsentsWhenSyncIsDisabled) { std::make_unique<UserConsentSpecifics>(user_consent_specifics)); ASSERT_THAT(GetAllData(), SizeIs(1)); - EXPECT_THAT( - bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()), - Eq(ModelTypeSyncBridge::StopSyncResponse::kModelStillReadyToSync)); + bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()); // The bridge may asynchronously query the store to choose what to delete. base::RunLoop().RunUntilIdle(); @@ -304,9 +312,7 @@ TEST_F(ConsentSyncBridgeImplTest, // User disables sync, hovewer, the consent hasn't been submitted yet. It is // preserved to be submitted when sync is re-enabled. - EXPECT_THAT( - bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()), - Eq(ModelTypeSyncBridge::StopSyncResponse::kModelStillReadyToSync)); + bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()); // The bridge may asynchronously query the store to choose what to delete. base::RunLoop().RunUntilIdle(); @@ -375,9 +381,7 @@ TEST_F(ConsentSyncBridgeImplTest, std::make_unique<UserConsentSpecifics>(user_consent_specifics)); ASSERT_THAT(GetAllData(), SizeIs(1)); - EXPECT_THAT( - bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()), - Eq(ModelTypeSyncBridge::StopSyncResponse::kModelStillReadyToSync)); + bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()); // The bridge may asynchronously query the store to choose what to delete. base::RunLoop().RunUntilIdle(); @@ -394,9 +398,7 @@ TEST_F(ConsentSyncBridgeImplTest, EntityChangeList()); base::RunLoop().RunUntilIdle(); - EXPECT_THAT( - bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()), - Eq(ModelTypeSyncBridge::StopSyncResponse::kModelStillReadyToSync)); + bridge()->ApplyStopSyncChanges(WriteBatch::CreateMetadataChangeList()); base::RunLoop().RunUntilIdle(); // This time their consent should be resubmitted, because it is for the same @@ -412,4 +414,4 @@ TEST_F(ConsentSyncBridgeImplTest, } // namespace -} // namespace syncer +} // namespace consent_auditor |