Commit 9ceadee1 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Sync cleanup: Remove a bunch of unused code and includes

I was mostly looking for components/signin/-related things, but
discovered a bunch more stuff along the way, mostly in
ProfileSyncComponentsFactoryImpl.

Bug: 825190
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I1b17d00db3cbefa50a7fabaf0b3e55e7ea567610
Reviewed-on: https://chromium-review.googlesource.com/978211Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545747}
parent 1b03f7f6
......@@ -23,7 +23,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/sync/glue/theme_data_type_controller.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
......@@ -56,7 +55,6 @@
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/sync/browser/password_model_worker.h"
#include "components/search_engines/search_engine_data_type_controller.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "components/sync/base/pref_names.h"
#include "components/sync/base/report_unrecoverable_error.h"
......@@ -220,22 +218,14 @@ void ChromeSyncClient::Initialize() {
// Component factory may already be set in tests.
if (!GetSyncApiComponentFactory()) {
const GURL sync_service_url = syncer::GetSyncServiceURL(
*base::CommandLine::ForCurrentProcess(), chrome::GetChannel());
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
net::URLRequestContextGetter* url_request_context_getter =
profile_->GetRequestContext();
component_factory_ = std::make_unique<ProfileSyncComponentsFactoryImpl>(
this, chrome::GetChannel(), chrome::GetVersionString(),
ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET,
*base::CommandLine::ForCurrentProcess(),
prefs::kSavingBrowserHistoryDisabled, sync_service_url,
prefs::kSavingBrowserHistoryDisabled,
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI),
db_thread_, token_service, url_request_context_getter,
web_data_service_, password_store_);
db_thread_, web_data_service_, password_store_);
}
}
......
......@@ -16,8 +16,6 @@
#include "components/autofill/core/browser/webdata/autofill_profile_data_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/browser/webdata/web_data_model_type_controller.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/browser_sync/browser_sync_switches.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/dom_distiller/core/dom_distiller_features.h"
......@@ -42,9 +40,6 @@
#include "components/sync_bookmarks/bookmark_model_associator.h"
#include "components/sync_bookmarks/bookmark_model_type_controller.h"
#include "components/sync_sessions/session_data_type_controller.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "google_apis/gaia/oauth2_token_service_request.h"
#include "net/url_request/url_request_context_getter.h"
using base::FeatureList;
using bookmarks::BookmarkModel;
......@@ -74,11 +69,6 @@ syncer::ModelTypeSet GetDisabledTypesFromCommandLine(
return disabled_types;
}
syncer::ModelTypeSet GetEnabledTypesFromCommandLine(
const base::CommandLine& command_line) {
return syncer::ModelTypeSet();
}
} // namespace
ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
......@@ -88,11 +78,8 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
bool is_tablet,
const base::CommandLine& command_line,
const char* history_disabled_pref,
const GURL& sync_service_url,
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
OAuth2TokenService* token_service,
net::URLRequestContextGetter* url_request_context_getter,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service,
const scoped_refptr<password_manager::PasswordStore>& password_store)
: sync_client_(sync_client),
......@@ -101,17 +88,10 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
is_tablet_(is_tablet),
command_line_(command_line),
history_disabled_pref_(history_disabled_pref),
sync_service_url_(sync_service_url),
ui_thread_(ui_thread),
db_thread_(db_thread),
token_service_(token_service),
url_request_context_getter_(url_request_context_getter),
web_data_service_(web_data_service),
password_store_(password_store),
weak_factory_(this) {
DCHECK(token_service_);
DCHECK(url_request_context_getter_);
}
password_store_(password_store) {}
ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {}
......@@ -120,18 +100,17 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
const RegisterDataTypesMethod& register_platform_types_method) {
syncer::ModelTypeSet disabled_types =
GetDisabledTypesFromCommandLine(command_line_);
syncer::ModelTypeSet enabled_types =
GetEnabledTypesFromCommandLine(command_line_);
RegisterCommonDataTypes(sync_service, disabled_types, enabled_types);
if (!register_platform_types_method.is_null())
RegisterCommonDataTypes(sync_service, disabled_types);
if (!register_platform_types_method.is_null()) {
syncer::ModelTypeSet enabled_types;
register_platform_types_method.Run(sync_service, disabled_types,
enabled_types);
}
}
void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
syncer::SyncService* sync_service,
syncer::ModelTypeSet disabled_types,
syncer::ModelTypeSet enabled_types) {
syncer::ModelTypeSet disabled_types) {
base::Closure error_callback =
base::Bind(&syncer::ReportUnrecoverableError, channel_);
......@@ -331,41 +310,6 @@ ProfileSyncComponentsFactoryImpl::CreateLocalDeviceInfoProvider() {
channel_, version_, is_tablet_);
}
class TokenServiceProvider
: public OAuth2TokenServiceRequest::TokenServiceProvider {
public:
TokenServiceProvider(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
OAuth2TokenService* token_service);
// OAuth2TokenServiceRequest::TokenServiceProvider implementation.
scoped_refptr<base::SingleThreadTaskRunner> GetTokenServiceTaskRunner()
override;
OAuth2TokenService* GetTokenService() override;
private:
~TokenServiceProvider() override;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
OAuth2TokenService* token_service_;
};
TokenServiceProvider::TokenServiceProvider(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
OAuth2TokenService* token_service)
: task_runner_(task_runner), token_service_(token_service) {}
TokenServiceProvider::~TokenServiceProvider() {}
scoped_refptr<base::SingleThreadTaskRunner>
TokenServiceProvider::GetTokenServiceTaskRunner() {
return task_runner_;
}
OAuth2TokenService* TokenServiceProvider::GetTokenService() {
return token_service_;
}
syncer::SyncApiComponentFactory::SyncComponents
ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents(
syncer::SyncService* sync_service,
......
......@@ -15,9 +15,6 @@
#include "components/sync/base/model_type.h"
#include "components/sync/driver/sync_api_component_factory.h"
#include "components/version_info/version_info.h"
#include "url/gurl.h"
class OAuth2TokenService;
namespace autofill {
class AutofillWebDataService;
......@@ -27,23 +24,11 @@ namespace password_manager {
class PasswordStore;
}
namespace net {
class URLRequestContextGetter;
}
namespace browser_sync {
class ProfileSyncComponentsFactoryImpl
: public syncer::SyncApiComponentFactory {
public:
// Constructs a ProfileSyncComponentsFactoryImpl.
//
// |sync_service_url| is the base URL of the sync server.
//
// |token_service| must outlive the ProfileSyncComponentsFactoryImpl.
//
// |url_request_context_getter| must outlive the
// ProfileSyncComponentsFactoryImpl.
ProfileSyncComponentsFactoryImpl(
syncer::SyncClient* sync_client,
version_info::Channel channel,
......@@ -51,11 +36,8 @@ class ProfileSyncComponentsFactoryImpl
bool is_tablet,
const base::CommandLine& command_line,
const char* history_disabled_pref,
const GURL& sync_service_url,
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
OAuth2TokenService* token_service,
net::URLRequestContextGetter* url_request_context_getter,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service,
const scoped_refptr<password_manager::PasswordStore>& password_store);
~ProfileSyncComponentsFactoryImpl() override;
......@@ -89,15 +71,10 @@ class ProfileSyncComponentsFactoryImpl
private:
// Register data types which are enabled on both desktop and mobile.
// |disabled_types| and |enabled_types| correspond only to those types
// being explicitly enabled/disabled by the command line.
// |disabled_types| corresponds only to those types being explicitly disabled
// by the command line.
void RegisterCommonDataTypes(syncer::SyncService* sync_service,
syncer::ModelTypeSet disabled_types,
syncer::ModelTypeSet enabled_types);
void DisableBrokenType(syncer::ModelType type,
const base::Location& from_here,
const std::string& message);
syncer::ModelTypeSet disabled_types);
// Client/platform specific members.
syncer::SyncClient* const sync_client_;
......@@ -106,16 +83,11 @@ class ProfileSyncComponentsFactoryImpl
const bool is_tablet_;
const base::CommandLine command_line_;
const char* history_disabled_pref_;
const GURL sync_service_url_;
const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
OAuth2TokenService* const token_service_;
net::URLRequestContextGetter* const url_request_context_getter_;
const scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
const scoped_refptr<password_manager::PasswordStore> password_store_;
base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_;
// Whether to override PREFERENCES to use USS.
static bool override_prefs_controller_to_uss_for_test_;
......
......@@ -4,10 +4,7 @@
#include "components/browser_sync/profile_sync_service.h"
#include <stddef.h>
#include <cstddef>
#include <map>
#include <utility>
#include "base/bind.h"
......@@ -15,30 +12,23 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/files/file_path.h"
#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/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_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"
#include "components/signin/core/browser/signin_metrics.h"
#include "components/sync/base/bind_to_task_runner.h"
#include "components/sync/base/cryptographer.h"
#include "components/sync/base/passphrase_type.h"
#include "components/sync/base/pref_names.h"
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/base/stop_source.h"
#include "components/sync/base/system_encryptor.h"
......
......@@ -19,7 +19,6 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
......
......@@ -14,7 +14,6 @@
#include "base/threading/thread_task_runner_handle.h"
#include "components/invalidation/public/invalidation_service.h"
#include "components/invalidation/public/object_id_invalidation_map.h"
#include "components/signin/core/browser/signin_client.h"
#include "components/sync/base/experiments.h"
#include "components/sync/base/invalidation_helper.h"
#include "components/sync/base/sync_prefs.h"
......
......@@ -28,7 +28,6 @@
#include "components/password_manager/sync/browser/password_model_worker.h"
#include "components/reading_list/core/reading_list_model.h"
#include "components/search_engines/search_engine_data_type_controller.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/driver/sync_api_component_factory.h"
#include "components/sync/driver/sync_util.h"
......@@ -54,7 +53,6 @@
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
#include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
#include "ios/chrome/browser/sync/glue/sync_start_util.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/ios_user_event_service_factory.h"
......@@ -156,22 +154,13 @@ void IOSChromeSyncClient::Initialize() {
// Component factory may already be set in tests.
if (!GetSyncApiComponentFactory()) {
const GURL sync_service_url = syncer::GetSyncServiceURL(
*base::CommandLine::ForCurrentProcess(), ::GetChannel());
ProfileOAuth2TokenService* token_service =
OAuth2TokenServiceFactory::GetForBrowserState(browser_state_);
net::URLRequestContextGetter* url_request_context_getter =
browser_state_->GetRequestContext();
component_factory_.reset(new browser_sync::ProfileSyncComponentsFactoryImpl(
this, ::GetChannel(), ::GetVersionString(),
ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET,
*base::CommandLine::ForCurrentProcess(),
prefs::kSavingBrowserHistoryDisabled, sync_service_url,
prefs::kSavingBrowserHistoryDisabled,
web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), db_thread_,
token_service, url_request_context_getter, web_data_service_,
password_store_));
web_data_service_, password_store_));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment