Chromium Code Reviews| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/time/clock.h" | |
| 20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 21 #include "components/sessions/core/session_id.h" | 22 #include "components/sessions/core/session_id.h" |
| 22 #include "components/sessions/core/session_types.h" | 23 #include "components/sessions/core/session_types.h" |
| 23 #include "components/sync/base/sync_prefs.h" | 24 #include "components/sync/base/sync_prefs.h" |
| 24 #include "components/sync/device_info/device_info.h" | 25 #include "components/sync/device_info/device_info.h" |
| 25 #include "components/sync/model/syncable_service.h" | 26 #include "components/sync/model/syncable_service.h" |
| 26 #include "components/sync_sessions/favicon_cache.h" | 27 #include "components/sync_sessions/favicon_cache.h" |
| 27 #include "components/sync_sessions/local_session_event_router.h" | 28 #include "components/sync_sessions/local_session_event_router.h" |
| 28 #include "components/sync_sessions/lost_navigations_recorder.h" | 29 #include "components/sync_sessions/lost_navigations_recorder.h" |
| 29 #include "components/sync_sessions/open_tabs_ui_delegate.h" | 30 #include "components/sync_sessions/open_tabs_ui_delegate.h" |
| 30 #include "components/sync_sessions/revisit/page_revisit_broadcaster.h" | 31 #include "components/sync_sessions/revisit/page_revisit_broadcaster.h" |
| 31 #include "components/sync_sessions/synced_session.h" | 32 #include "components/sync_sessions/synced_session.h" |
| 32 #include "components/sync_sessions/synced_session_tracker.h" | 33 #include "components/sync_sessions/synced_session_tracker.h" |
| 34 #include "components/sync_sessions/task_tracker.h" | |
| 33 | 35 |
| 34 namespace syncer { | 36 namespace syncer { |
| 35 class LocalDeviceInfoProvider; | 37 class LocalDeviceInfoProvider; |
| 36 class SyncErrorFactory; | 38 class SyncErrorFactory; |
| 37 class SyncPrefs; | 39 class SyncPrefs; |
| 38 } // namespace syncer | 40 } // namespace syncer |
| 39 | 41 |
| 40 namespace sync_pb { | 42 namespace sync_pb { |
| 41 class SessionHeader; | 43 class SessionHeader; |
| 42 class SessionSpecifics; | 44 class SessionSpecifics; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 57 // the sync sessions model. | 59 // the sync sessions model. |
| 58 class SessionsSyncManager : public syncer::SyncableService, | 60 class SessionsSyncManager : public syncer::SyncableService, |
| 59 public OpenTabsUIDelegate, | 61 public OpenTabsUIDelegate, |
| 60 public LocalSessionEventHandler { | 62 public LocalSessionEventHandler { |
| 61 public: | 63 public: |
| 62 SessionsSyncManager(SyncSessionsClient* sessions_client, | 64 SessionsSyncManager(SyncSessionsClient* sessions_client, |
| 63 syncer::SyncPrefs* sync_prefs, | 65 syncer::SyncPrefs* sync_prefs, |
| 64 syncer::LocalDeviceInfoProvider* local_device, | 66 syncer::LocalDeviceInfoProvider* local_device, |
| 65 std::unique_ptr<LocalSessionEventRouter> router, | 67 std::unique_ptr<LocalSessionEventRouter> router, |
| 66 const base::Closure& sessions_updated_callback, | 68 const base::Closure& sessions_updated_callback, |
| 67 const base::Closure& datatype_refresh_callback); | 69 const base::Closure& datatype_refresh_callback, |
| 70 std::unique_ptr<base::Clock> clock = | |
| 71 base::MakeUnique<base::DefaultClock>()); | |
| 68 ~SessionsSyncManager() override; | 72 ~SessionsSyncManager() override; |
| 69 | 73 |
| 70 // syncer::SyncableService implementation. | 74 // syncer::SyncableService implementation. |
| 71 syncer::SyncMergeResult MergeDataAndStartSyncing( | 75 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 72 syncer::ModelType type, | 76 syncer::ModelType type, |
| 73 const syncer::SyncDataList& initial_sync_data, | 77 const syncer::SyncDataList& initial_sync_data, |
| 74 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, | 78 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 75 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override; | 79 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 76 void StopSyncing(syncer::ModelType type) override; | 80 void StopSyncing(syncer::ModelType type) override; |
| 77 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; | 81 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 // Loads and reassociates the local tabs referenced in |tabs|. | 225 // Loads and reassociates the local tabs referenced in |tabs|. |
| 222 // |change_output| *must* be provided as a link to the SyncChange pipeline | 226 // |change_output| *must* be provided as a link to the SyncChange pipeline |
| 223 // that exists in the caller's context. This function will append necessary | 227 // that exists in the caller's context. This function will append necessary |
| 224 // changes for processing later. | 228 // changes for processing later. |
| 225 void AssociateTab(SyncedTabDelegate* const tab, | 229 void AssociateTab(SyncedTabDelegate* const tab, |
| 226 syncer::SyncChangeList* change_output); | 230 syncer::SyncChangeList* change_output); |
| 227 | 231 |
| 228 // Set |session_tab| from |tab_delegate| and |mtime|. | 232 // Set |session_tab| from |tab_delegate| and |mtime|. |
| 229 void SetSessionTabFromDelegate(const SyncedTabDelegate& tab_delegate, | 233 void SetSessionTabFromDelegate(const SyncedTabDelegate& tab_delegate, |
| 230 base::Time mtime, | 234 base::Time mtime, |
| 231 sessions::SessionTab* session_tab); | 235 sessions::SessionTab* session_tab, |
| 236 TabTasks* tab_tasks); | |
| 232 | 237 |
| 233 // Sets |variation_ids| field of |session_tab| with the ids of the currently | 238 // Sets |variation_ids| field of |session_tab| with the ids of the currently |
| 234 // assigned variations which should be sent to sync. | 239 // assigned variations which should be sent to sync. |
| 235 static void SetVariationIds(sessions::SessionTab* session_tab); | 240 static void SetVariationIds(sessions::SessionTab* session_tab); |
| 236 | 241 |
| 237 // Populates |specifics| based on the data in |tab_delegate|. | 242 // Populates |specifics| based on the data in |tab_delegate|. |
| 238 void LocalTabDelegateToSpecifics(const SyncedTabDelegate& tab_delegate, | 243 void LocalTabDelegateToSpecifics(const SyncedTabDelegate& tab_delegate, |
| 239 sync_pb::SessionSpecifics* specifics); | 244 sync_pb::SessionSpecifics* specifics); |
| 240 | 245 |
| 241 // It's possible that when we associate windows, tabs aren't all loaded | 246 // It's possible that when we associate windows, tabs aren't all loaded |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 | 321 |
| 317 std::unique_ptr<sync_sessions::LostNavigationsRecorder> | 322 std::unique_ptr<sync_sessions::LostNavigationsRecorder> |
| 318 lost_navigations_recorder_; | 323 lost_navigations_recorder_; |
| 319 | 324 |
| 320 // Callback to inform interested observer that new sessions data has arrived. | 325 // Callback to inform interested observer that new sessions data has arrived. |
| 321 base::Closure sessions_updated_callback_; | 326 base::Closure sessions_updated_callback_; |
| 322 | 327 |
| 323 // Callback to inform sync that a sync data refresh is requested. | 328 // Callback to inform sync that a sync data refresh is requested. |
| 324 base::Closure datatype_refresh_callback_; | 329 base::Closure datatype_refresh_callback_; |
| 325 | 330 |
| 331 std::unique_ptr<TaskTracker> task_tracker_; | |
|
Nicolas Zea
2017/03/27 20:43:52
nit: comment what this is for
shenchao
2017/04/06 00:54:55
Done.
| |
| 332 | |
| 326 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 333 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
| 327 }; | 334 }; |
| 328 | 335 |
| 329 } // namespace sync_sessions | 336 } // namespace sync_sessions |
| 330 | 337 |
| 331 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 338 #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| OLD | NEW |