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 CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "base/string16.h" | 20 #include "base/string16.h" |
| 21 #include "base/time.h" | 21 #include "base/time.h" |
| 22 #include "base/timer.h" | 22 #include "base/timer.h" |
| 23 #include "chrome/browser/profiles/profile_keyed_service.h" | 23 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 24 #include "chrome/browser/signin/oauth2_token_service.h" | |
| 24 #include "chrome/browser/signin/signin_global_error.h" | 25 #include "chrome/browser/signin/signin_global_error.h" |
| 25 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" | 26 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" |
| 26 #include "chrome/browser/sync/failed_datatypes_handler.h" | 27 #include "chrome/browser/sync/failed_datatypes_handler.h" |
| 27 #include "chrome/browser/sync/glue/data_type_controller.h" | 28 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 28 #include "chrome/browser/sync/glue/data_type_manager.h" | 29 #include "chrome/browser/sync/glue/data_type_manager.h" |
| 29 #include "chrome/browser/sync/glue/data_type_manager_observer.h" | 30 #include "chrome/browser/sync/glue/data_type_manager_observer.h" |
| 30 #include "chrome/browser/sync/glue/sync_backend_host.h" | 31 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 31 #include "chrome/browser/sync/invalidation_frontend.h" | 32 #include "chrome/browser/sync/invalidation_frontend.h" |
| 32 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 33 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 33 #include "chrome/browser/sync/profile_sync_service_base.h" | 34 #include "chrome/browser/sync/profile_sync_service_base.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 // data from the sync server. | 156 // data from the sync server. |
| 156 // | 157 // |
| 157 class ProfileSyncService : public ProfileSyncServiceBase, | 158 class ProfileSyncService : public ProfileSyncServiceBase, |
| 158 public browser_sync::SyncFrontend, | 159 public browser_sync::SyncFrontend, |
| 159 public browser_sync::SyncPrefObserver, | 160 public browser_sync::SyncPrefObserver, |
| 160 public browser_sync::DataTypeManagerObserver, | 161 public browser_sync::DataTypeManagerObserver, |
| 161 public SigninGlobalError::AuthStatusProvider, | 162 public SigninGlobalError::AuthStatusProvider, |
| 162 public syncer::UnrecoverableErrorHandler, | 163 public syncer::UnrecoverableErrorHandler, |
| 163 public content::NotificationObserver, | 164 public content::NotificationObserver, |
| 164 public ProfileKeyedService, | 165 public ProfileKeyedService, |
| 165 public InvalidationFrontend { | 166 public InvalidationFrontend, |
| 167 public OAuth2TokenService::Consumer { | |
| 166 public: | 168 public: |
| 167 typedef browser_sync::SyncBackendHost::Status Status; | 169 typedef browser_sync::SyncBackendHost::Status Status; |
| 168 | 170 |
| 169 enum SyncEventCodes { | 171 enum SyncEventCodes { |
| 170 MIN_SYNC_EVENT_CODE = 0, | 172 MIN_SYNC_EVENT_CODE = 0, |
| 171 | 173 |
| 172 // Events starting the sync service. | 174 // Events starting the sync service. |
| 173 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 175 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 174 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 176 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| 175 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. | 177 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 syncer::InvalidationHandler* handler, | 611 syncer::InvalidationHandler* handler, |
| 610 const syncer::ObjectIdSet& ids) OVERRIDE; | 612 const syncer::ObjectIdSet& ids) OVERRIDE; |
| 611 virtual void UnregisterInvalidationHandler( | 613 virtual void UnregisterInvalidationHandler( |
| 612 syncer::InvalidationHandler* handler) OVERRIDE; | 614 syncer::InvalidationHandler* handler) OVERRIDE; |
| 613 virtual void AcknowledgeInvalidation( | 615 virtual void AcknowledgeInvalidation( |
| 614 const invalidation::ObjectId& id, | 616 const invalidation::ObjectId& id, |
| 615 const syncer::AckHandle& ack_handle) OVERRIDE; | 617 const syncer::AckHandle& ack_handle) OVERRIDE; |
| 616 | 618 |
| 617 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; | 619 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
| 618 | 620 |
| 621 // OAuth2TokenService::Consumer implementation | |
| 622 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
| 623 const std::string& access_token, | |
| 624 const base::Time& expiration_time) OVERRIDE; | |
| 625 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
| 626 const GoogleServiceAuthError& error) OVERRIDE; | |
| 627 | |
| 619 // ProfileKeyedService implementation. This must be called exactly | 628 // ProfileKeyedService implementation. This must be called exactly |
| 620 // once (before this object is destroyed). | 629 // once (before this object is destroyed). |
| 621 virtual void Shutdown() OVERRIDE; | 630 virtual void Shutdown() OVERRIDE; |
| 622 | 631 |
| 623 // Simulate an incoming notification for the given id and payload. | 632 // Simulate an incoming notification for the given id and payload. |
| 624 void EmitInvalidationForTest( | 633 void EmitInvalidationForTest( |
| 625 const invalidation::ObjectId& id, | 634 const invalidation::ObjectId& id, |
| 626 const std::string& payload); | 635 const std::string& payload); |
| 627 | 636 |
| 628 protected: | 637 protected: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 // because OnPassphraseAccepted() was called, or because we've gotten a | 722 // because OnPassphraseAccepted() was called, or because we've gotten a |
| 714 // OnPassphraseRequired() but no data types are enabled). | 723 // OnPassphraseRequired() but no data types are enabled). |
| 715 void ResolvePassphraseRequired(); | 724 void ResolvePassphraseRequired(); |
| 716 | 725 |
| 717 // During initial signin, ProfileSyncService caches the user's signin | 726 // During initial signin, ProfileSyncService caches the user's signin |
| 718 // passphrase so it can be used to encrypt/decrypt data after sync starts up. | 727 // passphrase so it can be used to encrypt/decrypt data after sync starts up. |
| 719 // This routine is invoked once the backend has started up to use the | 728 // This routine is invoked once the backend has started up to use the |
| 720 // cached passphrase and clear it out when it is done. | 729 // cached passphrase and clear it out when it is done. |
| 721 void ConsumeCachedPassphraseIfPossible(); | 730 void ConsumeCachedPassphraseIfPossible(); |
| 722 | 731 |
| 732 // RequestAccessToken initiates RPC to request downscoped access token from | |
| 733 // refresh token. This happens when TokenService loads OAuth2 login token and | |
| 734 // when sync server returns AUTH_ERROR which indicates it is time to refresh | |
| 735 // token. | |
| 736 virtual void RequestAccessToken( | |
| 737 bool invalidate_previous_token, | |
|
tim (not reviewing)
2013/05/23 19:03:42
style-nit: Functions with bool parameters (especi
| |
| 738 bool invoke_callback); | |
| 739 | |
| 723 // If |delete_sync_data_folder| is true, then this method will delete all | 740 // If |delete_sync_data_folder| is true, then this method will delete all |
| 724 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). | 741 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). |
| 725 void InitializeBackend(bool delete_sync_data_folder); | 742 void InitializeBackend(bool delete_sync_data_folder); |
| 726 | 743 |
| 727 // Initializes the various settings from the command line. | 744 // Initializes the various settings from the command line. |
| 728 void InitSettings(); | 745 void InitSettings(); |
| 729 | 746 |
| 730 // Sets the last synced time to the current time. | 747 // Sets the last synced time to the current time. |
| 731 void UpdateLastSyncedTime(); | 748 void UpdateLastSyncedTime(); |
| 732 | 749 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 // Dispatches invalidations to handlers. Set in Initialize() and | 946 // Dispatches invalidations to handlers. Set in Initialize() and |
| 930 // unset in Shutdown(). | 947 // unset in Shutdown(). |
| 931 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; | 948 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; |
| 932 // Queues any acknowledgements received while the backend is uninitialized. | 949 // Queues any acknowledgements received while the backend is uninitialized. |
| 933 AckHandleReplayQueue ack_replay_queue_; | 950 AckHandleReplayQueue ack_replay_queue_; |
| 934 | 951 |
| 935 // Sync's internal debug info listener. Used to record datatype configuration | 952 // Sync's internal debug info listener. Used to record datatype configuration |
| 936 // and association information. | 953 // and association information. |
| 937 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 954 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
| 938 | 955 |
| 956 // ProfileSyncService needs to remember access token in order to invalidate it | |
| 957 // with OAuth2TokenService. | |
| 958 std::string access_token_; | |
| 959 | |
| 960 // ProfileSyncService needs to hold reference to access_token_request_ for | |
| 961 // the duration of request in order to receive callbacks. | |
| 962 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | |
| 963 | |
| 939 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 964 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 940 }; | 965 }; |
| 941 | 966 |
| 942 bool ShouldShowActionOnUI( | 967 bool ShouldShowActionOnUI( |
| 943 const syncer::SyncProtocolError& error); | 968 const syncer::SyncProtocolError& error); |
| 944 | 969 |
| 945 | 970 |
| 946 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 971 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |