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_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 6 #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 #include "components/sync/js/sync_js_controller.h" | 51 #include "components/sync/js/sync_js_controller.h" |
| 52 #include "components/version_info/version_info.h" | 52 #include "components/version_info/version_info.h" |
| 53 #include "google_apis/gaia/google_service_auth_error.h" | 53 #include "google_apis/gaia/google_service_auth_error.h" |
| 54 #include "google_apis/gaia/oauth2_token_service.h" | 54 #include "google_apis/gaia/oauth2_token_service.h" |
| 55 #include "net/base/backoff_entry.h" | 55 #include "net/base/backoff_entry.h" |
| 56 #include "url/gurl.h" | 56 #include "url/gurl.h" |
| 57 | 57 |
| 58 class Profile; | 58 class Profile; |
| 59 class ProfileOAuth2TokenService; | 59 class ProfileOAuth2TokenService; |
| 60 class SigninManagerWrapper; | 60 class SigninManagerWrapper; |
| 61 class SyncErrorController; | |
| 62 class SyncTypePreferenceProvider; | |
| 63 | 61 |
| 64 namespace sync_driver { | 62 namespace syncer { |
|
skym
2016/09/30 19:03:22
You mentioned offline that this was supposed to co
maxbogue
2016/09/30 20:13:41
Done.
| |
| 63 class BackendMigrator; | |
| 64 class BaseTransaction; | |
| 65 class DataTypeManager; | 65 class DataTypeManager; |
| 66 class DeviceInfoService; | |
| 66 class DeviceInfoSyncService; | 67 class DeviceInfoSyncService; |
| 67 class DeviceInfoTracker; | 68 class DeviceInfoTracker; |
| 68 class LocalDeviceInfoProvider; | 69 class LocalDeviceInfoProvider; |
| 70 class NetworkResources; | |
| 71 class Proto; | |
|
skym
2016/09/30 19:03:22
What is syncer::Proto? I don't see it anywhere in
maxbogue
2016/09/30 20:13:41
I have literally no idea where that came from. Goo
| |
| 69 class SyncApiComponentFactory; | 72 class SyncApiComponentFactory; |
| 70 class SyncClient; | 73 class SyncClient; |
| 71 } // namespace sync_driver | 74 class SyncErrorController; |
| 72 | 75 class SyncTypePreferenceProvider; |
| 73 namespace sync_driver_v2 { | |
| 74 class DeviceInfoService; | |
| 75 } | |
| 76 | |
| 77 namespace sync_sessions { | |
| 78 class FaviconCache; | |
| 79 class OpenTabsUIDelegate; | |
| 80 class SessionsSyncManager; | |
| 81 } // namespace sync_sessions | |
| 82 | |
| 83 namespace syncer { | |
| 84 class BaseTransaction; | |
| 85 class NetworkResources; | |
| 86 class TypeDebugInfoObserver; | 76 class TypeDebugInfoObserver; |
| 87 struct CommitCounters; | 77 struct CommitCounters; |
| 88 struct StatusCounters; | 78 struct StatusCounters; |
| 89 struct SyncCredentials; | 79 struct SyncCredentials; |
| 90 struct UpdateCounters; | 80 struct UpdateCounters; |
| 91 struct UserShare; | 81 struct UserShare; |
| 92 } // namespace syncer | 82 } // namespace syncer |
| 93 | 83 |
| 94 namespace sync_pb { | 84 namespace sync_pb { |
| 95 class EncryptedData; | 85 class EncryptedData; |
| 96 } // namespace sync_pb | 86 } // namespace sync_pb |
| 97 | 87 |
| 88 namespace sync_sessions { | |
| 89 class FaviconCache; | |
| 90 class OpenTabsUIDelegate; | |
| 91 class SessionsSyncManager; | |
| 92 } // namespace sync_sessions | |
| 93 | |
| 98 namespace browser_sync { | 94 namespace browser_sync { |
| 99 | 95 |
| 100 class BackendMigrator; | |
| 101 | |
| 102 // ProfileSyncService is the layer between browser subsystems like bookmarks, | 96 // ProfileSyncService is the layer between browser subsystems like bookmarks, |
| 103 // and the sync backend. Each subsystem is logically thought of as being | 97 // and the sync backend. Each subsystem is logically thought of as being |
| 104 // a sync datatype. | 98 // a sync datatype. |
| 105 // | 99 // |
| 106 // Individual datatypes can, at any point, be in a variety of stages of being | 100 // Individual datatypes can, at any point, be in a variety of stages of being |
| 107 // "enabled". Here are some specific terms for concepts used in this class: | 101 // "enabled". Here are some specific terms for concepts used in this class: |
| 108 // | 102 // |
| 109 // 'Registered' (feature suppression for a datatype) | 103 // 'Registered' (feature suppression for a datatype) |
| 110 // | 104 // |
| 111 // When a datatype is registered, the user has the option of syncing it. | 105 // When a datatype is registered, the user has the option of syncing it. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 // * GetSetupInProgressHandle() | 165 // * GetSetupInProgressHandle() |
| 172 // | 166 // |
| 173 // SetFirstSetupComplete() should be called once the user has finished setting | 167 // SetFirstSetupComplete() should be called once the user has finished setting |
| 174 // up sync at least once on their account. GetSetupInProgressHandle() should | 168 // up sync at least once on their account. GetSetupInProgressHandle() should |
| 175 // be called while the user is actively configuring their account. The handle | 169 // be called while the user is actively configuring their account. The handle |
| 176 // should be deleted once configuration is complete. | 170 // should be deleted once configuration is complete. |
| 177 // | 171 // |
| 178 // Once first setup has completed and there are no outstanding | 172 // Once first setup has completed and there are no outstanding |
| 179 // setup-in-progress handles, CanConfigureDataTypes() will return true and | 173 // setup-in-progress handles, CanConfigureDataTypes() will return true and |
| 180 // datatype configuration can begin. | 174 // datatype configuration can begin. |
| 181 class ProfileSyncService : public sync_driver::SyncService, | 175 class ProfileSyncService : public syncer::SyncService, |
| 182 public sync_driver::SyncFrontend, | 176 public syncer::SyncFrontend, |
| 183 public sync_driver::SyncPrefObserver, | 177 public syncer::SyncPrefObserver, |
| 184 public sync_driver::DataTypeManagerObserver, | 178 public syncer::DataTypeManagerObserver, |
| 185 public syncer::UnrecoverableErrorHandler, | 179 public syncer::UnrecoverableErrorHandler, |
| 186 public KeyedService, | 180 public KeyedService, |
| 187 public OAuth2TokenService::Consumer, | 181 public OAuth2TokenService::Consumer, |
| 188 public OAuth2TokenService::Observer, | 182 public OAuth2TokenService::Observer, |
| 189 public SigninManagerBase::Observer, | 183 public SigninManagerBase::Observer, |
| 190 public GaiaCookieManagerService::Observer { | 184 public GaiaCookieManagerService::Observer { |
| 191 public: | 185 public: |
| 192 typedef SyncBackendHost::Status Status; | 186 typedef syncer::SyncBackendHost::Status Status; |
| 193 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; | 187 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; |
| 194 | 188 |
| 195 enum SyncEventCodes { | 189 enum SyncEventCodes { |
| 196 MIN_SYNC_EVENT_CODE = 0, | 190 MIN_SYNC_EVENT_CODE = 0, |
| 197 | 191 |
| 198 // Events starting the sync service. | 192 // Events starting the sync service. |
| 199 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 193 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 200 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 194 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| 201 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. | 195 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
| 202 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. | 196 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 | 230 |
| 237 // Bundles the arguments for ProfileSyncService construction. This is a | 231 // Bundles the arguments for ProfileSyncService construction. This is a |
| 238 // movable struct. Because of the non-POD data members, it needs out-of-line | 232 // movable struct. Because of the non-POD data members, it needs out-of-line |
| 239 // constructors, so in particular the move constructor needs to be | 233 // constructors, so in particular the move constructor needs to be |
| 240 // explicitly defined. | 234 // explicitly defined. |
| 241 struct InitParams { | 235 struct InitParams { |
| 242 InitParams(); | 236 InitParams(); |
| 243 ~InitParams(); | 237 ~InitParams(); |
| 244 InitParams(InitParams&& other); // NOLINT | 238 InitParams(InitParams&& other); // NOLINT |
| 245 | 239 |
| 246 std::unique_ptr<sync_driver::SyncClient> sync_client; | 240 std::unique_ptr<syncer::SyncClient> sync_client; |
| 247 std::unique_ptr<SigninManagerWrapper> signin_wrapper; | 241 std::unique_ptr<SigninManagerWrapper> signin_wrapper; |
| 248 ProfileOAuth2TokenService* oauth2_token_service = nullptr; | 242 ProfileOAuth2TokenService* oauth2_token_service = nullptr; |
| 249 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; | 243 GaiaCookieManagerService* gaia_cookie_manager_service = nullptr; |
| 250 StartBehavior start_behavior = MANUAL_START; | 244 StartBehavior start_behavior = MANUAL_START; |
| 251 syncer::NetworkTimeUpdateCallback network_time_update_callback; | 245 syncer::NetworkTimeUpdateCallback network_time_update_callback; |
| 252 base::FilePath base_directory; | 246 base::FilePath base_directory; |
| 253 scoped_refptr<net::URLRequestContextGetter> url_request_context; | 247 scoped_refptr<net::URLRequestContextGetter> url_request_context; |
| 254 std::string debug_identifier; | 248 std::string debug_identifier; |
| 255 version_info::Channel channel = version_info::Channel::UNKNOWN; | 249 version_info::Channel channel = version_info::Channel::UNKNOWN; |
| 256 scoped_refptr<base::SingleThreadTaskRunner> db_thread; | 250 scoped_refptr<base::SingleThreadTaskRunner> db_thread; |
| 257 scoped_refptr<base::SingleThreadTaskRunner> file_thread; | 251 scoped_refptr<base::SingleThreadTaskRunner> file_thread; |
| 258 base::SequencedWorkerPool* blocking_pool = nullptr; | 252 base::SequencedWorkerPool* blocking_pool = nullptr; |
| 259 | 253 |
| 260 private: | 254 private: |
| 261 DISALLOW_COPY_AND_ASSIGN(InitParams); | 255 DISALLOW_COPY_AND_ASSIGN(InitParams); |
| 262 }; | 256 }; |
| 263 | 257 |
| 264 explicit ProfileSyncService(InitParams init_params); | 258 explicit ProfileSyncService(InitParams init_params); |
| 265 | 259 |
| 266 ~ProfileSyncService() override; | 260 ~ProfileSyncService() override; |
| 267 | 261 |
| 268 // Initializes the object. This must be called at most once, and | 262 // Initializes the object. This must be called at most once, and |
| 269 // immediately after an object of this class is constructed. | 263 // immediately after an object of this class is constructed. |
| 270 void Initialize(); | 264 void Initialize(); |
| 271 | 265 |
| 272 // sync_driver::SyncService implementation | 266 // syncer::SyncService implementation |
| 273 bool IsFirstSetupComplete() const override; | 267 bool IsFirstSetupComplete() const override; |
| 274 bool IsSyncAllowed() const override; | 268 bool IsSyncAllowed() const override; |
| 275 bool IsSyncActive() const override; | 269 bool IsSyncActive() const override; |
| 276 void TriggerRefresh(const syncer::ModelTypeSet& types) override; | 270 void TriggerRefresh(const syncer::ModelTypeSet& types) override; |
| 277 void OnDataTypeRequestsSyncStartup(syncer::ModelType type) override; | 271 void OnDataTypeRequestsSyncStartup(syncer::ModelType type) override; |
| 278 bool CanSyncStart() const override; | 272 bool CanSyncStart() const override; |
| 279 void RequestStop(SyncStopDataFate data_fate) override; | 273 void RequestStop(SyncStopDataFate data_fate) override; |
| 280 void RequestStart() override; | 274 void RequestStart() override; |
| 281 syncer::ModelTypeSet GetActiveDataTypes() const override; | 275 syncer::ModelTypeSet GetActiveDataTypes() const override; |
| 282 sync_driver::SyncClient* GetSyncClient() const override; | 276 syncer::SyncClient* GetSyncClient() const override; |
| 283 syncer::ModelTypeSet GetPreferredDataTypes() const override; | 277 syncer::ModelTypeSet GetPreferredDataTypes() const override; |
| 284 void OnUserChoseDatatypes(bool sync_everything, | 278 void OnUserChoseDatatypes(bool sync_everything, |
| 285 syncer::ModelTypeSet chosen_types) override; | 279 syncer::ModelTypeSet chosen_types) override; |
| 286 void SetFirstSetupComplete() override; | 280 void SetFirstSetupComplete() override; |
| 287 bool IsFirstSetupInProgress() const override; | 281 bool IsFirstSetupInProgress() const override; |
| 288 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> | 282 std::unique_ptr<syncer::SyncSetupInProgressHandle> GetSetupInProgressHandle() |
| 289 GetSetupInProgressHandle() override; | 283 override; |
| 290 bool IsSetupInProgress() const override; | 284 bool IsSetupInProgress() const override; |
| 291 bool ConfigurationDone() const override; | 285 bool ConfigurationDone() const override; |
| 292 const GoogleServiceAuthError& GetAuthError() const override; | 286 const GoogleServiceAuthError& GetAuthError() const override; |
| 293 bool HasUnrecoverableError() const override; | 287 bool HasUnrecoverableError() const override; |
| 294 bool IsBackendInitialized() const override; | 288 bool IsBackendInitialized() const override; |
| 295 sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; | 289 sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; |
| 296 bool IsPassphraseRequiredForDecryption() const override; | 290 bool IsPassphraseRequiredForDecryption() const override; |
| 297 base::Time GetExplicitPassphraseTime() const override; | 291 base::Time GetExplicitPassphraseTime() const override; |
| 298 bool IsUsingSecondaryPassphrase() const override; | 292 bool IsUsingSecondaryPassphrase() const override; |
| 299 void EnableEncryptEverything() override; | 293 void EnableEncryptEverything() override; |
| 300 bool IsEncryptEverythingEnabled() const override; | 294 bool IsEncryptEverythingEnabled() const override; |
| 301 void SetEncryptionPassphrase(const std::string& passphrase, | 295 void SetEncryptionPassphrase(const std::string& passphrase, |
| 302 PassphraseType type) override; | 296 PassphraseType type) override; |
| 303 bool SetDecryptionPassphrase(const std::string& passphrase) override | 297 bool SetDecryptionPassphrase(const std::string& passphrase) override |
| 304 WARN_UNUSED_RESULT; | 298 WARN_UNUSED_RESULT; |
| 305 bool IsCryptographerReady( | 299 bool IsCryptographerReady( |
| 306 const syncer::BaseTransaction* trans) const override; | 300 const syncer::BaseTransaction* trans) const override; |
| 307 syncer::UserShare* GetUserShare() const override; | 301 syncer::UserShare* GetUserShare() const override; |
| 308 sync_driver::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() | 302 syncer::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const override; |
| 309 const override; | 303 void AddObserver(syncer::SyncServiceObserver* observer) override; |
| 310 void AddObserver(sync_driver::SyncServiceObserver* observer) override; | 304 void RemoveObserver(syncer::SyncServiceObserver* observer) override; |
| 311 void RemoveObserver(sync_driver::SyncServiceObserver* observer) override; | 305 bool HasObserver(const syncer::SyncServiceObserver* observer) const override; |
| 312 bool HasObserver( | 306 void RegisterDataTypeController(std::unique_ptr<syncer::DataTypeController> |
| 313 const sync_driver::SyncServiceObserver* observer) const override; | 307 data_type_controller) override; |
| 314 void RegisterDataTypeController( | |
| 315 std::unique_ptr<sync_driver::DataTypeController> data_type_controller) | |
| 316 override; | |
| 317 void ReenableDatatype(syncer::ModelType type) override; | 308 void ReenableDatatype(syncer::ModelType type) override; |
| 318 SyncTokenStatus GetSyncTokenStatus() const override; | 309 SyncTokenStatus GetSyncTokenStatus() const override; |
| 319 std::string QuerySyncStatusSummaryString() override; | 310 std::string QuerySyncStatusSummaryString() override; |
| 320 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override; | 311 bool QueryDetailedSyncStatus(syncer::SyncStatus* result) override; |
| 321 base::string16 GetLastSyncedTimeString() const override; | 312 base::string16 GetLastSyncedTimeString() const override; |
| 322 std::string GetBackendInitializationStateString() const override; | 313 std::string GetBackendInitializationStateString() const override; |
| 323 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; | 314 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; |
| 324 base::Value* GetTypeStatusMap() const override; | 315 base::Value* GetTypeStatusMap() const override; |
| 325 const GURL& sync_service_url() const override; | 316 const GURL& sync_service_url() const override; |
| 326 std::string unrecoverable_error_message() const override; | 317 std::string unrecoverable_error_message() const override; |
| 327 tracked_objects::Location unrecoverable_error_location() const override; | 318 tracked_objects::Location unrecoverable_error_location() const override; |
| 328 void AddProtocolEventObserver(ProtocolEventObserver* observer) override; | 319 void AddProtocolEventObserver( |
| 329 void RemoveProtocolEventObserver(ProtocolEventObserver* observer) override; | 320 syncer::ProtocolEventObserver* observer) override; |
| 321 void RemoveProtocolEventObserver( | |
| 322 syncer::ProtocolEventObserver* observer) override; | |
| 330 void AddTypeDebugInfoObserver( | 323 void AddTypeDebugInfoObserver( |
| 331 syncer::TypeDebugInfoObserver* observer) override; | 324 syncer::TypeDebugInfoObserver* observer) override; |
| 332 void RemoveTypeDebugInfoObserver( | 325 void RemoveTypeDebugInfoObserver( |
| 333 syncer::TypeDebugInfoObserver* observer) override; | 326 syncer::TypeDebugInfoObserver* observer) override; |
| 334 base::WeakPtr<syncer::JsController> GetJsController() override; | 327 base::WeakPtr<syncer::JsController> GetJsController() override; |
| 335 void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>& | 328 void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>& |
| 336 callback) override; | 329 callback) override; |
| 337 | 330 |
| 338 // Add a sync type preference provider. Each provider may only be added once. | 331 // Add a sync type preference provider. Each provider may only be added once. |
| 339 void AddPreferenceProvider(SyncTypePreferenceProvider* provider); | 332 void AddPreferenceProvider(syncer::SyncTypePreferenceProvider* provider); |
| 340 // Remove a sync type preference provider. May only be called for providers | 333 // Remove a sync type preference provider. May only be called for providers |
| 341 // that have been added. Providers must not remove themselves while being | 334 // that have been added. Providers must not remove themselves while being |
| 342 // called back. | 335 // called back. |
| 343 void RemovePreferenceProvider(SyncTypePreferenceProvider* provider); | 336 void RemovePreferenceProvider(syncer::SyncTypePreferenceProvider* provider); |
| 344 // Check whether a given sync type preference provider has been added. | 337 // Check whether a given sync type preference provider has been added. |
| 345 bool HasPreferenceProvider(SyncTypePreferenceProvider* provider) const; | 338 bool HasPreferenceProvider( |
| 339 syncer::SyncTypePreferenceProvider* provider) const; | |
| 346 | 340 |
| 347 void RegisterAuthNotifications(); | 341 void RegisterAuthNotifications(); |
| 348 void UnregisterAuthNotifications(); | 342 void UnregisterAuthNotifications(); |
| 349 | 343 |
| 350 // Returns the SyncableService for syncer::SESSIONS. | 344 // Returns the SyncableService for syncer::SESSIONS. |
| 351 virtual syncer::SyncableService* GetSessionsSyncableService(); | 345 virtual syncer::SyncableService* GetSessionsSyncableService(); |
| 352 | 346 |
| 353 // Returns the SyncableService for syncer::DEVICE_INFO. | 347 // Returns the SyncableService for syncer::DEVICE_INFO. |
| 354 virtual syncer::SyncableService* GetDeviceInfoSyncableService(); | 348 virtual syncer::SyncableService* GetDeviceInfoSyncableService(); |
| 355 | 349 |
| 356 // Returns the ModelTypeService for syncer::DEVICE_INFO. | 350 // Returns the ModelTypeService for syncer::DEVICE_INFO. |
| 357 virtual syncer_v2::ModelTypeService* GetDeviceInfoService(); | 351 virtual syncer::ModelTypeService* GetDeviceInfoService(); |
| 358 | 352 |
| 359 // Returns synced devices tracker. | 353 // Returns synced devices tracker. |
| 360 virtual sync_driver::DeviceInfoTracker* GetDeviceInfoTracker() const; | 354 virtual syncer::DeviceInfoTracker* GetDeviceInfoTracker() const; |
| 361 | 355 |
| 362 // Fills state_map with a map of current data types that are possible to | 356 // Fills state_map with a map of current data types that are possible to |
| 363 // sync, as well as their states. | 357 // sync, as well as their states. |
| 364 void GetDataTypeControllerStates( | 358 void GetDataTypeControllerStates( |
| 365 sync_driver::DataTypeController::StateMap* state_map) const; | 359 syncer::DataTypeController::StateMap* state_map) const; |
| 366 | 360 |
| 367 // Called when asynchronous session restore has completed. | 361 // Called when asynchronous session restore has completed. |
| 368 void OnSessionRestoreComplete(); | 362 void OnSessionRestoreComplete(); |
| 369 | 363 |
| 370 // SyncFrontend implementation. | 364 // SyncFrontend implementation. |
| 371 void OnBackendInitialized( | 365 void OnBackendInitialized( |
| 372 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 366 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 373 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 367 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 374 debug_info_listener, | 368 debug_info_listener, |
| 375 const std::string& cache_guid, | 369 const std::string& cache_guid, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 394 bool encrypt_everything) override; | 388 bool encrypt_everything) override; |
| 395 void OnEncryptionComplete() override; | 389 void OnEncryptionComplete() override; |
| 396 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override; | 390 void OnMigrationNeededForTypes(syncer::ModelTypeSet types) override; |
| 397 void OnExperimentsChanged(const syncer::Experiments& experiments) override; | 391 void OnExperimentsChanged(const syncer::Experiments& experiments) override; |
| 398 void OnActionableError(const syncer::SyncProtocolError& error) override; | 392 void OnActionableError(const syncer::SyncProtocolError& error) override; |
| 399 void OnLocalSetPassphraseEncryption( | 393 void OnLocalSetPassphraseEncryption( |
| 400 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) override; | 394 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) override; |
| 401 | 395 |
| 402 // DataTypeManagerObserver implementation. | 396 // DataTypeManagerObserver implementation. |
| 403 void OnConfigureDone( | 397 void OnConfigureDone( |
| 404 const sync_driver::DataTypeManager::ConfigureResult& result) override; | 398 const syncer::DataTypeManager::ConfigureResult& result) override; |
| 405 void OnConfigureStart() override; | 399 void OnConfigureStart() override; |
| 406 | 400 |
| 407 // DataTypeEncryptionHandler implementation. | 401 // DataTypeEncryptionHandler implementation. |
| 408 bool IsPassphraseRequired() const override; | 402 bool IsPassphraseRequired() const override; |
| 409 syncer::ModelTypeSet GetEncryptedDataTypes() const override; | 403 syncer::ModelTypeSet GetEncryptedDataTypes() const override; |
| 410 | 404 |
| 411 // SigninManagerBase::Observer implementation. | 405 // SigninManagerBase::Observer implementation. |
| 412 void GoogleSigninSucceeded(const std::string& account_id, | 406 void GoogleSigninSucceeded(const std::string& account_id, |
| 413 const std::string& username, | 407 const std::string& username, |
| 414 const std::string& password) override; | 408 const std::string& password) override; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 // TODO(akalin): These two functions are used only by | 464 // TODO(akalin): These two functions are used only by |
| 471 // ProfileSyncServiceHarness. Figure out a different way to expose | 465 // ProfileSyncServiceHarness. Figure out a different way to expose |
| 472 // this info to that class, and remove these functions. | 466 // this info to that class, and remove these functions. |
| 473 | 467 |
| 474 // Returns whether or not the underlying sync engine has made any | 468 // Returns whether or not the underlying sync engine has made any |
| 475 // local changes to items that have not yet been synced with the | 469 // local changes to items that have not yet been synced with the |
| 476 // server. | 470 // server. |
| 477 bool HasUnsyncedItems() const; | 471 bool HasUnsyncedItems() const; |
| 478 | 472 |
| 479 // Used by ProfileSyncServiceHarness. May return NULL. | 473 // Used by ProfileSyncServiceHarness. May return NULL. |
| 480 BackendMigrator* GetBackendMigratorForTest(); | 474 syncer::BackendMigrator* GetBackendMigratorForTest(); |
| 481 | 475 |
| 482 // Used by tests to inspect interaction with OAuth2TokenService. | 476 // Used by tests to inspect interaction with OAuth2TokenService. |
| 483 bool IsRetryingAccessTokenFetchForTest() const; | 477 bool IsRetryingAccessTokenFetchForTest() const; |
| 484 | 478 |
| 485 // Used by tests to inspect the OAuth2 access tokens used by PSS. | 479 // Used by tests to inspect the OAuth2 access tokens used by PSS. |
| 486 std::string GetAccessTokenForTest() const; | 480 std::string GetAccessTokenForTest() const; |
| 487 | 481 |
| 488 // TODO(sync): This is only used in tests. Can we remove it? | 482 // TODO(sync): This is only used in tests. Can we remove it? |
| 489 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; | 483 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; |
| 490 | 484 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 virtual bool IsEncryptEverythingAllowed() const; | 516 virtual bool IsEncryptEverythingAllowed() const; |
| 523 | 517 |
| 524 // Sets whether encrypting all the sync data is allowed or not. | 518 // Sets whether encrypting all the sync data is allowed or not. |
| 525 virtual void SetEncryptEverythingAllowed(bool allowed); | 519 virtual void SetEncryptEverythingAllowed(bool allowed); |
| 526 | 520 |
| 527 // Returns true if the syncer is waiting for new datatypes to be encrypted. | 521 // Returns true if the syncer is waiting for new datatypes to be encrypted. |
| 528 virtual bool encryption_pending() const; | 522 virtual bool encryption_pending() const; |
| 529 | 523 |
| 530 SigninManagerBase* signin() const; | 524 SigninManagerBase* signin() const; |
| 531 | 525 |
| 532 SyncErrorController* sync_error_controller() { | 526 syncer::SyncErrorController* sync_error_controller() { |
| 533 return sync_error_controller_.get(); | 527 return sync_error_controller_.get(); |
| 534 } | 528 } |
| 535 | 529 |
| 536 // TODO(sync): This is only used in tests. Can we remove it? | 530 // TODO(sync): This is only used in tests. Can we remove it? |
| 537 const sync_driver::DataTypeStatusTable& data_type_status_table() const; | 531 const syncer::DataTypeStatusTable& data_type_status_table() const; |
| 538 | 532 |
| 539 sync_driver::DataTypeManager::ConfigureStatus configure_status() { | 533 syncer::DataTypeManager::ConfigureStatus configure_status() { |
| 540 return configure_status_; | 534 return configure_status_; |
| 541 } | 535 } |
| 542 | 536 |
| 543 // If true, the ProfileSyncService has detected that a new GAIA signin has | 537 // If true, the ProfileSyncService has detected that a new GAIA signin has |
| 544 // succeeded, and is waiting for initialization to complete. This is used by | 538 // succeeded, and is waiting for initialization to complete. This is used by |
| 545 // the UI to differentiate between a new auth error (encountered as part of | 539 // the UI to differentiate between a new auth error (encountered as part of |
| 546 // the initialization process) and a pre-existing auth error that just hasn't | 540 // the initialization process) and a pre-existing auth error that just hasn't |
| 547 // been cleared yet. Virtual for testing purposes. | 541 // been cleared yet. Virtual for testing purposes. |
| 548 virtual bool waiting_for_auth() const; | 542 virtual bool waiting_for_auth() const; |
| 549 | 543 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 const std::string& message, | 615 const std::string& message, |
| 622 bool delete_sync_database); | 616 bool delete_sync_database); |
| 623 | 617 |
| 624 // This is a cache of the last authentication response we received from the | 618 // This is a cache of the last authentication response we received from the |
| 625 // sync server. The UI queries this to display appropriate messaging to the | 619 // sync server. The UI queries this to display appropriate messaging to the |
| 626 // user. | 620 // user. |
| 627 GoogleServiceAuthError last_auth_error_; | 621 GoogleServiceAuthError last_auth_error_; |
| 628 | 622 |
| 629 // Our asynchronous backend to communicate with sync components living on | 623 // Our asynchronous backend to communicate with sync components living on |
| 630 // other threads. | 624 // other threads. |
| 631 std::unique_ptr<SyncBackendHost> backend_; | 625 std::unique_ptr<syncer::SyncBackendHost> backend_; |
| 632 | 626 |
| 633 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it | 627 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it |
| 634 // was required for encryption, decryption with a cached passphrase, or | 628 // was required for encryption, decryption with a cached passphrase, or |
| 635 // because a new passphrase is required? | 629 // because a new passphrase is required? |
| 636 syncer::PassphraseRequiredReason passphrase_required_reason_; | 630 syncer::PassphraseRequiredReason passphrase_required_reason_; |
| 637 | 631 |
| 638 private: | 632 private: |
| 639 enum UnrecoverableErrorReason { | 633 enum UnrecoverableErrorReason { |
| 640 ERROR_REASON_UNSET, | 634 ERROR_REASON_UNSET, |
| 641 ERROR_REASON_SYNCER, | 635 ERROR_REASON_SYNCER, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 void OnClearServerDataDone(); | 789 void OnClearServerDataDone(); |
| 796 | 790 |
| 797 // True if setup has been completed at least once and is not in progress. | 791 // True if setup has been completed at least once and is not in progress. |
| 798 bool CanConfigureDataTypes() const; | 792 bool CanConfigureDataTypes() const; |
| 799 | 793 |
| 800 // Called when a SetupInProgressHandle issued by this instance is destroyed. | 794 // Called when a SetupInProgressHandle issued by this instance is destroyed. |
| 801 virtual void OnSetupInProgressHandleDestroyed(); | 795 virtual void OnSetupInProgressHandleDestroyed(); |
| 802 | 796 |
| 803 // This profile's SyncClient, which abstracts away non-Sync dependencies and | 797 // This profile's SyncClient, which abstracts away non-Sync dependencies and |
| 804 // the Sync API component factory. | 798 // the Sync API component factory. |
| 805 std::unique_ptr<sync_driver::SyncClient> sync_client_; | 799 std::unique_ptr<syncer::SyncClient> sync_client_; |
| 806 | 800 |
| 807 // The class that handles getting, setting, and persisting sync | 801 // The class that handles getting, setting, and persisting sync |
| 808 // preferences. | 802 // preferences. |
| 809 sync_driver::SyncPrefs sync_prefs_; | 803 syncer::SyncPrefs sync_prefs_; |
| 810 | 804 |
| 811 // TODO(ncarter): Put this in a profile, once there is UI for it. | 805 // TODO(ncarter): Put this in a profile, once there is UI for it. |
| 812 // This specifies where to find the sync server. | 806 // This specifies where to find the sync server. |
| 813 const GURL sync_service_url_; | 807 const GURL sync_service_url_; |
| 814 | 808 |
| 815 // The time that OnConfigureStart is called. This member is zero if | 809 // The time that OnConfigureStart is called. This member is zero if |
| 816 // OnConfigureStart has not yet been called, and is reset to zero once | 810 // OnConfigureStart has not yet been called, and is reset to zero once |
| 817 // OnConfigureDone is called. | 811 // OnConfigureDone is called. |
| 818 base::Time sync_configure_start_time_; | 812 base::Time sync_configure_start_time_; |
| 819 | 813 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 840 | 834 |
| 841 // Indicates if this is the first time sync is being configured. This value | 835 // Indicates if this is the first time sync is being configured. This value |
| 842 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). | 836 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). |
| 843 bool is_first_time_sync_configure_; | 837 bool is_first_time_sync_configure_; |
| 844 | 838 |
| 845 // Number of UIs currently configuring the Sync service. When this number | 839 // Number of UIs currently configuring the Sync service. When this number |
| 846 // is decremented back to zero, Sync setup is marked no longer in progress. | 840 // is decremented back to zero, Sync setup is marked no longer in progress. |
| 847 int outstanding_setup_in_progress_handles_ = 0; | 841 int outstanding_setup_in_progress_handles_ = 0; |
| 848 | 842 |
| 849 // List of available data type controllers. | 843 // List of available data type controllers. |
| 850 sync_driver::DataTypeController::TypeMap data_type_controllers_; | 844 syncer::DataTypeController::TypeMap data_type_controllers_; |
| 851 | 845 |
| 852 // Whether the SyncBackendHost has been initialized. | 846 // Whether the SyncBackendHost has been initialized. |
| 853 bool backend_initialized_; | 847 bool backend_initialized_; |
| 854 | 848 |
| 855 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents | 849 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents |
| 856 // ProfileSyncService from starting backend till browser restarted or user | 850 // ProfileSyncService from starting backend till browser restarted or user |
| 857 // signed out. | 851 // signed out. |
| 858 bool sync_disabled_by_admin_; | 852 bool sync_disabled_by_admin_; |
| 859 | 853 |
| 860 // Set to true if a signin has completed but we're still waiting for the | 854 // Set to true if a signin has completed but we're still waiting for the |
| 861 // backend to refresh its credentials. | 855 // backend to refresh its credentials. |
| 862 bool is_auth_in_progress_; | 856 bool is_auth_in_progress_; |
| 863 | 857 |
| 864 // Encapsulates user signin - used to set/get the user's authenticated | 858 // Encapsulates user signin - used to set/get the user's authenticated |
| 865 // email address. | 859 // email address. |
| 866 const std::unique_ptr<SigninManagerWrapper> signin_; | 860 const std::unique_ptr<SigninManagerWrapper> signin_; |
| 867 | 861 |
| 868 // Information describing an unrecoverable error. | 862 // Information describing an unrecoverable error. |
| 869 UnrecoverableErrorReason unrecoverable_error_reason_; | 863 UnrecoverableErrorReason unrecoverable_error_reason_; |
| 870 std::string unrecoverable_error_message_; | 864 std::string unrecoverable_error_message_; |
| 871 tracked_objects::Location unrecoverable_error_location_; | 865 tracked_objects::Location unrecoverable_error_location_; |
| 872 | 866 |
| 873 // Manages the start and stop of the data types. | 867 // Manages the start and stop of the data types. |
| 874 std::unique_ptr<sync_driver::DataTypeManager> data_type_manager_; | 868 std::unique_ptr<syncer::DataTypeManager> data_type_manager_; |
| 875 | 869 |
| 876 base::ObserverList<sync_driver::SyncServiceObserver> observers_; | 870 base::ObserverList<syncer::SyncServiceObserver> observers_; |
| 877 base::ObserverList<ProtocolEventObserver> protocol_event_observers_; | 871 base::ObserverList<syncer::ProtocolEventObserver> protocol_event_observers_; |
| 878 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; | 872 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; |
| 879 | 873 |
| 880 std::set<SyncTypePreferenceProvider*> preference_providers_; | 874 std::set<syncer::SyncTypePreferenceProvider*> preference_providers_; |
| 881 | 875 |
| 882 syncer::SyncJsController sync_js_controller_; | 876 syncer::SyncJsController sync_js_controller_; |
| 883 | 877 |
| 884 // This allows us to gracefully handle an ABORTED return code from the | 878 // This allows us to gracefully handle an ABORTED return code from the |
| 885 // DataTypeManager in the event that the server informed us to cease and | 879 // DataTypeManager in the event that the server informed us to cease and |
| 886 // desist syncing immediately. | 880 // desist syncing immediately. |
| 887 bool expect_sync_configuration_aborted_; | 881 bool expect_sync_configuration_aborted_; |
| 888 | 882 |
| 889 // Sometimes we need to temporarily hold on to a passphrase because we don't | 883 // Sometimes we need to temporarily hold on to a passphrase because we don't |
| 890 // yet have a backend to send it to. This happens during initialization as | 884 // yet have a backend to send it to. This happens during initialization as |
| 891 // we don't StartUp until we have a valid token, which happens after valid | 885 // we don't StartUp until we have a valid token, which happens after valid |
| 892 // credentials were provided. | 886 // credentials were provided. |
| 893 std::string cached_passphrase_; | 887 std::string cached_passphrase_; |
| 894 | 888 |
| 895 // The current set of encrypted types. Always a superset of | 889 // The current set of encrypted types. Always a superset of |
| 896 // syncer::Cryptographer::SensitiveTypes(). | 890 // syncer::Cryptographer::SensitiveTypes(). |
| 897 syncer::ModelTypeSet encrypted_types_; | 891 syncer::ModelTypeSet encrypted_types_; |
| 898 | 892 |
| 899 // Whether encrypting everything is allowed. | 893 // Whether encrypting everything is allowed. |
| 900 bool encrypt_everything_allowed_; | 894 bool encrypt_everything_allowed_; |
| 901 | 895 |
| 902 // Whether we want to encrypt everything. | 896 // Whether we want to encrypt everything. |
| 903 bool encrypt_everything_; | 897 bool encrypt_everything_; |
| 904 | 898 |
| 905 // Whether we're waiting for an attempt to encryption all sync data to | 899 // Whether we're waiting for an attempt to encryption all sync data to |
| 906 // complete. We track this at this layer in order to allow the user to cancel | 900 // complete. We track this at this layer in order to allow the user to cancel |
| 907 // if they e.g. don't remember their explicit passphrase. | 901 // if they e.g. don't remember their explicit passphrase. |
| 908 bool encryption_pending_; | 902 bool encryption_pending_; |
| 909 | 903 |
| 910 std::unique_ptr<BackendMigrator> migrator_; | 904 std::unique_ptr<syncer::BackendMigrator> migrator_; |
| 911 | 905 |
| 912 // This is the last |SyncProtocolError| we received from the server that had | 906 // This is the last |SyncProtocolError| we received from the server that had |
| 913 // an action set on it. | 907 // an action set on it. |
| 914 syncer::SyncProtocolError last_actionable_error_; | 908 syncer::SyncProtocolError last_actionable_error_; |
| 915 | 909 |
| 916 // Exposes sync errors to the UI. | 910 // Exposes sync errors to the UI. |
| 917 std::unique_ptr<SyncErrorController> sync_error_controller_; | 911 std::unique_ptr<syncer::SyncErrorController> sync_error_controller_; |
| 918 | 912 |
| 919 // Tracks the set of failed data types (those that encounter an error | 913 // Tracks the set of failed data types (those that encounter an error |
| 920 // or must delay loading for some reason). | 914 // or must delay loading for some reason). |
| 921 sync_driver::DataTypeStatusTable data_type_status_table_; | 915 syncer::DataTypeStatusTable data_type_status_table_; |
| 922 | 916 |
| 923 sync_driver::DataTypeManager::ConfigureStatus configure_status_; | 917 syncer::DataTypeManager::ConfigureStatus configure_status_; |
| 924 | 918 |
| 925 // The set of currently enabled sync experiments. | 919 // The set of currently enabled sync experiments. |
| 926 syncer::Experiments current_experiments_; | 920 syncer::Experiments current_experiments_; |
| 927 | 921 |
| 928 // Sync's internal debug info listener. Used to record datatype configuration | 922 // Sync's internal debug info listener. Used to record datatype configuration |
| 929 // and association information. | 923 // and association information. |
| 930 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 924 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
| 931 | 925 |
| 932 // A thread where all the sync operations happen. | 926 // A thread where all the sync operations happen. |
| 933 // OWNERSHIP Notes: | 927 // OWNERSHIP Notes: |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 957 syncer::ConnectionStatus connection_status_; | 951 syncer::ConnectionStatus connection_status_; |
| 958 base::Time token_request_time_; | 952 base::Time token_request_time_; |
| 959 base::Time token_receive_time_; | 953 base::Time token_receive_time_; |
| 960 GoogleServiceAuthError last_get_token_error_; | 954 GoogleServiceAuthError last_get_token_error_; |
| 961 base::Time next_token_request_time_; | 955 base::Time next_token_request_time_; |
| 962 | 956 |
| 963 // The gaia cookie manager. Used for monitoring cookie jar changes to detect | 957 // The gaia cookie manager. Used for monitoring cookie jar changes to detect |
| 964 // when the user signs out of the content area. | 958 // when the user signs out of the content area. |
| 965 GaiaCookieManagerService* const gaia_cookie_manager_service_; | 959 GaiaCookieManagerService* const gaia_cookie_manager_service_; |
| 966 | 960 |
| 967 std::unique_ptr<sync_driver::LocalDeviceInfoProvider> local_device_; | 961 std::unique_ptr<syncer::LocalDeviceInfoProvider> local_device_; |
| 968 | 962 |
| 969 // Locally owned SyncableService and ModelTypeService implementations. | 963 // Locally owned SyncableService and ModelTypeService implementations. |
| 970 std::unique_ptr<sync_sessions::SessionsSyncManager> sessions_sync_manager_; | 964 std::unique_ptr<sync_sessions::SessionsSyncManager> sessions_sync_manager_; |
| 971 std::unique_ptr<sync_driver::DeviceInfoSyncService> device_info_sync_service_; | 965 std::unique_ptr<syncer::DeviceInfoSyncService> device_info_sync_service_; |
| 972 std::unique_ptr<sync_driver_v2::DeviceInfoService> device_info_service_; | 966 std::unique_ptr<syncer::DeviceInfoService> device_info_service_; |
| 973 | 967 |
| 974 std::unique_ptr<syncer::NetworkResources> network_resources_; | 968 std::unique_ptr<syncer::NetworkResources> network_resources_; |
| 975 | 969 |
| 976 StartBehavior start_behavior_; | 970 StartBehavior start_behavior_; |
| 977 std::unique_ptr<StartupController> startup_controller_; | 971 std::unique_ptr<syncer::StartupController> startup_controller_; |
| 978 | 972 |
| 979 // The full path to the sync data directory. | 973 // The full path to the sync data directory. |
| 980 base::FilePath directory_path_; | 974 base::FilePath directory_path_; |
| 981 | 975 |
| 982 std::unique_ptr<SyncStoppedReporter> sync_stopped_reporter_; | 976 std::unique_ptr<syncer::SyncStoppedReporter> sync_stopped_reporter_; |
| 983 | 977 |
| 984 // Listens for the system being under memory pressure. | 978 // Listens for the system being under memory pressure. |
| 985 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 979 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
| 986 | 980 |
| 987 // Nigori state after user switching to custom passphrase, saved until | 981 // Nigori state after user switching to custom passphrase, saved until |
| 988 // transition steps complete. It will be injected into new backend after sync | 982 // transition steps complete. It will be injected into new backend after sync |
| 989 // restart. | 983 // restart. |
| 990 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 984 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 991 saved_nigori_state_; | 985 saved_nigori_state_; |
| 992 | 986 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1016 base::WeakPtrFactory<ProfileSyncService> weak_factory_; | 1010 base::WeakPtrFactory<ProfileSyncService> weak_factory_; |
| 1017 | 1011 |
| 1018 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1012 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 1019 }; | 1013 }; |
| 1020 | 1014 |
| 1021 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); | 1015 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); |
| 1022 | 1016 |
| 1023 } // namespace browser_sync | 1017 } // namespace browser_sync |
| 1024 | 1018 |
| 1025 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1019 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |