Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: chrome/browser/sync/profile_sync_service.h

Issue 74653002: sync: Add --enable-sync-sessions-v2 and necessary plumbing to use SessionsSyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup components factory Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/sync/glue/data_type_controller.h" 24 #include "chrome/browser/sync/glue/data_type_controller.h"
25 #include "chrome/browser/sync/glue/data_type_encryption_handler.h" 25 #include "chrome/browser/sync/glue/data_type_encryption_handler.h"
26 #include "chrome/browser/sync/glue/data_type_manager.h" 26 #include "chrome/browser/sync/glue/data_type_manager.h"
27 #include "chrome/browser/sync/glue/data_type_manager_observer.h" 27 #include "chrome/browser/sync/glue/data_type_manager_observer.h"
28 #include "chrome/browser/sync/glue/failed_data_types_handler.h" 28 #include "chrome/browser/sync/glue/failed_data_types_handler.h"
29 #include "chrome/browser/sync/glue/sync_backend_host.h" 29 #include "chrome/browser/sync/glue/sync_backend_host.h"
30 #include "chrome/browser/sync/glue/sync_frontend.h" 30 #include "chrome/browser/sync/glue/sync_frontend.h"
31 #include "chrome/browser/sync/glue/synced_device_tracker.h" 31 #include "chrome/browser/sync/glue/synced_device_tracker.h"
32 #include "chrome/browser/sync/profile_sync_service_base.h" 32 #include "chrome/browser/sync/profile_sync_service_base.h"
33 #include "chrome/browser/sync/profile_sync_service_observer.h" 33 #include "chrome/browser/sync/profile_sync_service_observer.h"
34 #include "chrome/browser/sync/sessions2/sessions_sync_manager.h"
34 #include "chrome/browser/sync/sync_prefs.h" 35 #include "chrome/browser/sync/sync_prefs.h"
35 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 36 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
36 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
37 #include "content/public/browser/notification_registrar.h" 38 #include "content/public/browser/notification_registrar.h"
38 #include "content/public/browser/notification_types.h" 39 #include "content/public/browser/notification_types.h"
39 #include "google_apis/gaia/google_service_auth_error.h" 40 #include "google_apis/gaia/google_service_auth_error.h"
40 #include "google_apis/gaia/oauth2_token_service.h" 41 #include "google_apis/gaia/oauth2_token_service.h"
41 #include "net/base/backoff_entry.h" 42 #include "net/base/backoff_entry.h"
42 #include "sync/internal_api/public/base/model_type.h" 43 #include "sync/internal_api/public/base/model_type.h"
43 #include "sync/internal_api/public/engine/model_safe_worker.h" 44 #include "sync/internal_api/public/engine/model_safe_worker.h"
44 #include "sync/internal_api/public/sync_manager_factory.h" 45 #include "sync/internal_api/public/sync_manager_factory.h"
45 #include "sync/internal_api/public/util/experiments.h" 46 #include "sync/internal_api/public/util/experiments.h"
46 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 47 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
47 #include "sync/js/sync_js_controller.h" 48 #include "sync/js/sync_js_controller.h"
48 #include "url/gurl.h" 49 #include "url/gurl.h"
49 50
50 class Profile; 51 class Profile;
51 class ProfileOAuth2TokenService; 52 class ProfileOAuth2TokenService;
52 class ProfileSyncComponentsFactory; 53 class ProfileSyncComponentsFactory;
53 class SigninManagerBase; 54 class SigninManagerBase;
54 class SyncGlobalError; 55 class SyncGlobalError;
55 56
56 namespace browser_sync { 57 namespace browser_sync {
57 class BackendMigrator; 58 class BackendMigrator;
58 class ChangeProcessor; 59 class ChangeProcessor;
59 class DataTypeManager; 60 class DataTypeManager;
60 class DeviceInfo; 61 class DeviceInfo;
62 class FaviconCache;
61 class JsController; 63 class JsController;
64 class OpenTabsUIDelegate;
62 class SessionModelAssociator; 65 class SessionModelAssociator;
63 66
64 namespace sessions { 67 namespace sessions {
65 class SyncSessionSnapshot; 68 class SyncSessionSnapshot;
66 } // namespace sessions 69 } // namespace sessions
67 } // namespace browser_sync 70 } // namespace browser_sync
68 71
69 namespace syncer { 72 namespace syncer {
70 class BaseTransaction; 73 class BaseTransaction;
71 struct SyncCredentials; 74 struct SyncCredentials;
72 struct UserShare; 75 struct UserShare;
73 } // namespace syncer 76 } // namespace syncer
74 77
75 namespace sync_pb { 78 namespace sync_pb {
76 class EncryptedData; 79 class EncryptedData;
77 } // namespace sync_pb 80 } // namespace sync_pb
78 81
82 using browser_sync::SessionsSyncManager;
83
79 // ProfileSyncService is the layer between browser subsystems like bookmarks, 84 // ProfileSyncService is the layer between browser subsystems like bookmarks,
80 // and the sync backend. Each subsystem is logically thought of as being 85 // and the sync backend. Each subsystem is logically thought of as being
81 // a sync datatype. 86 // a sync datatype.
82 // 87 //
83 // Individual datatypes can, at any point, be in a variety of stages of being 88 // Individual datatypes can, at any point, be in a variety of stages of being
84 // "enabled". Here are some specific terms for concepts used in this class: 89 // "enabled". Here are some specific terms for concepts used in this class:
85 // 90 //
86 // 'Registered' (feature suppression for a datatype) 91 // 'Registered' (feature suppression for a datatype)
87 // 92 //
88 // When a datatype is registered, the user has the option of syncing it. 93 // When a datatype is registered, the user has the option of syncing it.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // called while the user is actively configuring their account, and then 157 // called while the user is actively configuring their account, and then
153 // SetSetupInProgress(false) should be called when configuration is complete. 158 // SetSetupInProgress(false) should be called when configuration is complete.
154 // When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has 159 // When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has
155 // been called, then the sync engine knows not to download any user data. 160 // been called, then the sync engine knows not to download any user data.
156 // 161 //
157 // When initial sync is complete, the UI code should call 162 // When initial sync is complete, the UI code should call
158 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will 163 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will
159 // tell the sync engine that setup is completed and it can begin downloading 164 // tell the sync engine that setup is completed and it can begin downloading
160 // data from the sync server. 165 // data from the sync server.
161 // 166 //
162 class ProfileSyncService : public ProfileSyncServiceBase, 167 class ProfileSyncService
163 public browser_sync::SyncFrontend, 168 : public ProfileSyncServiceBase,
164 public browser_sync::SyncPrefObserver, 169 public browser_sync::SyncFrontend,
165 public browser_sync::DataTypeManagerObserver, 170 public browser_sync::SyncPrefObserver,
166 public syncer::UnrecoverableErrorHandler, 171 public browser_sync::DataTypeManagerObserver,
167 public content::NotificationObserver, 172 public syncer::UnrecoverableErrorHandler,
168 public BrowserContextKeyedService, 173 public content::NotificationObserver,
169 public browser_sync::DataTypeEncryptionHandler, 174 public BrowserContextKeyedService,
170 public OAuth2TokenService::Consumer, 175 public browser_sync::DataTypeEncryptionHandler,
171 public OAuth2TokenService::Observer { 176 public OAuth2TokenService::Consumer,
177 public OAuth2TokenService::Observer,
178 public SessionsSyncManager::SyncInternalApiDelegate {
172 public: 179 public:
173 typedef browser_sync::SyncBackendHost::Status Status; 180 typedef browser_sync::SyncBackendHost::Status Status;
174 181
175 // Status of sync server connection, sync token and token request. 182 // Status of sync server connection, sync token and token request.
176 struct SyncTokenStatus { 183 struct SyncTokenStatus {
177 SyncTokenStatus(); 184 SyncTokenStatus();
178 ~SyncTokenStatus(); 185 ~SyncTokenStatus();
179 186
180 // Sync server connection status reported by sync backend. 187 // Sync server connection status reported by sync backend.
181 base::Time connection_status_update_time; 188 base::Time connection_status_update_time;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Registers a data type controller with the sync service. This 299 // Registers a data type controller with the sync service. This
293 // makes the data type controller available for use, it does not 300 // makes the data type controller available for use, it does not
294 // enable or activate the synchronization of the data type (see 301 // enable or activate the synchronization of the data type (see
295 // ActivateDataType). Takes ownership of the pointer. 302 // ActivateDataType). Takes ownership of the pointer.
296 void RegisterDataTypeController( 303 void RegisterDataTypeController(
297 browser_sync::DataTypeController* data_type_controller); 304 browser_sync::DataTypeController* data_type_controller);
298 305
299 // Returns the session model associator associated with this type, but only if 306 // Returns the session model associator associated with this type, but only if
300 // the associator is running. If it is doing anything else, it will return 307 // the associator is running. If it is doing anything else, it will return
301 // null. 308 // null.
302 // TODO(zea): Figure out a better way to expose this to the UI elements that 309 //
303 // need it. 310 // ### DONT USE THIS ANYMORE! ***
rlarocque 2013/11/18 23:20:08 That's a pretty strong comment. nit: Could you be
tim (not reviewing) 2013/11/20 18:38:57 Yeah, I want to be a bit scary :) I'll be removin
304 virtual browser_sync::SessionModelAssociator* GetSessionModelAssociator(); 311 // If you think you want to use this, think again! Can you use
312 // GetOpenTabsUIDelegate instead?
313 // TODO(tim): Remove this method.
314 virtual browser_sync::SessionModelAssociator*
315 GetSessionModelAssociatorDeprecated();
305 316
317 // Return the active OpenTabsUIDelegate. If sessions is not enabled or not
318 // currently syncing, returns NULL.
319 virtual browser_sync::OpenTabsUIDelegate* GetOpenTabsUIDelegate();
320
321 // Returns the SyncableService for syncer::SESSIONS.
322 virtual syncer::SyncableService* GetSessionsSyncableService();
323
324 // SyncInternalApiDelegate implementation.
325 //
306 // Returns sync's representation of the local device info. 326 // Returns sync's representation of the local device info.
307 // Return value is an empty scoped_ptr if the device info is unavailable. 327 // Return value is an empty scoped_ptr if the device info is unavailable.
308 virtual scoped_ptr<browser_sync::DeviceInfo> GetLocalDeviceInfo() const; 328 virtual scoped_ptr<browser_sync::DeviceInfo> GetLocalDeviceInfo()
329 const OVERRIDE;
330
331 // Gets the guid for the local device. Can be used by other layers to
332 // to distinguish sync data that belongs to the local device vs data
333 // that belongs to remote devices. Returns empty string if sync is not
334 // initialized.
335 virtual std::string GetLocalDeviceGUID() const OVERRIDE;
rlarocque 2013/11/18 23:20:08 Is this the sync cache GUID? If so, could you ren
tim (not reviewing) 2013/11/20 18:38:57 Good point. I actually had it called CacheGuid (s
309 336
310 // Returns sync's representation of the device info for a client identified 337 // Returns sync's representation of the device info for a client identified
311 // by |client_id|. Return value is an empty scoped ptr if the device info 338 // by |client_id|. Return value is an empty scoped ptr if the device info
312 // is unavailable. 339 // is unavailable.
313 virtual scoped_ptr<browser_sync::DeviceInfo> GetDeviceInfo( 340 virtual scoped_ptr<browser_sync::DeviceInfo> GetDeviceInfo(
314 const std::string& client_id) const; 341 const std::string& client_id) const;
315 342
316 // Gets the device info for all devices signed into the account associated 343 // Gets the device info for all devices signed into the account associated
317 // with this profile. 344 // with this profile.
318 virtual ScopedVector<browser_sync::DeviceInfo> GetAllSignedInDevices() const; 345 virtual ScopedVector<browser_sync::DeviceInfo> GetAllSignedInDevices() const;
319 346
320 // Gets the partnership guid for the local device. Can be used by other
321 // layers to distinguish sync data that belongs to the local device vs
322 // data that belong to remote devices. Returns null if sync is not
323 // initialized.
324 virtual std::string GetLocalDeviceGUID() const;
325
326 // Notifies the observer of any device info changes. 347 // Notifies the observer of any device info changes.
327 virtual void AddObserverForDeviceInfoChange( 348 virtual void AddObserverForDeviceInfoChange(
328 browser_sync::SyncedDeviceTracker::Observer* observer); 349 browser_sync::SyncedDeviceTracker::Observer* observer);
329 350
330 // Removes the observer from device info notification. 351 // Removes the observer from device info notification.
331 virtual void RemoveObserverForDeviceInfoChange( 352 virtual void RemoveObserverForDeviceInfoChange(
332 browser_sync::SyncedDeviceTracker::Observer* observer); 353 browser_sync::SyncedDeviceTracker::Observer* observer);
333 354
334 // Fills state_map with a map of current data types that are possible to 355 // Fills state_map with a map of current data types that are possible to
335 // sync, as well as their states. 356 // sync, as well as their states.
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 689
669 // Called when a datatype (SyncableService) has a need for sync to start 690 // Called when a datatype (SyncableService) has a need for sync to start
670 // ASAP, presumably because a local change event has occurred but we're 691 // ASAP, presumably because a local change event has occurred but we're
671 // still in deferred start mode, meaning the SyncableService hasn't been 692 // still in deferred start mode, meaning the SyncableService hasn't been
672 // told to MergeDataAndStartSyncing yet. 693 // told to MergeDataAndStartSyncing yet.
673 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); 694 void OnDataTypeRequestsSyncStartup(syncer::ModelType type);
674 695
675 // Return sync token status. 696 // Return sync token status.
676 SyncTokenStatus GetSyncTokenStatus() const; 697 SyncTokenStatus GetSyncTokenStatus() const;
677 698
699 browser_sync::FaviconCache* GetFaviconCache();
700
678 protected: 701 protected:
679 // Used by test classes that derive from ProfileSyncService. 702 // Used by test classes that derive from ProfileSyncService.
680 virtual browser_sync::SyncBackendHost* GetBackendForTest(); 703 virtual browser_sync::SyncBackendHost* GetBackendForTest();
681 704
682 // Helper to configure the priority data types. 705 // Helper to configure the priority data types.
683 void ConfigurePriorityDataTypes(); 706 void ConfigurePriorityDataTypes();
684 707
685 // Helper to install and configure a data type manager. 708 // Helper to install and configure a data type manager.
686 void ConfigureDataTypeManager(); 709 void ConfigureDataTypeManager();
687 710
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 base::WeakPtrFactory<ProfileSyncService> weak_factory_; 1030 base::WeakPtrFactory<ProfileSyncService> weak_factory_;
1008 1031
1009 // States related to sync token and connection. 1032 // States related to sync token and connection.
1010 base::Time connection_status_update_time_; 1033 base::Time connection_status_update_time_;
1011 syncer::ConnectionStatus connection_status_; 1034 syncer::ConnectionStatus connection_status_;
1012 base::Time token_request_time_; 1035 base::Time token_request_time_;
1013 base::Time token_receive_time_; 1036 base::Time token_receive_time_;
1014 GoogleServiceAuthError last_get_token_error_; 1037 GoogleServiceAuthError last_get_token_error_;
1015 base::Time next_token_request_time_; 1038 base::Time next_token_request_time_;
1016 1039
1040 scoped_ptr<SessionsSyncManager> sessions_sync_manager_;
1041
1017 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); 1042 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
1018 }; 1043 };
1019 1044
1020 bool ShouldShowActionOnUI( 1045 bool ShouldShowActionOnUI(
1021 const syncer::SyncProtocolError& error); 1046 const syncer::SyncProtocolError& error);
1022 1047
1023 1048
1024 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 1049 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698