Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ |
| 6 #define COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ | 6 #define COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 15 #include "base/location.h" | 16 #include "base/location.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/memory_pressure_listener.h" | 18 #include "base/memory/memory_pressure_listener.h" |
| 18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
| 21 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 22 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 24 #include "base/timer/timer.h" | 25 #include "base/timer/timer.h" |
| 25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 26 #include "components/keyed_service/core/keyed_service.h" | 27 #include "components/keyed_service/core/keyed_service.h" |
| 28 #include "components/signin/core/browser/gaia_cookie_manager_service.h" | |
| 27 #include "components/signin/core/browser/signin_manager_base.h" | 29 #include "components/signin/core/browser/signin_manager_base.h" |
| 28 #include "components/sync_driver/data_type_controller.h" | 30 #include "components/sync_driver/data_type_controller.h" |
| 29 #include "components/sync_driver/data_type_manager.h" | 31 #include "components/sync_driver/data_type_manager.h" |
| 30 #include "components/sync_driver/data_type_manager_observer.h" | 32 #include "components/sync_driver/data_type_manager_observer.h" |
| 31 #include "components/sync_driver/data_type_status_table.h" | 33 #include "components/sync_driver/data_type_status_table.h" |
| 32 #include "components/sync_driver/glue/sync_backend_host.h" | 34 #include "components/sync_driver/glue/sync_backend_host.h" |
| 33 #include "components/sync_driver/local_device_info_provider.h" | 35 #include "components/sync_driver/local_device_info_provider.h" |
| 34 #include "components/sync_driver/protocol_event_observer.h" | 36 #include "components/sync_driver/protocol_event_observer.h" |
| 35 #include "components/sync_driver/startup_controller.h" | 37 #include "components/sync_driver/startup_controller.h" |
| 36 #include "components/sync_driver/sync_client.h" | 38 #include "components/sync_driver/sync_client.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 // Once both these conditions have been met, CanConfigureDataTypes() will | 174 // Once both these conditions have been met, CanConfigureDataTypes() will |
| 173 // return true and datatype configuration can begin. | 175 // return true and datatype configuration can begin. |
| 174 class ProfileSyncService : public sync_driver::SyncService, | 176 class ProfileSyncService : public sync_driver::SyncService, |
| 175 public sync_driver::SyncFrontend, | 177 public sync_driver::SyncFrontend, |
| 176 public sync_driver::SyncPrefObserver, | 178 public sync_driver::SyncPrefObserver, |
| 177 public sync_driver::DataTypeManagerObserver, | 179 public sync_driver::DataTypeManagerObserver, |
| 178 public syncer::UnrecoverableErrorHandler, | 180 public syncer::UnrecoverableErrorHandler, |
| 179 public KeyedService, | 181 public KeyedService, |
| 180 public OAuth2TokenService::Consumer, | 182 public OAuth2TokenService::Consumer, |
| 181 public OAuth2TokenService::Observer, | 183 public OAuth2TokenService::Observer, |
| 182 public SigninManagerBase::Observer { | 184 public SigninManagerBase::Observer, |
| 185 public GaiaCookieManagerService::Observer { | |
| 183 public: | 186 public: |
| 184 typedef browser_sync::SyncBackendHost::Status Status; | 187 typedef browser_sync::SyncBackendHost::Status Status; |
| 185 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; | 188 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; |
| 186 | 189 |
| 187 enum SyncEventCodes { | 190 enum SyncEventCodes { |
| 188 MIN_SYNC_EVENT_CODE = 0, | 191 MIN_SYNC_EVENT_CODE = 0, |
| 189 | 192 |
| 190 // Events starting the sync service. | 193 // Events starting the sync service. |
| 191 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 194 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 192 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 195 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 // constructors, so in particular the move constructor needs to be | 234 // constructors, so in particular the move constructor needs to be |
| 232 // explicitly defined. | 235 // explicitly defined. |
| 233 struct InitParams { | 236 struct InitParams { |
| 234 InitParams(); | 237 InitParams(); |
| 235 ~InitParams(); | 238 ~InitParams(); |
| 236 InitParams(InitParams&& other); // NOLINT | 239 InitParams(InitParams&& other); // NOLINT |
| 237 | 240 |
| 238 scoped_ptr<sync_driver::SyncClient> sync_client; | 241 scoped_ptr<sync_driver::SyncClient> sync_client; |
| 239 scoped_ptr<SigninManagerWrapper> signin_wrapper; | 242 scoped_ptr<SigninManagerWrapper> signin_wrapper; |
| 240 ProfileOAuth2TokenService* oauth2_token_service = nullptr; | 243 ProfileOAuth2TokenService* oauth2_token_service = nullptr; |
| 244 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; | |
| 241 StartBehavior start_behavior = MANUAL_START; | 245 StartBehavior start_behavior = MANUAL_START; |
| 242 syncer::NetworkTimeUpdateCallback network_time_update_callback; | 246 syncer::NetworkTimeUpdateCallback network_time_update_callback; |
| 243 base::FilePath base_directory; | 247 base::FilePath base_directory; |
| 244 scoped_refptr<net::URLRequestContextGetter> url_request_context; | 248 scoped_refptr<net::URLRequestContextGetter> url_request_context; |
| 245 std::string debug_identifier; | 249 std::string debug_identifier; |
| 246 version_info::Channel channel = version_info::Channel::UNKNOWN; | 250 version_info::Channel channel = version_info::Channel::UNKNOWN; |
| 247 scoped_refptr<base::SingleThreadTaskRunner> db_thread; | 251 scoped_refptr<base::SingleThreadTaskRunner> db_thread; |
| 248 scoped_refptr<base::SingleThreadTaskRunner> file_thread; | 252 scoped_refptr<base::SingleThreadTaskRunner> file_thread; |
| 249 base::SequencedWorkerPool* blocking_pool = nullptr; | 253 base::SequencedWorkerPool* blocking_pool = nullptr; |
| 250 | 254 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 bool IsPassphraseRequired() const override; | 403 bool IsPassphraseRequired() const override; |
| 400 syncer::ModelTypeSet GetEncryptedDataTypes() const override; | 404 syncer::ModelTypeSet GetEncryptedDataTypes() const override; |
| 401 | 405 |
| 402 // SigninManagerBase::Observer implementation. | 406 // SigninManagerBase::Observer implementation. |
| 403 void GoogleSigninSucceeded(const std::string& account_id, | 407 void GoogleSigninSucceeded(const std::string& account_id, |
| 404 const std::string& username, | 408 const std::string& username, |
| 405 const std::string& password) override; | 409 const std::string& password) override; |
| 406 void GoogleSignedOut(const std::string& account_id, | 410 void GoogleSignedOut(const std::string& account_id, |
| 407 const std::string& username) override; | 411 const std::string& username) override; |
| 408 | 412 |
| 413 // GaiaCookieManagerService::Observer implementation. | |
| 414 void OnGaiaAccountsInCookieUpdated( | |
| 415 const std::vector<gaia::ListedAccount>& accounts, | |
| 416 const GoogleServiceAuthError& error) override; | |
| 417 | |
| 409 // Get the sync status code. | 418 // Get the sync status code. |
| 410 SyncStatusSummary QuerySyncStatusSummary(); | 419 SyncStatusSummary QuerySyncStatusSummary(); |
| 411 | 420 |
| 412 // Reconfigures the data type manager with the latest enabled types. | 421 // Reconfigures the data type manager with the latest enabled types. |
| 413 // Note: Does not initialize the backend if it is not already initialized. | 422 // Note: Does not initialize the backend if it is not already initialized. |
| 414 // This function needs to be called only after sync has been initialized | 423 // This function needs to be called only after sync has been initialized |
| 415 // (i.e.,only for reconfigurations). The reason we don't initialize the | 424 // (i.e.,only for reconfigurations). The reason we don't initialize the |
| 416 // backend is because if we had encountered an unrecoverable error we don't | 425 // backend is because if we had encountered an unrecoverable error we don't |
| 417 // want to startup once more. | 426 // want to startup once more. |
| 418 // This function is called by |SetSetupInProgress|. | 427 // This function is called by |SetSetupInProgress|. |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 net::BackoffEntry request_access_token_backoff_; | 948 net::BackoffEntry request_access_token_backoff_; |
| 940 | 949 |
| 941 // States related to sync token and connection. | 950 // States related to sync token and connection. |
| 942 base::Time connection_status_update_time_; | 951 base::Time connection_status_update_time_; |
| 943 syncer::ConnectionStatus connection_status_; | 952 syncer::ConnectionStatus connection_status_; |
| 944 base::Time token_request_time_; | 953 base::Time token_request_time_; |
| 945 base::Time token_receive_time_; | 954 base::Time token_receive_time_; |
| 946 GoogleServiceAuthError last_get_token_error_; | 955 GoogleServiceAuthError last_get_token_error_; |
| 947 base::Time next_token_request_time_; | 956 base::Time next_token_request_time_; |
| 948 | 957 |
| 958 // The gaia cookie manager. | |
|
maxbogue
2016/04/01 22:30:48
This comment isn't particularly useful. Could you
Nicolas Zea
2016/04/04 19:57:31
Done.
| |
| 959 GaiaCookieManagerService* const gaia_cookie_manager_service_; | |
| 960 | |
| 949 scoped_ptr<sync_driver::LocalDeviceInfoProvider> local_device_; | 961 scoped_ptr<sync_driver::LocalDeviceInfoProvider> local_device_; |
| 950 | 962 |
| 951 // Locally owned SyncableService and ModelTypeService implementations. | 963 // Locally owned SyncableService and ModelTypeService implementations. |
| 952 scoped_ptr<browser_sync::SessionsSyncManager> sessions_sync_manager_; | 964 scoped_ptr<browser_sync::SessionsSyncManager> sessions_sync_manager_; |
| 953 scoped_ptr<sync_driver::DeviceInfoSyncService> device_info_sync_service_; | 965 scoped_ptr<sync_driver::DeviceInfoSyncService> device_info_sync_service_; |
| 954 scoped_ptr<sync_driver_v2::DeviceInfoService> device_info_service_; | 966 scoped_ptr<sync_driver_v2::DeviceInfoService> device_info_service_; |
| 955 | 967 |
| 956 scoped_ptr<syncer::NetworkResources> network_resources_; | 968 scoped_ptr<syncer::NetworkResources> network_resources_; |
| 957 | 969 |
| 958 StartBehavior start_behavior_; | 970 StartBehavior start_behavior_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; | 1014 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; |
| 1003 | 1015 |
| 1004 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1016 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 1005 }; | 1017 }; |
| 1006 | 1018 |
| 1007 bool ShouldShowActionOnUI( | 1019 bool ShouldShowActionOnUI( |
| 1008 const syncer::SyncProtocolError& error); | 1020 const syncer::SyncProtocolError& error); |
| 1009 | 1021 |
| 1010 | 1022 |
| 1011 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ | 1023 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |