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 19 matching lines...) Expand all Loading... | |
| 30 #include "components/signin/core/browser/signin_manager_base.h" | 30 #include "components/signin/core/browser/signin_manager_base.h" |
| 31 #include "components/sync/base/experiments.h" | 31 #include "components/sync/base/experiments.h" |
| 32 #include "components/sync/base/model_type.h" | 32 #include "components/sync/base/model_type.h" |
| 33 #include "components/sync/base/sync_prefs.h" | 33 #include "components/sync/base/sync_prefs.h" |
| 34 #include "components/sync/base/unrecoverable_error_handler.h" | 34 #include "components/sync/base/unrecoverable_error_handler.h" |
| 35 #include "components/sync/device_info/local_device_info_provider.h" | 35 #include "components/sync/device_info/local_device_info_provider.h" |
| 36 #include "components/sync/driver/data_type_controller.h" | 36 #include "components/sync/driver/data_type_controller.h" |
| 37 #include "components/sync/driver/data_type_manager.h" | 37 #include "components/sync/driver/data_type_manager.h" |
| 38 #include "components/sync/driver/data_type_manager_observer.h" | 38 #include "components/sync/driver/data_type_manager_observer.h" |
| 39 #include "components/sync/driver/data_type_status_table.h" | 39 #include "components/sync/driver/data_type_status_table.h" |
| 40 #include "components/sync/driver/glue/sync_backend_host.h" | |
| 41 #include "components/sync/driver/startup_controller.h" | 40 #include "components/sync/driver/startup_controller.h" |
| 42 #include "components/sync/driver/sync_client.h" | 41 #include "components/sync/driver/sync_client.h" |
| 43 #include "components/sync/driver/sync_frontend.h" | |
| 44 #include "components/sync/driver/sync_service.h" | 42 #include "components/sync/driver/sync_service.h" |
| 45 #include "components/sync/driver/sync_stopped_reporter.h" | 43 #include "components/sync/driver/sync_stopped_reporter.h" |
| 46 #include "components/sync/engine/events/protocol_event_observer.h" | 44 #include "components/sync/engine/events/protocol_event_observer.h" |
| 47 #include "components/sync/engine/model_safe_worker.h" | 45 #include "components/sync/engine/model_safe_worker.h" |
| 48 #include "components/sync/engine/net/network_time_update_callback.h" | 46 #include "components/sync/engine/net/network_time_update_callback.h" |
| 49 #include "components/sync/engine/shutdown_reason.h" | 47 #include "components/sync/engine/shutdown_reason.h" |
| 48 #include "components/sync/engine/sync_engine.h" | |
| 49 #include "components/sync/engine/sync_engine_host.h" | |
| 50 #include "components/sync/engine/sync_manager_factory.h" | 50 #include "components/sync/engine/sync_manager_factory.h" |
| 51 #include "components/sync/js/sync_js_controller.h" | 51 #include "components/sync/js/sync_js_controller.h" |
| 52 #include "components/sync/syncable/user_share.h" | 52 #include "components/sync/syncable/user_share.h" |
| 53 #include "components/version_info/version_info.h" | 53 #include "components/version_info/version_info.h" |
| 54 #include "google_apis/gaia/google_service_auth_error.h" | 54 #include "google_apis/gaia/google_service_auth_error.h" |
| 55 #include "google_apis/gaia/oauth2_token_service.h" | 55 #include "google_apis/gaia/oauth2_token_service.h" |
| 56 #include "net/base/backoff_entry.h" | 56 #include "net/base/backoff_entry.h" |
| 57 #include "url/gurl.h" | 57 #include "url/gurl.h" |
| 58 | 58 |
| 59 class Profile; | 59 class Profile; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 // | 165 // |
| 166 // SetFirstSetupComplete() should be called once the user has finished setting | 166 // SetFirstSetupComplete() should be called once the user has finished setting |
| 167 // up sync at least once on their account. GetSetupInProgressHandle() should | 167 // up sync at least once on their account. GetSetupInProgressHandle() should |
| 168 // be called while the user is actively configuring their account. The handle | 168 // be called while the user is actively configuring their account. The handle |
| 169 // should be deleted once configuration is complete. | 169 // should be deleted once configuration is complete. |
| 170 // | 170 // |
| 171 // Once first setup has completed and there are no outstanding | 171 // Once first setup has completed and there are no outstanding |
| 172 // setup-in-progress handles, CanConfigureDataTypes() will return true and | 172 // setup-in-progress handles, CanConfigureDataTypes() will return true and |
| 173 // datatype configuration can begin. | 173 // datatype configuration can begin. |
| 174 class ProfileSyncService : public syncer::SyncService, | 174 class ProfileSyncService : public syncer::SyncService, |
| 175 public syncer::SyncFrontend, | 175 public syncer::SyncEngineHost, |
| 176 public syncer::SyncPrefObserver, | 176 public syncer::SyncPrefObserver, |
| 177 public syncer::DataTypeManagerObserver, | 177 public syncer::DataTypeManagerObserver, |
| 178 public syncer::UnrecoverableErrorHandler, | 178 public syncer::UnrecoverableErrorHandler, |
| 179 public KeyedService, | 179 public KeyedService, |
| 180 public OAuth2TokenService::Consumer, | 180 public OAuth2TokenService::Consumer, |
| 181 public OAuth2TokenService::Observer, | 181 public OAuth2TokenService::Observer, |
| 182 public SigninManagerBase::Observer, | 182 public SigninManagerBase::Observer, |
| 183 public GaiaCookieManagerService::Observer { | 183 public GaiaCookieManagerService::Observer { |
| 184 public: | 184 public: |
| 185 typedef syncer::SyncBackendHost::Status Status; | 185 typedef syncer::SyncEngine::Status Status; |
| 186 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; | 186 typedef base::Callback<bool(void)> PlatformSyncAllowedProvider; |
| 187 | 187 |
| 188 enum SyncEventCodes { | 188 enum SyncEventCodes { |
| 189 MIN_SYNC_EVENT_CODE = 0, | 189 MIN_SYNC_EVENT_CODE = 0, |
| 190 | 190 |
| 191 // Events starting the sync service. | 191 // Events starting the sync service. |
| 192 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 192 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 193 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 193 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| 194 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. | 194 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
| 195 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. | 195 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 virtual syncer::DeviceInfoTracker* GetDeviceInfoTracker() const; | 351 virtual syncer::DeviceInfoTracker* GetDeviceInfoTracker() const; |
| 352 | 352 |
| 353 // Fills state_map with a map of current data types that are possible to | 353 // Fills state_map with a map of current data types that are possible to |
| 354 // sync, as well as their states. | 354 // sync, as well as their states. |
| 355 void GetDataTypeControllerStates( | 355 void GetDataTypeControllerStates( |
| 356 syncer::DataTypeController::StateMap* state_map) const; | 356 syncer::DataTypeController::StateMap* state_map) const; |
| 357 | 357 |
| 358 // Called when asynchronous session restore has completed. | 358 // Called when asynchronous session restore has completed. |
| 359 void OnSessionRestoreComplete(); | 359 void OnSessionRestoreComplete(); |
| 360 | 360 |
| 361 // SyncFrontend implementation. | 361 // SyncEngineHost implementation. |
| 362 void OnBackendInitialized( | 362 void OnBackendInitialized( |
| 363 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 363 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 364 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 364 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 365 debug_info_listener, | 365 debug_info_listener, |
| 366 const std::string& cache_guid, | 366 const std::string& cache_guid, |
| 367 bool success) override; | 367 bool success) override; |
| 368 void OnSyncCycleCompleted() override; | 368 void OnSyncCycleCompleted() override; |
| 369 void OnProtocolEvent(const syncer::ProtocolEvent& event) override; | 369 void OnProtocolEvent(const syncer::ProtocolEvent& event) override; |
| 370 void OnDirectoryTypeCommitCounterUpdated( | 370 void OnDirectoryTypeCommitCounterUpdated( |
| 371 syncer::ModelType type, | 371 syncer::ModelType type, |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 // Return SyncCredentials from the OAuth2TokenService. | 600 // Return SyncCredentials from the OAuth2TokenService. |
| 601 syncer::SyncCredentials GetCredentials(); | 601 syncer::SyncCredentials GetCredentials(); |
| 602 | 602 |
| 603 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); | 603 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); |
| 604 | 604 |
| 605 // Helper method for managing encryption UI. | 605 // Helper method for managing encryption UI. |
| 606 bool IsEncryptedDatatypeEnabled() const; | 606 bool IsEncryptedDatatypeEnabled() const; |
| 607 | 607 |
| 608 // Helper for OnUnrecoverableError. | 608 // Helper for OnUnrecoverableError. |
| 609 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, | 609 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, |
| 610 // and in SyncBackendHost::Shutdown. | 610 // and in SyncEngine::Shutdown. |
| 611 void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here, | 611 void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here, |
| 612 const std::string& message, | 612 const std::string& message, |
| 613 bool delete_sync_database); | 613 bool delete_sync_database); |
| 614 | 614 |
| 615 // This is a cache of the last authentication response we received from the | 615 // This is a cache of the last authentication response we received from the |
| 616 // sync server. The UI queries this to display appropriate messaging to the | 616 // sync server. The UI queries this to display appropriate messaging to the |
| 617 // user. | 617 // user. |
| 618 GoogleServiceAuthError last_auth_error_; | 618 GoogleServiceAuthError last_auth_error_; |
| 619 | 619 |
| 620 // Our asynchronous backend to communicate with sync components living on | 620 // Our asynchronous backend to communicate with sync components living on |
| 621 // other threads. | 621 // other threads. |
| 622 std::unique_ptr<syncer::SyncBackendHost> backend_; | 622 std::unique_ptr<syncer::SyncEngine> backend_; |
| 623 | 623 |
| 624 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it | 624 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it |
| 625 // was required for encryption, decryption with a cached passphrase, or | 625 // was required for encryption, decryption with a cached passphrase, or |
| 626 // because a new passphrase is required? | 626 // because a new passphrase is required? |
| 627 syncer::PassphraseRequiredReason passphrase_required_reason_; | 627 syncer::PassphraseRequiredReason passphrase_required_reason_; |
| 628 | 628 |
| 629 private: | 629 private: |
| 630 enum UnrecoverableErrorReason { | 630 enum UnrecoverableErrorReason { |
| 631 ERROR_REASON_UNSET, | 631 ERROR_REASON_UNSET, |
| 632 ERROR_REASON_SYNCER, | 632 ERROR_REASON_SYNCER, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 831 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). | 831 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). |
| 832 bool is_first_time_sync_configure_; | 832 bool is_first_time_sync_configure_; |
| 833 | 833 |
| 834 // Number of UIs currently configuring the Sync service. When this number | 834 // Number of UIs currently configuring the Sync service. When this number |
| 835 // is decremented back to zero, Sync setup is marked no longer in progress. | 835 // is decremented back to zero, Sync setup is marked no longer in progress. |
| 836 int outstanding_setup_in_progress_handles_ = 0; | 836 int outstanding_setup_in_progress_handles_ = 0; |
| 837 | 837 |
| 838 // List of available data type controllers. | 838 // List of available data type controllers. |
| 839 syncer::DataTypeController::TypeMap data_type_controllers_; | 839 syncer::DataTypeController::TypeMap data_type_controllers_; |
| 840 | 840 |
| 841 // Whether the SyncBackendHost has been initialized. | 841 // Whether the SyncEngine has been initialized. |
| 842 bool backend_initialized_; | 842 bool backend_initialized_; |
|
skym
2016/12/02 20:54:54
Should his be engine_initialized_? Also, does this
maxbogue
2016/12/02 23:59:27
As I said in the CL description, PSS naming update
skym
2016/12/03 00:03:47
Ah, that's fair. And when I asked what this means,
| |
| 843 | 843 |
| 844 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents | 844 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents |
| 845 // ProfileSyncService from starting backend till browser restarted or user | 845 // ProfileSyncService from starting backend till browser restarted or user |
| 846 // signed out. | 846 // signed out. |
| 847 bool sync_disabled_by_admin_; | 847 bool sync_disabled_by_admin_; |
| 848 | 848 |
| 849 // Set to true if a signin has completed but we're still waiting for the | 849 // Set to true if a signin has completed but we're still waiting for the |
| 850 // backend to refresh its credentials. | 850 // backend to refresh its credentials. |
| 851 bool is_auth_in_progress_; | 851 bool is_auth_in_progress_; |
| 852 | 852 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 base::WeakPtrFactory<ProfileSyncService> weak_factory_; | 1004 base::WeakPtrFactory<ProfileSyncService> weak_factory_; |
| 1005 | 1005 |
| 1006 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1006 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 1007 }; | 1007 }; |
| 1008 | 1008 |
| 1009 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); | 1009 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error); |
| 1010 | 1010 |
| 1011 } // namespace browser_sync | 1011 } // namespace browser_sync |
| 1012 | 1012 |
| 1013 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1013 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |