| 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 COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 5 #ifndef COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| 6 #define COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 6 #define COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class SessionSpecifics; | 45 class SessionSpecifics; |
| 46 class SessionTab; | 46 class SessionTab; |
| 47 class SessionWindow; | 47 class SessionWindow; |
| 48 class TabNavigation; | 48 class TabNavigation; |
| 49 } // namespace sync_pb | 49 } // namespace sync_pb |
| 50 | 50 |
| 51 namespace extensions { | 51 namespace extensions { |
| 52 class ExtensionSessionsTest; | 52 class ExtensionSessionsTest; |
| 53 } // namespace extensions | 53 } // namespace extensions |
| 54 | 54 |
| 55 namespace browser_sync { | 55 namespace sync_sessions { |
| 56 | 56 |
| 57 class SyncedTabDelegate; | 57 class SyncedTabDelegate; |
| 58 class SyncedWindowDelegatesGetter; | 58 class SyncedWindowDelegatesGetter; |
| 59 | 59 |
| 60 // Contains all logic for associating the Chrome sessions model and | 60 // Contains all logic for associating the Chrome sessions model and |
| 61 // the sync sessions model. | 61 // the sync sessions model. |
| 62 class SessionsSyncManager : public syncer::SyncableService, | 62 class SessionsSyncManager : public syncer::SyncableService, |
| 63 public sync_driver::OpenTabsUIDelegate, | 63 public OpenTabsUIDelegate, |
| 64 public LocalSessionEventHandler { | 64 public LocalSessionEventHandler { |
| 65 public: | 65 public: |
| 66 SessionsSyncManager(sync_sessions::SyncSessionsClient* sessions_client, | 66 SessionsSyncManager(SyncSessionsClient* sessions_client, |
| 67 sync_driver::SyncPrefs* sync_prefs, | 67 sync_driver::SyncPrefs* sync_prefs, |
| 68 sync_driver::LocalDeviceInfoProvider* local_device, | 68 sync_driver::LocalDeviceInfoProvider* local_device, |
| 69 std::unique_ptr<LocalSessionEventRouter> router, | 69 std::unique_ptr<LocalSessionEventRouter> router, |
| 70 const base::Closure& sessions_updated_callback, | 70 const base::Closure& sessions_updated_callback, |
| 71 const base::Closure& datatype_refresh_callback); | 71 const base::Closure& datatype_refresh_callback); |
| 72 ~SessionsSyncManager() override; | 72 ~SessionsSyncManager() override; |
| 73 | 73 |
| 74 // syncer::SyncableService implementation. | 74 // syncer::SyncableService implementation. |
| 75 syncer::SyncMergeResult MergeDataAndStartSyncing( | 75 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 76 syncer::ModelType type, | 76 syncer::ModelType type, |
| 77 const syncer::SyncDataList& initial_sync_data, | 77 const syncer::SyncDataList& initial_sync_data, |
| 78 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, | 78 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 79 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override; | 79 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 80 void StopSyncing(syncer::ModelType type) override; | 80 void StopSyncing(syncer::ModelType type) override; |
| 81 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; | 81 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 82 syncer::SyncError ProcessSyncChanges( | 82 syncer::SyncError ProcessSyncChanges( |
| 83 const tracked_objects::Location& from_here, | 83 const tracked_objects::Location& from_here, |
| 84 const syncer::SyncChangeList& change_list) override; | 84 const syncer::SyncChangeList& change_list) override; |
| 85 | 85 |
| 86 // OpenTabsUIDelegate implementation. | 86 // OpenTabsUIDelegate implementation. |
| 87 bool GetSyncedFaviconForPageURL( | 87 bool GetSyncedFaviconForPageURL( |
| 88 const std::string& pageurl, | 88 const std::string& pageurl, |
| 89 scoped_refptr<base::RefCountedMemory>* favicon_png) const override; | 89 scoped_refptr<base::RefCountedMemory>* favicon_png) const override; |
| 90 bool GetAllForeignSessions( | 90 bool GetAllForeignSessions( |
| 91 std::vector<const sync_driver::SyncedSession*>* sessions) override; | 91 std::vector<const SyncedSession*>* sessions) override; |
| 92 bool GetForeignSession( | 92 bool GetForeignSession( |
| 93 const std::string& tag, | 93 const std::string& tag, |
| 94 std::vector<const sessions::SessionWindow*>* windows) override; | 94 std::vector<const sessions::SessionWindow*>* windows) override; |
| 95 bool GetForeignTab(const std::string& tag, | 95 bool GetForeignTab(const std::string& tag, |
| 96 const SessionID::id_type tab_id, | 96 const SessionID::id_type tab_id, |
| 97 const sessions::SessionTab** tab) override; | 97 const sessions::SessionTab** tab) override; |
| 98 bool GetForeignSessionTabs( | 98 bool GetForeignSessionTabs( |
| 99 const std::string& tag, | 99 const std::string& tag, |
| 100 std::vector<const sessions::SessionTab*>* tabs) override; | 100 std::vector<const sessions::SessionTab*>* tabs) override; |
| 101 void DeleteForeignSession(const std::string& tag) override; | 101 void DeleteForeignSession(const std::string& tag) override; |
| 102 bool GetLocalSession( | 102 bool GetLocalSession(const SyncedSession** local_session) override; |
| 103 const sync_driver::SyncedSession** local_session) override; | |
| 104 | 103 |
| 105 // LocalSessionEventHandler implementation. | 104 // LocalSessionEventHandler implementation. |
| 106 void OnLocalTabModified(SyncedTabDelegate* modified_tab) override; | 105 void OnLocalTabModified(SyncedTabDelegate* modified_tab) override; |
| 107 void OnFaviconsChanged(const std::set<GURL>& page_urls, | 106 void OnFaviconsChanged(const std::set<GURL>& page_urls, |
| 108 const GURL& icon_url) override; | 107 const GURL& icon_url) override; |
| 109 | 108 |
| 110 // Returns the tag used to uniquely identify this machine's session in the | 109 // Returns the tag used to uniquely identify this machine's session in the |
| 111 // sync model. | 110 // sync model. |
| 112 const std::string& current_machine_tag() const { | 111 const std::string& current_machine_tag() const { |
| 113 DCHECK(!current_machine_tag_.empty()); | 112 DCHECK(!current_machine_tag_.empty()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // that exists in the caller's context. This function will append necessary | 223 // that exists in the caller's context. This function will append necessary |
| 225 // changes for processing later. | 224 // changes for processing later. |
| 226 void DeleteForeignSessionInternal(const std::string& tag, | 225 void DeleteForeignSessionInternal(const std::string& tag, |
| 227 syncer::SyncChangeList* change_output); | 226 syncer::SyncChangeList* change_output); |
| 228 | 227 |
| 229 // Used to populate a session header from the session specifics header | 228 // Used to populate a session header from the session specifics header |
| 230 // provided. | 229 // provided. |
| 231 static void PopulateSessionHeaderFromSpecifics( | 230 static void PopulateSessionHeaderFromSpecifics( |
| 232 const sync_pb::SessionHeader& header_specifics, | 231 const sync_pb::SessionHeader& header_specifics, |
| 233 base::Time mtime, | 232 base::Time mtime, |
| 234 sync_driver::SyncedSession* session_header); | 233 SyncedSession* session_header); |
| 235 | 234 |
| 236 // Builds |session_window| from the session specifics window | 235 // Builds |session_window| from the session specifics window |
| 237 // provided and updates the SessionTracker with foreign session data created. | 236 // provided and updates the SessionTracker with foreign session data created. |
| 238 void BuildSyncedSessionFromSpecifics(const std::string& session_tag, | 237 void BuildSyncedSessionFromSpecifics(const std::string& session_tag, |
| 239 const sync_pb::SessionWindow& specifics, | 238 const sync_pb::SessionWindow& specifics, |
| 240 base::Time mtime, | 239 base::Time mtime, |
| 241 sessions::SessionWindow* session_window); | 240 sessions::SessionWindow* session_window); |
| 242 | 241 |
| 243 // Resync local window information. Updates the local sessions header node | 242 // Resync local window information. Updates the local sessions header node |
| 244 // with the status of open windows and the order of tabs they contain. Should | 243 // with the status of open windows and the order of tabs they contain. Should |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // specifics is the model type, ie us. We need to generate the tag because it | 316 // specifics is the model type, ie us. We need to generate the tag because it |
| 318 // is not passed over the wire for remote data. The use case this function was | 317 // is not passed over the wire for remote data. The use case this function was |
| 319 // created for is detecting bad tag hashes from remote data, see | 318 // created for is detecting bad tag hashes from remote data, see |
| 320 // crbug.com/604657. | 319 // crbug.com/604657. |
| 321 static std::string TagHashFromSpecifics( | 320 static std::string TagHashFromSpecifics( |
| 322 const sync_pb::SessionSpecifics& specifics); | 321 const sync_pb::SessionSpecifics& specifics); |
| 323 | 322 |
| 324 SyncedWindowDelegatesGetter* synced_window_delegates_getter() const; | 323 SyncedWindowDelegatesGetter* synced_window_delegates_getter() const; |
| 325 | 324 |
| 326 // The client of this sync sessions datatype. | 325 // The client of this sync sessions datatype. |
| 327 sync_sessions::SyncSessionsClient* const sessions_client_; | 326 SyncSessionsClient* const sessions_client_; |
| 328 | 327 |
| 329 // Mapping of current open (local) tabs to their sync identifiers. | 328 // Mapping of current open (local) tabs to their sync identifiers. |
| 330 TabLinksMap local_tab_map_; | 329 TabLinksMap local_tab_map_; |
| 331 | 330 |
| 332 SyncedSessionTracker session_tracker_; | 331 SyncedSessionTracker session_tracker_; |
| 333 FaviconCache favicon_cache_; | 332 FaviconCache favicon_cache_; |
| 334 | 333 |
| 335 // Pool of used/available sync nodes associated with local tabs. | 334 // Pool of used/available sync nodes associated with local tabs. |
| 336 TabNodePool local_tab_pool_; | 335 TabNodePool local_tab_pool_; |
| 337 | 336 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 372 |
| 374 // Callback to inform interested observer that new sessions data has arrived. | 373 // Callback to inform interested observer that new sessions data has arrived. |
| 375 base::Closure sessions_updated_callback_; | 374 base::Closure sessions_updated_callback_; |
| 376 | 375 |
| 377 // Callback to inform sync that a sync data refresh is requested. | 376 // Callback to inform sync that a sync data refresh is requested. |
| 378 base::Closure datatype_refresh_callback_; | 377 base::Closure datatype_refresh_callback_; |
| 379 | 378 |
| 380 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 379 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
| 381 }; | 380 }; |
| 382 | 381 |
| 383 } // namespace browser_sync | 382 } // namespace sync_sessions |
| 384 | 383 |
| 385 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 384 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| OLD | NEW |