summaryrefslogtreecommitdiff
path: root/chromium/components/browser_sync
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-03 13:42:47 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-15 10:27:51 +0000
commit8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (patch)
treed29d987c4d7b173cf853279b79a51598f104b403 /chromium/components/browser_sync
parent830c9e163d31a9180fadca926b3e1d7dfffb5021 (diff)
downloadqtwebengine-chromium-8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec.tar.gz
BASELINE: Update Chromium to 66.0.3359.156
Change-Id: I0c9831ad39911a086b6377b16f995ad75a51e441 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/components/browser_sync')
-rw-r--r--chromium/components/browser_sync/BUILD.gn1
-rw-r--r--chromium/components/browser_sync/profile_sync_components_factory_impl.cc80
-rw-r--r--chromium/components/browser_sync/profile_sync_components_factory_impl.h6
-rw-r--r--chromium/components/browser_sync/profile_sync_service.cc33
-rw-r--r--chromium/components/browser_sync/profile_sync_service.h7
-rw-r--r--chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc15
-rw-r--r--chromium/components/browser_sync/profile_sync_service_mock.cc5
-rw-r--r--chromium/components/browser_sync/profile_sync_service_mock.h8
-rw-r--r--chromium/components/browser_sync/profile_sync_service_typed_url_unittest.cc1044
-rw-r--r--chromium/components/browser_sync/profile_sync_service_unittest.cc7
-rw-r--r--chromium/components/browser_sync/profile_sync_test_util.cc11
-rw-r--r--chromium/components/browser_sync/profile_sync_test_util.h22
-rw-r--r--chromium/components/browser_sync/signin_confirmation_helper.cc1
13 files changed, 54 insertions, 1186 deletions
diff --git a/chromium/components/browser_sync/BUILD.gn b/chromium/components/browser_sync/BUILD.gn
index 1bddf05f365..d8c3092bfd1 100644
--- a/chromium/components/browser_sync/BUILD.gn
+++ b/chromium/components/browser_sync/BUILD.gn
@@ -53,7 +53,6 @@ source_set("unit_tests") {
"profile_sync_service_autofill_unittest.cc",
"profile_sync_service_bookmark_unittest.cc",
"profile_sync_service_startup_unittest.cc",
- "profile_sync_service_typed_url_unittest.cc",
"profile_sync_service_unittest.cc",
]
diff --git a/chromium/components/browser_sync/profile_sync_components_factory_impl.cc b/chromium/components/browser_sync/profile_sync_components_factory_impl.cc
index 9c4a83ab8e6..ac89e31d6ad 100644
--- a/chromium/components/browser_sync/profile_sync_components_factory_impl.cc
+++ b/chromium/components/browser_sync/profile_sync_components_factory_impl.cc
@@ -22,7 +22,6 @@
#include "components/browser_sync/profile_sync_service.h"
#include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/history/core/browser/history_delete_directives_data_type_controller.h"
-#include "components/history/core/browser/typed_url_data_type_controller.h"
#include "components/history/core/browser/typed_url_model_type_controller.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/sync/browser/password_data_type_controller.h"
@@ -37,10 +36,7 @@
#include "components/sync/driver/proxy_data_type_controller.h"
#include "components/sync/driver/sync_client.h"
#include "components/sync/driver/sync_driver_switches.h"
-#include "components/sync/engine/attachments/attachment_downloader.h"
-#include "components/sync/engine/attachments/attachment_uploader.h"
#include "components/sync/engine/sync_engine.h"
-#include "components/sync/model/attachments/attachment_service.h"
#include "components/sync_bookmarks/bookmark_change_processor.h"
#include "components/sync_bookmarks/bookmark_data_type_controller.h"
#include "components/sync_bookmarks/bookmark_model_associator.h"
@@ -150,17 +146,11 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
// Autocomplete sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::AUTOFILL)) {
- if (FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) {
- sync_service->RegisterDataTypeController(
- std::make_unique<autofill::WebDataModelTypeController>(
- syncer::AUTOFILL, sync_client_, db_thread_, web_data_service_,
- base::Bind(
- &autofill::AutocompleteSyncBridge::FromWebDataService)));
- } else {
- sync_service->RegisterDataTypeController(
- std::make_unique<AutofillDataTypeController>(
- db_thread_, error_callback, sync_client_, web_data_service_));
- }
+ sync_service->RegisterDataTypeController(
+ std::make_unique<autofill::WebDataModelTypeController>(
+ syncer::AUTOFILL, sync_client_, db_thread_, web_data_service_,
+ base::Bind(
+ &autofill::AutocompleteSyncBridge::FromWebDataService)));
}
// Autofill sync is enabled by default. Register unless explicitly
@@ -211,15 +201,9 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
// TypedUrl sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::TYPED_URLS)) {
- if (base::FeatureList::IsEnabled(switches::kSyncUSSTypedURL)) {
- sync_service->RegisterDataTypeController(
- std::make_unique<history::TypedURLModelTypeController>(
- sync_client_, history_disabled_pref_));
- } else {
- sync_service->RegisterDataTypeController(
- std::make_unique<TypedUrlDataTypeController>(
- error_callback, sync_client_, history_disabled_pref_));
- }
+ sync_service->RegisterDataTypeController(
+ std::make_unique<history::TypedURLModelTypeController>(
+ sync_client_, history_disabled_pref_));
}
// Delete directive sync is enabled by default.
@@ -382,54 +366,6 @@ OAuth2TokenService* TokenServiceProvider::GetTokenService() {
return token_service_;
}
-std::unique_ptr<syncer::AttachmentService>
-ProfileSyncComponentsFactoryImpl::CreateAttachmentService(
- std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store,
- const syncer::UserShare& user_share,
- const std::string& store_birthday,
- syncer::ModelType model_type,
- syncer::AttachmentService::Delegate* delegate) {
- std::unique_ptr<syncer::AttachmentUploader> attachment_uploader;
- std::unique_ptr<syncer::AttachmentDownloader> attachment_downloader;
- // Only construct an AttachmentUploader and AttachmentDownload if we have sync
- // credentials. We may not have sync credentials because there may not be a
- // signed in sync user.
- if (!user_share.sync_credentials.account_id.empty() &&
- !user_share.sync_credentials.scope_set.empty()) {
- scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>
- token_service_provider(
- new TokenServiceProvider(ui_thread_, token_service_));
- // TODO(maniscalco): Use shared (one per profile) thread-safe instances of
- // AttachmentUploader and AttachmentDownloader instead of creating a new one
- // per AttachmentService (bug 369536).
- attachment_uploader = syncer::AttachmentUploader::Create(
- sync_service_url_, url_request_context_getter_,
- user_share.sync_credentials.account_id,
- user_share.sync_credentials.scope_set, token_service_provider,
- store_birthday, model_type);
-
- token_service_provider =
- new TokenServiceProvider(ui_thread_, token_service_);
- attachment_downloader = syncer::AttachmentDownloader::Create(
- sync_service_url_, url_request_context_getter_,
- user_share.sync_credentials.account_id,
- user_share.sync_credentials.scope_set, token_service_provider,
- store_birthday, model_type);
- }
-
- // It is important that the initial backoff delay is relatively large. For
- // whatever reason, the server may fail all requests for a short period of
- // time. When this happens we don't want to overwhelm the server with
- // requests so we use a large initial backoff.
- const base::TimeDelta initial_backoff_delay =
- base::TimeDelta::FromMinutes(30);
- const base::TimeDelta max_backoff_delay = base::TimeDelta::FromHours(4);
- return syncer::AttachmentService::Create(
- std::move(attachment_store), std::move(attachment_uploader),
- std::move(attachment_downloader), delegate, initial_backoff_delay,
- max_backoff_delay);
-}
-
syncer::SyncApiComponentFactory::SyncComponents
ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents(
syncer::SyncService* sync_service,
diff --git a/chromium/components/browser_sync/profile_sync_components_factory_impl.h b/chromium/components/browser_sync/profile_sync_components_factory_impl.h
index 351e688f4f5..fa0259a4b31 100644
--- a/chromium/components/browser_sync/profile_sync_components_factory_impl.h
+++ b/chromium/components/browser_sync/profile_sync_components_factory_impl.h
@@ -79,12 +79,6 @@ class ProfileSyncComponentsFactoryImpl
const base::FilePath& sync_data_folder) override;
std::unique_ptr<syncer::LocalDeviceInfoProvider>
CreateLocalDeviceInfoProvider() override;
- std::unique_ptr<syncer::AttachmentService> CreateAttachmentService(
- std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store,
- const syncer::UserShare& user_share,
- const std::string& store_birthday,
- syncer::ModelType model_type,
- syncer::AttachmentService::Delegate* delegate) override;
syncer::SyncApiComponentFactory::SyncComponents CreateBookmarkSyncComponents(
syncer::SyncService* sync_service,
std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) override;
diff --git a/chromium/components/browser_sync/profile_sync_service.cc b/chromium/components/browser_sync/profile_sync_service.cc
index f76497cfab6..4d99038c24c 100644
--- a/chromium/components/browser_sync/profile_sync_service.cc
+++ b/chromium/components/browser_sync/profile_sync_service.cc
@@ -19,18 +19,18 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/browser_sync/browser_sync_switches.h"
-#include "components/history/core/browser/typed_url_data_type_controller.h"
#include "components/invalidation/impl/invalidation_prefs.h"
#include "components/invalidation/public/invalidation_service.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/json_pref_store.h"
-#include "components/reading_list/features/reading_list_enable_flags.h"
+#include "components/reading_list/features/reading_list_buildflags.h"
#include "components/signin/core/browser/about_signin_internals.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -235,10 +235,7 @@ void ProfileSyncService::Initialize() {
sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(),
router,
base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated,
- sync_enabled_weak_factory_.GetWeakPtr()),
- base::Bind(&ProfileSyncService::TriggerRefresh,
- sync_enabled_weak_factory_.GetWeakPtr(),
- syncer::ModelTypeSet(syncer::SESSIONS)));
+ sync_enabled_weak_factory_.GetWeakPtr()));
device_info_sync_bridge_ = std::make_unique<DeviceInfoSyncBridge>(
local_device_.get(), model_type_store_factory_,
@@ -384,9 +381,12 @@ sync_sessions::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() {
DCHECK(thread_checker_.CalledOnValidThread());
// Although the backing data actually is of type |SESSIONS|, the desire to use
// open tabs functionality is tracked by the state of the |PROXY_TABS| type.
- return IsDataTypeControllerRunning(syncer::PROXY_TABS)
- ? sessions_sync_manager_.get()
- : nullptr;
+ if (!IsDataTypeControllerRunning(syncer::PROXY_TABS)) {
+ return nullptr;
+ }
+
+ DCHECK(sessions_sync_manager_);
+ return sessions_sync_manager_->GetOpenTabsUIDelegate();
}
sync_sessions::FaviconCache* ProfileSyncService::GetFaviconCache() {
@@ -605,7 +605,7 @@ void ProfileSyncService::OnGetTokenFailure(
UMA_HISTOGRAM_ENUMERATION("Sync.SyncAuthError", AUTH_ERROR_ENCOUNTERED,
AUTH_ERROR_LIMIT);
}
- // Fallthrough.
+ FALLTHROUGH;
}
default: {
if (error.state() != GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) {
@@ -903,8 +903,7 @@ void ProfileSyncService::OnEngineInitialized(
} else {
SigninClient* signin_client = signin_->GetOriginal()->signin_client();
DCHECK(signin_client);
- std::string signin_scoped_device_id =
- signin_client->GetSigninScopedDeviceId();
+ signin_scoped_device_id = signin_client->GetSigninScopedDeviceId();
}
// Initialize local device info.
@@ -1123,7 +1122,7 @@ void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
// On every platform except ChromeOS, sign out the user after a dashboard
// clear.
if (!IsLocalSyncEnabled()) {
- static_cast<SigninManager*>(signin_->GetOriginal())
+ SigninManager::FromSigninManagerBase(signin_->GetOriginal())
->SignOut(signin_metrics::SERVER_FORCED_DISABLE,
signin_metrics::SignoutDelete::IGNORE_METRIC);
}
@@ -1623,13 +1622,13 @@ void ProfileSyncService::SetPlatformSyncAllowedProvider(
}
// static
-syncer::ModelTypeStoreFactory ProfileSyncService::GetModelTypeStoreFactory(
- const base::FilePath& base_path) {
+syncer::RepeatingModelTypeStoreFactory
+ProfileSyncService::GetModelTypeStoreFactory(const base::FilePath& base_path) {
// TODO(skym): Verify using AsUTF8Unsafe is okay here. Should work as long
// as the Local State file is guaranteed to be UTF-8.
const std::string path =
FormatSharedModelTypeStorePath(base_path).AsUTF8Unsafe();
- return base::Bind(&ModelTypeStore::CreateStore, path);
+ return base::BindRepeating(&ModelTypeStore::CreateStore, path);
}
void ProfileSyncService::ConfigureDataTypeManager() {
@@ -2092,7 +2091,7 @@ void ProfileSyncService::GetAllNodes(
}
syncer::GlobalIdMapper* ProfileSyncService::GetGlobalIdMapper() const {
- return sessions_sync_manager_.get();
+ return sessions_sync_manager_->GetGlobalIdMapper();
}
base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() {
diff --git a/chromium/components/browser_sync/profile_sync_service.h b/chromium/components/browser_sync/profile_sync_service.h
index d63cd92f61d..5a04d94f19a 100644
--- a/chromium/components/browser_sync/profile_sync_service.h
+++ b/chromium/components/browser_sync/profile_sync_service.h
@@ -20,7 +20,6 @@
#include "base/message_loop/message_loop.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -237,7 +236,7 @@ class ProfileSyncService : public syncer::SyncServiceBase,
scoped_refptr<net::URLRequestContextGetter> url_request_context;
std::string debug_identifier;
version_info::Channel channel = version_info::Channel::UNKNOWN;
- syncer::ModelTypeStoreFactory model_type_store_factory;
+ syncer::RepeatingModelTypeStoreFactory model_type_store_factory;
private:
DISALLOW_COPY_AND_ASSIGN(InitParams);
@@ -559,7 +558,7 @@ class ProfileSyncService : public syncer::SyncServiceBase,
// Returns a function that will create a ModelTypeStore that shares
// the sync LevelDB backend. |base_path| should be set to profile path.
- static syncer::ModelTypeStoreFactory GetModelTypeStoreFactory(
+ static syncer::RepeatingModelTypeStoreFactory GetModelTypeStoreFactory(
const base::FilePath& base_path);
// Needed to test whether the directory is deleted properly.
@@ -886,7 +885,7 @@ class ProfileSyncService : public syncer::SyncServiceBase,
// sync bridges created by the ProfileSyncService. The default factory
// creates an on disk leveldb-backed ModelTypeStore; one might override this
// default to, e.g., use an in-memory db for unit tests.
- syncer::ModelTypeStoreFactory model_type_store_factory_;
+ syncer::RepeatingModelTypeStoreFactory model_type_store_factory_;
// This weak factory invalidates its issued pointers when Sync is disabled.
base::WeakPtrFactory<ProfileSyncService> sync_enabled_weak_factory_;
diff --git a/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc b/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc
index 19652a16e8a..54dd4a7ddfb 100644
--- a/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc
+++ b/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc
@@ -433,10 +433,9 @@ class ProfileSyncServiceAutofillTest
EXPECT_CALL(personal_data_manager(), LoadProfiles());
EXPECT_CALL(personal_data_manager(), LoadCreditCards());
- personal_data_manager_->Init(
- web_data_service_, profile_sync_service_bundle()->pref_service(),
- profile_sync_service_bundle()->account_tracker(),
- profile_sync_service_bundle()->signin_manager(), false);
+ personal_data_manager_->Init(web_data_service_,
+ profile_sync_service_bundle()->pref_service(),
+ nullptr, false);
web_data_service_->StartSyncableService();
@@ -625,12 +624,12 @@ class ProfileSyncServiceAutofillTest
DCHECK(type == AUTOFILL || type == AUTOFILL_PROFILE);
if (type == AUTOFILL) {
return std::make_unique<AutofillDataTypeController>(
- data_type_thread()->task_runner(), base::Bind(&base::DoNothing),
- sync_client_, web_data_service_);
+ data_type_thread()->task_runner(), base::DoNothing(), sync_client_,
+ web_data_service_);
} else {
return std::make_unique<AutofillProfileDataTypeController>(
- data_type_thread()->task_runner(), base::Bind(&base::DoNothing),
- sync_client_, web_data_service_);
+ data_type_thread()->task_runner(), base::DoNothing(), sync_client_,
+ web_data_service_);
}
}
diff --git a/chromium/components/browser_sync/profile_sync_service_mock.cc b/chromium/components/browser_sync/profile_sync_service_mock.cc
index 4102a954b0b..56ed2496ba9 100644
--- a/chromium/components/browser_sync/profile_sync_service_mock.cc
+++ b/chromium/components/browser_sync/profile_sync_service_mock.cc
@@ -26,4 +26,9 @@ ProfileSyncServiceMock::GetOpenTabsUIDelegate() {
: ProfileSyncService::GetOpenTabsUIDelegate();
}
+std::unique_ptr<syncer::SyncSetupInProgressHandle>
+ProfileSyncServiceMock::GetSetupInProgressHandleConcrete() {
+ return browser_sync::ProfileSyncService::GetSetupInProgressHandle();
+}
+
} // namespace browser_sync
diff --git a/chromium/components/browser_sync/profile_sync_service_mock.h b/chromium/components/browser_sync/profile_sync_service_mock.h
index 588c74e95d9..cb5003ff577 100644
--- a/chromium/components/browser_sync/profile_sync_service_mock.h
+++ b/chromium/components/browser_sync/profile_sync_service_mock.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_
#define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_
+#include <memory>
#include <string>
#include <vector>
@@ -43,6 +44,9 @@ class ProfileSyncServiceMock : public ProfileSyncService {
MOCK_METHOD1(OnSyncCycleCompleted, void(const syncer::SyncCycleSnapshot&));
MOCK_METHOD2(OnUserChoseDatatypes,
void(bool sync_everything, syncer::ModelTypeSet chosen_types));
+ MOCK_METHOD0(SetFirstSetupComplete, void());
+ MOCK_METHOD0(GetSetupInProgressHandle,
+ std::unique_ptr<syncer::SyncSetupInProgressHandle>());
MOCK_METHOD2(OnUnrecoverableError,
void(const base::Location& location,
@@ -103,6 +107,10 @@ class ProfileSyncServiceMock : public ProfileSyncService {
void(const std::string& passphrase, PassphraseType type));
MOCK_METHOD0(OnSetupInProgressHandleDestroyed, void());
+
+ // Gives access to the real implementation of ProfileSyncService methods:
+ std::unique_ptr<syncer::SyncSetupInProgressHandle>
+ GetSetupInProgressHandleConcrete();
};
} // namespace browser_sync
diff --git a/chromium/components/browser_sync/profile_sync_service_typed_url_unittest.cc b/chromium/components/browser_sync/profile_sync_service_typed_url_unittest.cc
deleted file mode 100644
index 964ae968ab8..00000000000
--- a/chromium/components/browser_sync/profile_sync_service_typed_url_unittest.cc
+++ /dev/null
@@ -1,1044 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/location.h"
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
-#include "base/memory/ref_counted.h"
-#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
-#include "base/strings/string16.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/threading/thread.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "base/time/time.h"
-#include "components/browser_sync/abstract_profile_sync_service_test.h"
-#include "components/browser_sync/test_profile_sync_service.h"
-#include "components/history/core/browser/history_backend.h"
-#include "components/history/core/browser/history_backend_client.h"
-#include "components/history/core/browser/history_backend_notifier.h"
-#include "components/history/core/browser/history_db_task.h"
-#include "components/history/core/browser/history_service.h"
-#include "components/history/core/browser/typed_url_data_type_controller.h"
-#include "components/signin/core/browser/signin_manager.h"
-#include "components/sync/driver/data_type_manager_impl.h"
-#include "components/sync/model/data_type_error_handler_mock.h"
-#include "components/sync/protocol/typed_url_specifics.pb.h"
-#include "components/sync/syncable/read_node.h"
-#include "components/sync/syncable/read_transaction.h"
-#include "components/sync/syncable/write_node.h"
-#include "components/sync/syncable/write_transaction.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-using history::HistoryBackend;
-using history::HistoryBackendNotifier;
-using history::TypedUrlSyncableService;
-using testing::DoAll;
-using testing::Return;
-using testing::SetArgPointee;
-using testing::_;
-
-namespace browser_sync {
-
-namespace {
-
-const char kDummySavingBrowserHistoryDisabled[] = "dummyPref";
-
-// Visits with this timestamp are treated as expired.
-static const int EXPIRED_VISIT = -1;
-
-ACTION_P(ReturnNewDataTypeManager, sync_client) {
- return new syncer::DataTypeManagerImpl(sync_client, arg0, arg1, arg2, arg3,
- arg4, arg5);
-}
-
-class HistoryBackendMock : public HistoryBackend {
- public:
- HistoryBackendMock()
- : HistoryBackend(nullptr, nullptr, base::ThreadTaskRunnerHandle::Get()) {}
- bool IsExpiredVisitTime(const base::Time& time) override {
- return time.ToInternalValue() == EXPIRED_VISIT;
- }
- MOCK_METHOD1(GetAllTypedURLs, bool(history::URLRows* entries));
- MOCK_METHOD3(GetMostRecentVisitsForURL,
- bool(history::URLID id,
- int max_visits,
- history::VisitVector* visits));
- MOCK_METHOD2(UpdateURL, bool(history::URLID id, const history::URLRow& url));
- MOCK_METHOD3(AddVisits,
- bool(const GURL& url,
- const std::vector<history::VisitInfo>& visits,
- history::VisitSource visit_source));
- MOCK_METHOD2(GetURL, bool(const GURL& url_id, history::URLRow* url_row));
- MOCK_METHOD2(SetPageTitle,
- void(const GURL& url, const base::string16& title));
- MOCK_METHOD1(DeleteURL, void(const GURL& url));
-
- private:
- friend class ProfileSyncServiceTypedUrlTest;
-
- virtual ~HistoryBackendMock() {}
-};
-
-class HistoryServiceMock : public history::HistoryService {
- public:
- HistoryServiceMock() : history::HistoryService(), backend_(nullptr) {}
-
- base::CancelableTaskTracker::TaskId ScheduleDBTask(
- std::unique_ptr<history::HistoryDBTask> task,
- base::CancelableTaskTracker* tracker) override {
- // Explicitly copy out the raw pointer -- compilers might decide to
- // evaluate task.release() before the arguments for the first Bind().
- history::HistoryDBTask* task_raw = task.get();
- task_runner_->PostTaskAndReply(
- FROM_HERE, base::Bind(&HistoryServiceMock::RunTaskOnDBThread,
- base::Unretained(this), task_raw),
- base::Bind(&base::DeletePointer<history::HistoryDBTask>,
- task.release()));
- return base::CancelableTaskTracker::kBadTaskId; // unused
- }
-
- ~HistoryServiceMock() override {}
-
- void set_task_runner(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
- DCHECK(task_runner.get());
- task_runner_ = task_runner;
- }
-
- void set_backend(scoped_refptr<history::HistoryBackend> backend) {
- backend_ = backend;
- }
-
- private:
- void RunTaskOnDBThread(history::HistoryDBTask* task) {
- EXPECT_TRUE(task->RunOnDBThread(backend_.get(), nullptr));
- }
-
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- scoped_refptr<history::HistoryBackend> backend_;
-};
-
-class TestTypedUrlSyncableService : public TypedUrlSyncableService {
- // TODO(gangwu): remove TestProfileSyncService or even remove whole test
- // suite, and make sure typed_url_syncable_service_unittest.cc and the various
- // typed url integration tests.
- public:
- explicit TestTypedUrlSyncableService(history::HistoryBackend* history_backend)
- : TypedUrlSyncableService(history_backend) {}
-
- static void WriteToSyncNode(const history::URLRow& url,
- const history::VisitVector& visits,
- syncer::WriteNode* node) {
- sync_pb::TypedUrlSpecifics typed_url;
- ASSERT_TRUE(WriteToTypedUrlSpecifics(url, visits, &typed_url));
- node->SetTypedUrlSpecifics(typed_url);
- }
-
- protected:
- // Don't clear error stats - that way we can verify their values in our
- // tests.
- void ClearErrorStats() override {}
-};
-
-class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
- public:
- void AddTypedUrlSyncNode(const history::URLRow& url,
- const history::VisitVector& visits) {
- syncer::WriteTransaction trans(FROM_HERE, sync_service()->GetUserShare());
-
- syncer::WriteNode node(&trans);
- std::string tag = url.url().spec();
- syncer::WriteNode::InitUniqueByCreationResult result =
- node.InitUniqueByCreation(syncer::TYPED_URLS, tag);
- ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result);
- TestTypedUrlSyncableService::WriteToSyncNode(url, visits, &node);
- }
-
- protected:
- ProfileSyncServiceTypedUrlTest() {
- profile_sync_service_bundle()
- ->pref_service()
- ->registry()
- ->RegisterBooleanPref(kDummySavingBrowserHistoryDisabled, false);
-
- data_type_thread()->Start();
- base::RunLoop run_loop;
- data_type_thread()->task_runner()->PostTaskAndReply(
- FROM_HERE,
- base::Bind(&ProfileSyncServiceTypedUrlTest::CreateHistoryService,
- base::Unretained(this)),
- run_loop.QuitClosure());
- run_loop.Run();
- history_service_ = base::WrapUnique(new HistoryServiceMock);
- history_service_->set_task_runner(data_type_thread()->task_runner());
- history_service_->set_backend(history_backend_);
-
- ProfileSyncServiceBundle::SyncClientBuilder builder(
- profile_sync_service_bundle());
- builder.SetHistoryService(history_service_.get());
- builder.SetSyncServiceCallback(GetSyncServiceCallback());
- builder.SetSyncableServiceCallback(
- base::Bind(&ProfileSyncServiceTypedUrlTest::GetSyncableServiceForType,
- base::Unretained(this)));
- builder.set_activate_model_creation();
- sync_client_ = builder.Build();
- }
-
- void CreateHistoryService() {
- history_backend_ = new HistoryBackendMock();
- syncable_service_ =
- std::make_unique<TestTypedUrlSyncableService>(history_backend_.get());
- }
-
- void DeleteSyncableService() {
- syncable_service_.reset();
- history_backend_ = nullptr;
- }
-
- ~ProfileSyncServiceTypedUrlTest() override {
- history_service_->Shutdown();
-
- // Request stop to get deletion tasks related to the HistoryService posted
- // on the Sync thread. It is important to not Shutdown at this moment,
- // because after shutdown the Sync thread is not returned to the sync
- // service, so we could not get the thread's message loop to wait for the
- // deletions to be finished.
- sync_service()->RequestStop(syncer::SyncService::CLEAR_DATA);
- // Spin the sync thread.
- {
- base::RunLoop run_loop;
- sync_service()->GetSyncLoopForTest()->task_runner()->PostTaskAndReply(
- FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure());
- run_loop.Run();
- }
-
- // Spin the loop again for deletion tasks posted from the Sync thread.
- base::RunLoop().RunUntilIdle();
-
- {
- base::RunLoop run_loop;
- data_type_thread()->task_runner()->PostTaskAndReply(
- FROM_HERE,
- base::Bind(&ProfileSyncServiceTypedUrlTest::DeleteSyncableService,
- base::Unretained(this)),
- run_loop.QuitClosure());
- run_loop.Run();
- }
- }
-
- TypedUrlSyncableService* StartSyncService(const base::Closure& callback) {
- if (!sync_service()) {
- std::string account_id =
- profile_sync_service_bundle()->account_tracker()->SeedAccountInfo(
- "gaia_id", "test");
- SigninManagerBase* signin =
- profile_sync_service_bundle()->signin_manager();
- signin->SetAuthenticatedAccountInfo("gaia_id", "test");
- EXPECT_CALL(*profile_sync_service_bundle()->component_factory(),
- CreateDataTypeManager(_, _, _, _, _, _))
- .WillOnce(ReturnNewDataTypeManager(sync_client_.get()));
- CreateSyncService(std::move(sync_client_), callback);
-
- profile_sync_service_bundle()->auth_service()->UpdateCredentials(
- account_id, "oauth2_login_token");
-
- sync_service()->RegisterDataTypeController(
- std::make_unique<TypedUrlDataTypeController>(
- base::Bind(&base::DoNothing), sync_service()->GetSyncClient(),
- kDummySavingBrowserHistoryDisabled));
-
- sync_service()->Initialize();
- base::RunLoop().Run();
- }
- return syncable_service_.get();
- }
-
- void GetTypedUrlsFromSyncDB(history::URLRows* urls) {
- urls->clear();
- syncer::ReadTransaction trans(FROM_HERE, sync_service()->GetUserShare());
- syncer::ReadNode typed_url_root(&trans);
- if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
- syncer::BaseNode::INIT_OK)
- return;
-
- int64_t child_id = typed_url_root.GetFirstChildId();
- while (child_id != syncer::kInvalidId) {
- syncer::ReadNode child_node(&trans);
- if (child_node.InitByIdLookup(child_id) != syncer::BaseNode::INIT_OK)
- return;
-
- const sync_pb::TypedUrlSpecifics& typed_url(
- child_node.GetTypedUrlSpecifics());
- history::URLRow new_url(GURL(typed_url.url()));
-
- new_url.set_title(base::UTF8ToUTF16(typed_url.title()));
- DCHECK(typed_url.visits_size());
- DCHECK_EQ(typed_url.visits_size(), typed_url.visit_transitions_size());
- new_url.set_last_visit(base::Time::FromInternalValue(
- typed_url.visits(typed_url.visits_size() - 1)));
- new_url.set_hidden(typed_url.hidden());
-
- urls->push_back(new_url);
- child_id = child_node.GetSuccessorId();
- }
- }
-
- void SetIdleChangeProcessorExpectations() {
- EXPECT_CALL((history_backend()), SetPageTitle(_, _)).Times(0);
- EXPECT_CALL((history_backend()), UpdateURL(_, _)).Times(0);
- EXPECT_CALL((history_backend()), GetURL(_, _)).Times(0);
- EXPECT_CALL((history_backend()), DeleteURL(_)).Times(0);
- }
-
- void SendNotification(const base::Closure& task) {
- data_type_thread()->task_runner()->PostTaskAndReply(
- FROM_HERE, task, base::Bind(&base::RunLoop::QuitCurrentDeprecated));
- base::RunLoop().Run();
- }
-
- void SendNotificationURLVisited(ui::PageTransition transition,
- const history::URLRow& row) {
- base::Time visit_time;
- history::RedirectList redirects;
- SendNotification(base::Bind(&HistoryBackendNotifier::NotifyURLVisited,
- base::Unretained(history_backend_.get()),
- transition, row, redirects, visit_time));
- }
-
- void SendNotificationURLsModified(const history::URLRows& rows) {
- SendNotification(base::Bind(&HistoryBackendNotifier::NotifyURLsModified,
- base::Unretained(history_backend_.get()),
- rows));
- }
-
- void SendNotificationURLsDeleted(bool all_history,
- bool expired,
- const history::URLRows& deleted_rows,
- const std::set<GURL>& favicon_urls) {
- SendNotification(base::Bind(&HistoryBackendNotifier::NotifyURLsDeleted,
- base::Unretained(history_backend_.get()),
- all_history, expired, deleted_rows,
- favicon_urls));
- }
-
- static bool URLsEqual(const history::URLRow& lhs,
- const history::URLRow& rhs) {
- // Only verify the fields we explicitly sync (i.e. don't verify typed_count
- // or visit_count because we rely on the history DB to manage those values
- // and they are left unchanged by HistoryBackendMock).
- return (lhs.url().spec().compare(rhs.url().spec()) == 0) &&
- (lhs.title().compare(rhs.title()) == 0) &&
- (lhs.last_visit() == rhs.last_visit()) &&
- (lhs.hidden() == rhs.hidden());
- }
-
- static history::URLRow MakeTypedUrlEntry(const char* url,
- const char* title,
- int typed_count,
- int64_t last_visit,
- bool hidden,
- history::VisitVector* visits) {
- // Give each URL a unique ID, to mimic the behavior of the real database.
- static int unique_url_id = 0;
- GURL gurl(url);
- history::URLRow history_url(gurl, ++unique_url_id);
- history_url.set_title(base::UTF8ToUTF16(title));
- history_url.set_typed_count(typed_count);
- history_url.set_last_visit(base::Time::FromInternalValue(last_visit));
- history_url.set_hidden(hidden);
- visits->push_back(history::VisitRow(history_url.id(),
- history_url.last_visit(), 0,
- ui::PAGE_TRANSITION_TYPED, 0));
- history_url.set_visit_count(visits->size());
- return history_url;
- }
-
- base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
- syncer::ModelType type) {
- DCHECK_EQ(syncer::TYPED_URLS, type);
- return syncable_service_->AsWeakPtr();
- }
-
- HistoryBackendMock& history_backend() { return *history_backend_.get(); }
-
- private:
- scoped_refptr<HistoryBackendMock> history_backend_;
- std::unique_ptr<HistoryServiceMock> history_service_;
- syncer::DataTypeErrorHandlerMock error_handler_;
- std::unique_ptr<TestTypedUrlSyncableService> syncable_service_;
- std::unique_ptr<syncer::FakeSyncClient> sync_client_;
-
- DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTypedUrlTest);
-};
-
-void AddTypedUrlEntries(ProfileSyncServiceTypedUrlTest* test,
- const history::URLRows& entries) {
- test->CreateRoot(syncer::TYPED_URLS);
- for (size_t i = 0; i < entries.size(); ++i) {
- history::VisitVector visits;
- visits.push_back(history::VisitRow(entries[i].id(), entries[i].last_visit(),
- 0, ui::PageTransitionFromInt(1), 0));
- test->AddTypedUrlSyncNode(entries[i], visits);
- }
-}
-
-} // namespace
-
-TEST_F(ProfileSyncServiceTypedUrlTest, EmptyNativeEmptySync) {
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- TypedUrlSyncableService* syncable_service =
- StartSyncService(create_root.callback());
- history::URLRows sync_entries;
- GetTypedUrlsFromSyncDB(&sync_entries);
- EXPECT_EQ(0U, sync_entries.size());
- ASSERT_EQ(0, syncable_service->GetErrorPercentage());
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeEmptySync) {
- history::URLRows entries;
- history::VisitVector visits;
- entries.push_back(
- MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits));
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(visits), Return(true)));
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- TypedUrlSyncableService* syncable_service =
- StartSyncService(create_root.callback());
- history::URLRows sync_entries;
- GetTypedUrlsFromSyncDB(&sync_entries);
- ASSERT_EQ(1U, sync_entries.size());
- EXPECT_TRUE(URLsEqual(entries[0], sync_entries[0]));
- ASSERT_EQ(0, syncable_service->GetErrorPercentage());
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeErrorReadingVisits) {
- history::URLRows entries;
- history::VisitVector visits;
- history::URLRow native_entry1(
- MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits));
- history::URLRow native_entry2(
- MakeTypedUrlEntry("http://foo2.com", "bar", 3, 15, false, &visits));
- entries.push_back(native_entry1);
- entries.push_back(native_entry2);
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(entries), Return(true)));
- // Return an error from GetMostRecentVisitsForURL() for the second URL.
- EXPECT_CALL((history_backend()),
- GetMostRecentVisitsForURL(native_entry1.id(), _, _))
- .WillRepeatedly(Return(true));
- EXPECT_CALL((history_backend()),
- GetMostRecentVisitsForURL(native_entry2.id(), _, _))
- .WillRepeatedly(Return(false));
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
- history::URLRows sync_entries;
- GetTypedUrlsFromSyncDB(&sync_entries);
- ASSERT_EQ(1U, sync_entries.size());
- EXPECT_TRUE(URLsEqual(native_entry1, sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeWithBlankEmptySync) {
- std::vector<history::URLRow> entries;
- history::VisitVector visits;
- // Add an empty URL.
- entries.push_back(MakeTypedUrlEntry("", "bar", 2, 15, false, &visits));
- entries.push_back(
- MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits));
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(visits), Return(true)));
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
- std::vector<history::URLRow> sync_entries;
- GetTypedUrlsFromSyncDB(&sync_entries);
- // The empty URL should be ignored.
- ASSERT_EQ(1U, sync_entries.size());
- EXPECT_TRUE(URLsEqual(entries[1], sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeHasSyncNoMerge) {
- history::VisitVector native_visits;
- history::VisitVector sync_visits;
- history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
- 2, 15, false, &native_visits));
- history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3,
- 16, false, &sync_visits));
-
- history::URLRows native_entries;
- native_entries.push_back(native_entry);
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(native_visits), Return(true)));
- EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
- .WillRepeatedly(Return(true));
-
- history::URLRows sync_entries;
- sync_entries.push_back(sync_entry);
-
- EXPECT_CALL((history_backend()), UpdateURL(_, _))
- .WillRepeatedly(Return(true));
- StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
-
- std::map<std::string, history::URLRow> expected;
- expected[native_entry.url().spec()] = native_entry;
- expected[sync_entry.url().spec()] = sync_entry;
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- EXPECT_EQ(expected.size(), new_sync_entries.size());
- for (history::URLRows::iterator entry = new_sync_entries.begin();
- entry != new_sync_entries.end(); ++entry) {
- EXPECT_TRUE(URLsEqual(expected[entry->url().spec()], *entry));
- }
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, EmptyNativeExpiredSync) {
- history::VisitVector sync_visits;
- history::URLRow sync_entry(MakeTypedUrlEntry(
- "http://sync.com", "entry", 3, EXPIRED_VISIT, false, &sync_visits));
- history::URLRows sync_entries;
- sync_entries.push_back(sync_entry);
-
- // Since all our URLs are expired, no backend calls to add new URLs will be
- // made.
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
- SetIdleChangeProcessorExpectations();
-
- StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeHasSyncMerge) {
- history::VisitVector native_visits;
- history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
- 2, 15, false, &native_visits));
- history::VisitVector sync_visits;
- history::URLRow sync_entry(MakeTypedUrlEntry("http://native.com", "name", 1,
- 17, false, &sync_visits));
- history::VisitVector merged_visits;
- merged_visits.push_back(
- history::VisitRow(sync_entry.id(), base::Time::FromInternalValue(15), 0,
- ui::PageTransitionFromInt(0), 0));
-
- history::URLRow merged_entry(MakeTypedUrlEntry("http://native.com", "name", 2,
- 17, false, &merged_visits));
-
- history::URLRows native_entries;
- native_entries.push_back(native_entry);
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(native_visits), Return(true)));
- EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
- .WillRepeatedly(Return(true));
-
- history::URLRows sync_entries;
- sync_entries.push_back(sync_entry);
-
- EXPECT_CALL((history_backend()), UpdateURL(_, _))
- .WillRepeatedly(Return(true));
- EXPECT_CALL((history_backend()), SetPageTitle(_, _)).WillRepeatedly(Return());
- StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(merged_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeWithErrorHasSyncMerge) {
- history::VisitVector native_visits;
- history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "native",
- 2, 15, false, &native_visits));
- history::VisitVector sync_visits;
- history::URLRow sync_entry(MakeTypedUrlEntry("http://native.com", "sync", 1,
- 17, false, &sync_visits));
-
- history::URLRows native_entries;
- native_entries.push_back(native_entry);
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
- // Return an error getting the visits for the native URL.
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL((history_backend()), GetURL(_, _))
- .WillRepeatedly(DoAll(SetArgPointee<1>(native_entry), Return(true)));
- EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
- .WillRepeatedly(Return(true));
-
- history::URLRows sync_entries;
- sync_entries.push_back(sync_entry);
-
- EXPECT_CALL((history_backend()), UpdateURL(_, _))
- .WillRepeatedly(Return(true));
- EXPECT_CALL((history_backend()), SetPageTitle(_, _)).WillRepeatedly(Return());
- StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(sync_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAdd) {
- history::VisitVector added_visits;
- history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2,
- 15, false, &added_visits));
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(added_visits), Return(true)));
-
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::URLRows changed_urls;
- changed_urls.push_back(added_entry);
- SendNotificationURLsModified(changed_urls);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddWithBlank) {
- history::VisitVector added_visits;
- history::URLRow empty_entry(
- MakeTypedUrlEntry("", "entry", 2, 15, false, &added_visits));
- history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2,
- 15, false, &added_visits));
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(added_visits), Return(true)));
-
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::URLRows changed_urls;
- changed_urls.push_back(empty_entry);
- changed_urls.push_back(added_entry);
- SendNotificationURLsModified(changed_urls);
-
- std::vector<history::URLRow> new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdate) {
- history::VisitVector original_visits;
- history::URLRow original_entry(MakeTypedUrlEntry(
- "http://mine.com", "entry", 2, 15, false, &original_visits));
- history::URLRows original_entries;
- original_entries.push_back(original_entry);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(original_visits), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::VisitVector updated_visits;
- history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7,
- 17, false, &updated_visits));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(updated_visits), Return(true)));
-
- history::URLRows changed_urls;
- changed_urls.push_back(updated_entry);
- SendNotificationURLsModified(changed_urls);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(updated_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddFromVisit) {
- history::VisitVector added_visits;
- history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2,
- 15, false, &added_visits));
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(added_visits), Return(true)));
-
- SetIdleChangeProcessorExpectations();
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, added_entry);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdateFromVisit) {
- history::VisitVector original_visits;
- history::URLRow original_entry(MakeTypedUrlEntry(
- "http://mine.com", "entry", 2, 15, false, &original_visits));
- history::URLRows original_entries;
- original_entries.push_back(original_entry);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(original_visits), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::VisitVector updated_visits;
- history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7,
- 17, false, &updated_visits));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillOnce(DoAll(SetArgPointee<2>(updated_visits), Return(true)));
-
- SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, updated_entry);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(updated_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserIgnoreChangeUpdateFromVisit) {
- history::VisitVector original_visits;
- history::URLRow original_entry(MakeTypedUrlEntry(
- "http://mine.com", "entry", 2, 15, false, &original_visits));
- history::URLRows original_entries;
- original_entries.push_back(original_entry);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(original_entry, new_sync_entries[0]));
-
- history::VisitVector updated_visits;
- history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7,
- 15, false, &updated_visits));
-
- // Should ignore this change because it's not TYPED.
- SendNotificationURLVisited(ui::PAGE_TRANSITION_RELOAD, updated_entry);
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- // Should be no changes to the sync DB from this notification.
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(original_entry, new_sync_entries[0]));
-
- // Now, try updating it with a large number of visits not divisible by 10
- // (should ignore this visit).
- history::URLRow twelve_visits(MakeTypedUrlEntry(
- "http://mine.com", "entry", 12, 15, false, &updated_visits));
- SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, twelve_visits);
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- // Should be no changes to the sync DB from this notification.
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(original_entry, new_sync_entries[0]));
-
- // Now, try updating it with a large number of visits that is divisible by 10
- // (should *not* be ignored).
- history::URLRow twenty_visits(MakeTypedUrlEntry(
- "http://mine.com", "entry", 20, 15, false, &updated_visits));
- SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, twenty_visits);
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(twenty_visits, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemove) {
- history::VisitVector original_visits1;
- history::URLRow original_entry1(MakeTypedUrlEntry(
- "http://mine.com", "entry", 2, 15, false, &original_visits1));
- history::VisitVector original_visits2;
- history::URLRow original_entry2(MakeTypedUrlEntry(
- "http://mine2.com", "entry2", 3, 15, false, &original_visits2));
- history::URLRows original_entries;
- original_entries.push_back(original_entry1);
- original_entries.push_back(original_entry2);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits1), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::URLRows rows;
- rows.push_back(history::URLRow(GURL("http://mine.com")));
- SendNotificationURLsDeleted(false, false, rows, std::set<GURL>());
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(original_entry2, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveExpired) {
- history::VisitVector original_visits1;
- history::URLRow original_entry1(MakeTypedUrlEntry(
- "http://mine.com", "entry", 2, 15, false, &original_visits1));
- history::VisitVector original_visits2;
- history::URLRow original_entry2(MakeTypedUrlEntry(
- "http://mine2.com", "entry2", 3, 15, false, &original_visits2));
- history::URLRows original_entries;
- original_entries.push_back(original_entry1);
- original_entries.push_back(original_entry2);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits1), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- // Setting expired=true should cause the sync code to ignore this deletion.
- history::URLRows rows;
- rows.push_back(history::URLRow(GURL("http://mine.com")));
- SendNotificationURLsDeleted(false, true, rows, std::set<GURL>());
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- // Both URLs should still be there.
- ASSERT_EQ(2U, new_sync_entries.size());
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveAll) {
- history::VisitVector original_visits1;
- history::URLRow original_entry1(MakeTypedUrlEntry(
- "http://mine.com", "entry", 2, 15, false, &original_visits1));
- history::VisitVector original_visits2;
- history::URLRow original_entry2(MakeTypedUrlEntry(
- "http://mine2.com", "entry2", 3, 15, false, &original_visits2));
- history::URLRows original_entries;
- original_entries.push_back(original_entry1);
- original_entries.push_back(original_entry2);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits1), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(2U, new_sync_entries.size());
-
- SendNotificationURLsDeleted(true, false, history::URLRows(),
- std::set<GURL>());
-
- GetTypedUrlsFromSyncDB(&new_sync_entries);
- ASSERT_EQ(0U, new_sync_entries.size());
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, FailWriteToHistoryBackend) {
- history::VisitVector native_visits;
- history::VisitVector sync_visits;
- history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
- 2, 15, false, &native_visits));
- history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3,
- 16, false, &sync_visits));
-
- history::URLRows native_entries;
- native_entries.push_back(native_entry);
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetURL(_, _))
- .WillOnce(DoAll(SetArgPointee<1>(native_entry), Return(false)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(native_visits), Return(true)));
- EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
- .WillRepeatedly(Return(false));
-
- history::URLRows sync_entries;
- sync_entries.push_back(sync_entry);
-
- EXPECT_CALL((history_backend()), UpdateURL(_, _))
- .WillRepeatedly(Return(false));
- TypedUrlSyncableService* syncable_service =
- StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
- // Errors writing to the DB should be recorded, but should not cause an
- // unrecoverable error.
- ASSERT_FALSE(sync_service()->data_type_status_table().GetFailedTypes().Has(
- syncer::TYPED_URLS));
- // Some calls should have succeeded, so the error percentage should be
- // somewhere > 0 and < 100.
- ASSERT_NE(0, syncable_service->GetErrorPercentage());
- ASSERT_NE(100, syncable_service->GetErrorPercentage());
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, FailToGetTypedURLs) {
- history::VisitVector native_visits;
- history::VisitVector sync_visits;
- history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
- 2, 15, false, &native_visits));
- history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3,
- 16, false, &sync_visits));
-
- history::URLRows native_entries;
- native_entries.push_back(native_entry);
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(false)));
-
- history::URLRows sync_entries;
- sync_entries.push_back(sync_entry);
-
- StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
- // Errors getting typed URLs will cause an unrecoverable error (since we can
- // do *nothing* in that case).
- ASSERT_TRUE(sync_service()->data_type_status_table().GetFailedTypes().Has(
- syncer::TYPED_URLS));
- ASSERT_EQ(1u,
- sync_service()->data_type_status_table().GetFailedTypes().Size());
- // Can't check GetErrorPercentage(), because generating an unrecoverable
- // error will free the model associator.
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, IgnoreLocalFileURL) {
- history::VisitVector original_visits;
- // Create http and file url.
- history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", "yey", 12, 15,
- false, &original_visits));
- history::URLRow file_entry(MakeTypedUrlEntry(
- "file:///kitty.jpg", "kitteh", 12, 15, false, &original_visits));
-
- history::URLRows original_entries;
- original_entries.push_back(url_entry);
- original_entries.push_back(file_entry);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::VisitVector updated_visits;
- // Create updates for the previous urls + a new file one.
- history::URLRow updated_url_entry(MakeTypedUrlEntry(
- "http://yey.com", "yey", 20, 15, false, &updated_visits));
- history::URLRow updated_file_entry(MakeTypedUrlEntry(
- "file:///cat.jpg", "cat", 20, 15, false, &updated_visits));
- history::URLRow new_file_entry(MakeTypedUrlEntry("file:///dog.jpg", "dog", 20,
- 15, false, &updated_visits));
-
- history::URLRows changed_urls;
- changed_urls.push_back(updated_url_entry);
- changed_urls.push_back(updated_file_entry);
- changed_urls.push_back(new_file_entry);
- SendNotificationURLsModified(changed_urls);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- // We should ignore the local file urls (existing and updated),
- // and only be left with the updated http url.
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(updated_url_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, IgnoreLocalhostURL) {
- history::VisitVector original_visits;
- // Create http and localhost url.
- history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", "yey", 12, 15,
- false, &original_visits));
- history::URLRow localhost_entry(MakeTypedUrlEntry(
- "http://localhost", "localhost", 12, 15, false, &original_visits));
-
- history::URLRows original_entries;
- original_entries.push_back(url_entry);
- original_entries.push_back(localhost_entry);
-
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(original_entries), Return(true)));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits), Return(true)));
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::VisitVector updated_visits;
- // Update the previous entries and add a new localhost.
- history::URLRow updated_url_entry(MakeTypedUrlEntry(
- "http://yey.com", "yey", 20, 15, false, &updated_visits));
- history::URLRow updated_localhost_entry(MakeTypedUrlEntry(
- "http://localhost:80", "localhost", 20, 15, false, &original_visits));
- history::URLRow localhost_ip_entry(MakeTypedUrlEntry(
- "http://127.0.0.1", "localhost", 12, 15, false, &original_visits));
-
- history::URLRows changed_urls;
- changed_urls.push_back(updated_url_entry);
- changed_urls.push_back(updated_localhost_entry);
- changed_urls.push_back(localhost_ip_entry);
- SendNotificationURLsModified(changed_urls);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- // We should ignore the localhost urls and left only with http url.
- ASSERT_EQ(1U, new_sync_entries.size());
- EXPECT_TRUE(URLsEqual(updated_url_entry, new_sync_entries[0]));
-}
-
-TEST_F(ProfileSyncServiceTypedUrlTest, IgnoreModificationWithoutValidVisit) {
- EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
- .WillRepeatedly(Return(true));
- EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
- .WillRepeatedly(Return(true));
-
- CreateRootHelper create_root(this, syncer::TYPED_URLS);
- StartSyncService(create_root.callback());
-
- history::VisitVector updated_visits;
- history::URLRow updated_url_entry(MakeTypedUrlEntry(
- "http://yey.com", "yey", 20, 0, false, &updated_visits));
-
- history::URLRows changed_urls;
- changed_urls.push_back(updated_url_entry);
- SendNotificationURLsModified(changed_urls);
-
- history::URLRows new_sync_entries;
- GetTypedUrlsFromSyncDB(&new_sync_entries);
-
- // The change should be ignored.
- ASSERT_EQ(0U, new_sync_entries.size());
-}
-
-} // namespace browser_sync
diff --git a/chromium/components/browser_sync/profile_sync_service_unittest.cc b/chromium/components/browser_sync/profile_sync_service_unittest.cc
index fa95486dc49..ffcb16bdb94 100644
--- a/chromium/components/browser_sync/profile_sync_service_unittest.cc
+++ b/chromium/components/browser_sync/profile_sync_service_unittest.cc
@@ -15,7 +15,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
-#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/browser_sync/browser_sync_switches.h"
@@ -162,10 +161,6 @@ ACTION_P(ReturnNewMockHostCaptureClearServerData, captured_callback) {
&OnClearServerDataCalled, base::Unretained(captured_callback)));
}
-void DoNothing(DataTypeController::ConfigureResult ignored1,
- const SyncMergeResult& ignored2,
- const SyncMergeResult& ignored3) {}
-
// A test harness that uses a real ProfileSyncService and in most cases a
// MockSyncEngine.
//
@@ -992,7 +987,7 @@ TEST_F(ProfileSyncServiceTest, GetOpenTabsUIDelegate) {
std::make_unique<syncer::FakeDataTypeController>(syncer::PROXY_TABS);
// Progress the controller to RUNNING first, which is how the service
// determines whether a type is enabled.
- controller->StartAssociating(base::Bind(&DoNothing));
+ controller->StartAssociating(base::DoNothing());
controller->FinishStart(DataTypeController::OK_FIRST_RUN);
service()->RegisterDataTypeController(std::move(controller));
EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate());
diff --git a/chromium/components/browser_sync/profile_sync_test_util.cc b/chromium/components/browser_sync/profile_sync_test_util.cc
index 956573725ce..249c55b7e3e 100644
--- a/chromium/components/browser_sync/profile_sync_test_util.cc
+++ b/chromium/components/browser_sync/profile_sync_test_util.cc
@@ -13,7 +13,6 @@
#include "components/history/core/browser/history_model_worker.h"
#include "components/history/core/browser/history_service.h"
#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/signin/core/browser/profile_management_switches.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/sync/base/sync_prefs.h"
#include "components/sync/driver/signin_manager_wrapper.h"
@@ -166,17 +165,12 @@ bookmarks::BookmarkModel* BundleSyncClient::GetBookmarkModel() {
} // namespace
-void EmptyNetworkTimeUpdate(const base::Time&,
- const base::TimeDelta&,
- const base::TimeDelta&) {}
-
void RegisterPrefsForProfileSyncService(
user_prefs::PrefRegistrySyncable* registry) {
syncer::SyncPrefs::RegisterProfilePrefs(registry);
AccountTrackerService::RegisterPrefs(registry);
SigninManagerBase::RegisterProfilePrefs(registry);
SigninManagerBase::RegisterPrefs(registry);
- signin::RegisterAccountConsistencyProfilePrefs(registry);
}
ProfileSyncServiceBundle::SyncClientBuilder::~SyncClientBuilder() = default;
@@ -229,7 +223,6 @@ ProfileSyncServiceBundle::SyncClientBuilder::Build() {
ProfileSyncServiceBundle::ProfileSyncServiceBundle()
: db_thread_(base::ThreadTaskRunnerHandle::Get()),
- worker_pool_owner_(2, "sync test worker pool"),
signin_client_(&pref_service_),
#if defined(OS_CHROMEOS)
signin_manager_(&signin_client_, &account_tracker_),
@@ -242,7 +235,6 @@ ProfileSyncServiceBundle::ProfileSyncServiceBundle()
url_request_context_(new net::TestURLRequestContextGetter(
base::ThreadTaskRunnerHandle::Get())) {
RegisterPrefsForProfileSyncService(pref_service_.registry());
- signin::SetGaiaOriginIsolatedCallback(base::Bind([] { return true; }));
auth_service_.set_auto_post_fetch_response_on_message_loop(true);
account_tracker_.Initialize(&signin_client_);
signin_manager_.Initialize(&pref_service_);
@@ -260,8 +252,7 @@ ProfileSyncService::InitParams ProfileSyncServiceBundle::CreateBasicInitParams(
init_params.signin_wrapper =
std::make_unique<SigninManagerWrapper>(signin_manager());
init_params.oauth2_token_service = auth_service();
- init_params.network_time_update_callback =
- base::Bind(&EmptyNetworkTimeUpdate);
+ init_params.network_time_update_callback = base::DoNothing();
EXPECT_TRUE(base_directory_.CreateUniqueTempDir());
init_params.base_directory = base_directory_.GetPath();
init_params.url_request_context = url_request_context();
diff --git a/chromium/components/browser_sync/profile_sync_test_util.h b/chromium/components/browser_sync/profile_sync_test_util.h
index 63252044d6d..44eccf009f0 100644
--- a/chromium/components/browser_sync/profile_sync_test_util.h
+++ b/chromium/components/browser_sync/profile_sync_test_util.h
@@ -11,9 +11,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
-#include "base/test/sequenced_worker_pool_owner.h"
-#include "base/time/time.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/invalidation/impl/fake_invalidation_service.h"
#include "components/signin/core/browser/account_tracker_service.h"
@@ -23,12 +20,7 @@
#include "components/sync/driver/fake_sync_client.h"
#include "components/sync/driver/sync_api_component_factory_mock.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
-#include "components/sync_sessions/fake_sync_sessions_client.h"
-
-namespace base {
-class Time;
-class TimeDelta;
-}
+#include "components/sync_sessions/mock_sync_sessions_client.h"
namespace history {
class HistoryService;
@@ -44,12 +36,6 @@ class PrefRegistrySyncable;
namespace browser_sync {
-// An empty syncer::NetworkTimeUpdateCallback. Used in various tests to
-// instantiate ProfileSyncService.
-void EmptyNetworkTimeUpdate(const base::Time&,
- const base::TimeDelta&,
- const base::TimeDelta&);
-
// Call this to register preferences needed for ProfileSyncService creation.
void RegisterPrefsForProfileSyncService(
user_prefs::PrefRegistrySyncable* registry);
@@ -152,7 +138,7 @@ class ProfileSyncServiceBundle {
return &component_factory_;
}
- sync_sessions::FakeSyncSessionsClient* sync_sessions_client() {
+ sync_sessions::MockSyncSessionsClient* sync_sessions_client() {
return &sync_sessions_client_;
}
@@ -169,14 +155,14 @@ class ProfileSyncServiceBundle {
private:
scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
- base::SequencedWorkerPoolOwner worker_pool_owner_;
sync_preferences::TestingPrefServiceSyncable pref_service_;
TestSigninClient signin_client_;
AccountTrackerService account_tracker_;
FakeSigninManagerType signin_manager_;
FakeProfileOAuth2TokenService auth_service_;
syncer::SyncApiComponentFactoryMock component_factory_;
- sync_sessions::FakeSyncSessionsClient sync_sessions_client_;
+ testing::NiceMock<sync_sessions::MockSyncSessionsClient>
+ sync_sessions_client_;
invalidation::FakeInvalidationService fake_invalidation_service_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_;
base::ScopedTempDir base_directory_;
diff --git a/chromium/components/browser_sync/signin_confirmation_helper.cc b/chromium/components/browser_sync/signin_confirmation_helper.cc
index 1300ae0384b..1270e0aedae 100644
--- a/chromium/components/browser_sync/signin_confirmation_helper.cc
+++ b/chromium/components/browser_sync/signin_confirmation_helper.cc
@@ -94,6 +94,7 @@ void SigninConfirmationHelper::CheckHasTypedURLs() {
return;
}
history_service_->ScheduleDBTask(
+ FROM_HERE,
std::unique_ptr<history::HistoryDBTask>(new HasTypedURLsTask(base::Bind(
&SigninConfirmationHelper::ReturnResult, base::Unretained(this)))),
&task_tracker_);