| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 6 #define CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 class SessionHeader; | 36 class SessionHeader; |
| 37 class SessionSpecifics; | 37 class SessionSpecifics; |
| 38 class SessionTab; | 38 class SessionTab; |
| 39 class SessionWindow; | 39 class SessionWindow; |
| 40 class TabNavigation; | 40 class TabNavigation; |
| 41 } // namespace sync_pb | 41 } // namespace sync_pb |
| 42 | 42 |
| 43 namespace browser_sync { | 43 namespace browser_sync { |
| 44 | 44 |
| 45 class DataTypeErrorHandler; | 45 class DataTypeErrorHandler; |
| 46 class LocalDeviceInfoProvider; |
| 46 class SyncedTabDelegate; | 47 class SyncedTabDelegate; |
| 47 class SyncedWindowDelegate; | 48 class SyncedWindowDelegate; |
| 48 class SyncedWindowDelegatesGetter; | 49 class SyncedWindowDelegatesGetter; |
| 49 | 50 |
| 50 // An interface defining the ways in which local open tab events can interact | 51 // An interface defining the ways in which local open tab events can interact |
| 51 // with session sync. All local tab events flow to sync via this interface. | 52 // with session sync. All local tab events flow to sync via this interface. |
| 52 // In that way it is analogous to sync changes flowing to the local model | 53 // In that way it is analogous to sync changes flowing to the local model |
| 53 // via ProcessSyncChanges, just with a more granular breakdown. | 54 // via ProcessSyncChanges, just with a more granular breakdown. |
| 54 class LocalSessionEventHandler { | 55 class LocalSessionEventHandler { |
| 55 public: | 56 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0; | 76 virtual void StartRoutingTo(LocalSessionEventHandler* handler) = 0; |
| 76 virtual void Stop() = 0; | 77 virtual void Stop() = 0; |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 // Contains all logic for associating the Chrome sessions model and | 80 // Contains all logic for associating the Chrome sessions model and |
| 80 // the sync sessions model. | 81 // the sync sessions model. |
| 81 class SessionsSyncManager : public syncer::SyncableService, | 82 class SessionsSyncManager : public syncer::SyncableService, |
| 82 public OpenTabsUIDelegate, | 83 public OpenTabsUIDelegate, |
| 83 public LocalSessionEventHandler { | 84 public LocalSessionEventHandler { |
| 84 public: | 85 public: |
| 85 // Isolates SessionsSyncManager from having to depend on sync internals. | |
| 86 class SyncInternalApiDelegate { | |
| 87 public: | |
| 88 virtual ~SyncInternalApiDelegate() {} | |
| 89 | |
| 90 // Returns sync's representation of the local device info. | |
| 91 // Return value is an empty scoped_ptr if the device info is unavailable. | |
| 92 virtual scoped_ptr<DeviceInfo> GetLocalDeviceInfo() const = 0; | |
| 93 | |
| 94 // Used for creation of the machine tag for this local session. | |
| 95 virtual std::string GetLocalSyncCacheGUID() const = 0; | |
| 96 }; | |
| 97 | |
| 98 SessionsSyncManager(Profile* profile, | 86 SessionsSyncManager(Profile* profile, |
| 99 SyncInternalApiDelegate* delegate, | 87 LocalDeviceInfoProvider* local_device, |
| 100 scoped_ptr<LocalSessionEventRouter> router); | 88 scoped_ptr<LocalSessionEventRouter> router); |
| 101 virtual ~SessionsSyncManager(); | 89 virtual ~SessionsSyncManager(); |
| 102 | 90 |
| 103 // syncer::SyncableService implementation. | 91 // syncer::SyncableService implementation. |
| 104 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 92 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 105 syncer::ModelType type, | 93 syncer::ModelType type, |
| 106 const syncer::SyncDataList& initial_sync_data, | 94 const syncer::SyncDataList& initial_sync_data, |
| 107 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 95 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 108 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; | 96 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; |
| 109 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 97 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 129 } |
| 142 | 130 |
| 143 // Return the virtual URL of the current tab, even if it's pending. | 131 // Return the virtual URL of the current tab, even if it's pending. |
| 144 static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate); | 132 static GURL GetCurrentVirtualURL(const SyncedTabDelegate& tab_delegate); |
| 145 | 133 |
| 146 // Return the favicon url of the current tab, even if it's pending. | 134 // Return the favicon url of the current tab, even if it's pending. |
| 147 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); | 135 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); |
| 148 | 136 |
| 149 FaviconCache* GetFaviconCache(); | 137 FaviconCache* GetFaviconCache(); |
| 150 | 138 |
| 139 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() const; |
| 140 |
| 151 // Triggers garbage collection of stale sessions (as defined by | 141 // Triggers garbage collection of stale sessions (as defined by |
| 152 // |stale_session_threshold_days_|). This is called automatically every | 142 // |stale_session_threshold_days_|). This is called automatically every |
| 153 // time we start up (via AssociateModels) and when new sessions data is | 143 // time we start up (via AssociateModels) and when new sessions data is |
| 154 // downloaded (sync cycles complete). | 144 // downloaded (sync cycles complete). |
| 155 void DoGarbageCollection(); | 145 void DoGarbageCollection(); |
| 156 | 146 |
| 157 private: | 147 private: |
| 158 // Keep all the links to local tab data in one place. A tab_node_id and tab | 148 // Keep all the links to local tab data in one place. A tab_node_id and tab |
| 159 // must be passed at creation. The tab_node_id is not mutable, although | 149 // must be passed at creation. The tab_node_id is not mutable, although |
| 160 // all other fields are. | 150 // all other fields are. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // proves that we are still relevant. | 337 // proves that we are still relevant. |
| 348 bool local_tab_pool_out_of_sync_; | 338 bool local_tab_pool_out_of_sync_; |
| 349 | 339 |
| 350 sync_driver::SyncPrefs sync_prefs_; | 340 sync_driver::SyncPrefs sync_prefs_; |
| 351 | 341 |
| 352 const Profile* const profile_; | 342 const Profile* const profile_; |
| 353 | 343 |
| 354 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 344 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
| 355 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 345 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| 356 | 346 |
| 357 const SyncInternalApiDelegate* const delegate_; | 347 // Local device info provider, owned by ProfileSyncService. |
| 348 const LocalDeviceInfoProvider* const local_device_; |
| 358 | 349 |
| 359 // Unique client tag. | 350 // Unique client tag. |
| 360 std::string current_machine_tag_; | 351 std::string current_machine_tag_; |
| 361 | 352 |
| 362 // User-visible machine name. | 353 // User-visible machine name. |
| 363 std::string current_session_name_; | 354 std::string current_session_name_; |
| 364 | 355 |
| 365 // SyncID for the sync node containing all the window information for this | 356 // SyncID for the sync node containing all the window information for this |
| 366 // client. | 357 // client. |
| 367 int local_session_header_node_id_; | 358 int local_session_header_node_id_; |
| 368 | 359 |
| 369 // Number of days without activity after which we consider a session to be | 360 // Number of days without activity after which we consider a session to be |
| 370 // stale and a candidate for garbage collection. | 361 // stale and a candidate for garbage collection. |
| 371 size_t stale_session_threshold_days_; | 362 size_t stale_session_threshold_days_; |
| 372 | 363 |
| 373 scoped_ptr<LocalSessionEventRouter> local_event_router_; | 364 scoped_ptr<LocalSessionEventRouter> local_event_router_; |
| 374 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; | 365 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; |
| 375 | 366 |
| 376 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 367 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
| 377 }; | 368 }; |
| 378 | 369 |
| 379 } // namespace browser_sync | 370 } // namespace browser_sync |
| 380 | 371 |
| 381 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 372 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| OLD | NEW |