| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "chrome/browser/sessions/session_types.h" | 18 #include "chrome/browser/sessions/session_types.h" |
| 19 #include "chrome/browser/sync/glue/device_info.h" | |
| 20 #include "chrome/browser/sync/glue/favicon_cache.h" | 19 #include "chrome/browser/sync/glue/favicon_cache.h" |
| 21 #include "chrome/browser/sync/glue/synced_session.h" | 20 #include "chrome/browser/sync/glue/synced_session.h" |
| 22 #include "chrome/browser/sync/glue/synced_session_tracker.h" | 21 #include "chrome/browser/sync/glue/synced_session_tracker.h" |
| 23 #include "chrome/browser/sync/open_tabs_ui_delegate.h" | 22 #include "chrome/browser/sync/open_tabs_ui_delegate.h" |
| 24 #include "chrome/browser/sync/sessions/tab_node_pool.h" | 23 #include "chrome/browser/sync/sessions/tab_node_pool.h" |
| 25 #include "components/sessions/session_id.h" | 24 #include "components/sessions/session_id.h" |
| 25 #include "components/sync_driver/device_info.h" |
| 26 #include "components/sync_driver/sync_prefs.h" | 26 #include "components/sync_driver/sync_prefs.h" |
| 27 #include "sync/api/syncable_service.h" | 27 #include "sync/api/syncable_service.h" |
| 28 | 28 |
| 29 class Profile; | 29 class Profile; |
| 30 | 30 |
| 31 namespace syncer { | 31 namespace syncer { |
| 32 class SyncErrorFactory; | 32 class SyncErrorFactory; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace sync_driver { |
| 36 class LocalDeviceInfoProvider; |
| 37 } |
| 38 |
| 35 namespace sync_pb { | 39 namespace sync_pb { |
| 36 class SessionHeader; | 40 class SessionHeader; |
| 37 class SessionSpecifics; | 41 class SessionSpecifics; |
| 38 class SessionTab; | 42 class SessionTab; |
| 39 class SessionWindow; | 43 class SessionWindow; |
| 40 class TabNavigation; | 44 class TabNavigation; |
| 41 } // namespace sync_pb | 45 } // namespace sync_pb |
| 42 | 46 |
| 43 namespace browser_sync { | 47 namespace browser_sync { |
| 44 | 48 |
| 45 class DataTypeErrorHandler; | 49 class DataTypeErrorHandler; |
| 46 class LocalDeviceInfoProvider; | |
| 47 class SyncedTabDelegate; | 50 class SyncedTabDelegate; |
| 48 class SyncedWindowDelegate; | 51 class SyncedWindowDelegate; |
| 49 class SyncedWindowDelegatesGetter; | 52 class SyncedWindowDelegatesGetter; |
| 50 | 53 |
| 51 // An interface defining the ways in which local open tab events can interact | 54 // An interface defining the ways in which local open tab events can interact |
| 52 // with session sync. All local tab events flow to sync via this interface. | 55 // with session sync. All local tab events flow to sync via this interface. |
| 53 // In that way it is analogous to sync changes flowing to the local model | 56 // In that way it is analogous to sync changes flowing to the local model |
| 54 // via ProcessSyncChanges, just with a more granular breakdown. | 57 // via ProcessSyncChanges, just with a more granular breakdown. |
| 55 class LocalSessionEventHandler { | 58 class LocalSessionEventHandler { |
| 56 public: | 59 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 virtual void Stop() = 0; | 80 virtual void Stop() = 0; |
| 78 }; | 81 }; |
| 79 | 82 |
| 80 // Contains all logic for associating the Chrome sessions model and | 83 // Contains all logic for associating the Chrome sessions model and |
| 81 // the sync sessions model. | 84 // the sync sessions model. |
| 82 class SessionsSyncManager : public syncer::SyncableService, | 85 class SessionsSyncManager : public syncer::SyncableService, |
| 83 public OpenTabsUIDelegate, | 86 public OpenTabsUIDelegate, |
| 84 public LocalSessionEventHandler { | 87 public LocalSessionEventHandler { |
| 85 public: | 88 public: |
| 86 SessionsSyncManager(Profile* profile, | 89 SessionsSyncManager(Profile* profile, |
| 87 LocalDeviceInfoProvider* local_device, | 90 sync_driver::LocalDeviceInfoProvider* local_device, |
| 88 scoped_ptr<LocalSessionEventRouter> router); | 91 scoped_ptr<LocalSessionEventRouter> router); |
| 89 virtual ~SessionsSyncManager(); | 92 virtual ~SessionsSyncManager(); |
| 90 | 93 |
| 91 // syncer::SyncableService implementation. | 94 // syncer::SyncableService implementation. |
| 92 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 95 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 93 syncer::ModelType type, | 96 syncer::ModelType type, |
| 94 const syncer::SyncDataList& initial_sync_data, | 97 const syncer::SyncDataList& initial_sync_data, |
| 95 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 98 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 96 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; | 99 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; |
| 97 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 100 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 bool local_tab_pool_out_of_sync_; | 349 bool local_tab_pool_out_of_sync_; |
| 347 | 350 |
| 348 sync_driver::SyncPrefs sync_prefs_; | 351 sync_driver::SyncPrefs sync_prefs_; |
| 349 | 352 |
| 350 const Profile* const profile_; | 353 const Profile* const profile_; |
| 351 | 354 |
| 352 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 355 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
| 353 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 356 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| 354 | 357 |
| 355 // Local device info provider, owned by ProfileSyncService. | 358 // Local device info provider, owned by ProfileSyncService. |
| 356 const LocalDeviceInfoProvider* const local_device_; | 359 const sync_driver::LocalDeviceInfoProvider* const local_device_; |
| 357 | 360 |
| 358 // Unique client tag. | 361 // Unique client tag. |
| 359 std::string current_machine_tag_; | 362 std::string current_machine_tag_; |
| 360 | 363 |
| 361 // User-visible machine name. | 364 // User-visible machine name. |
| 362 std::string current_session_name_; | 365 std::string current_session_name_; |
| 363 | 366 |
| 364 // SyncID for the sync node containing all the window information for this | 367 // SyncID for the sync node containing all the window information for this |
| 365 // client. | 368 // client. |
| 366 int local_session_header_node_id_; | 369 int local_session_header_node_id_; |
| 367 | 370 |
| 368 // Number of days without activity after which we consider a session to be | 371 // Number of days without activity after which we consider a session to be |
| 369 // stale and a candidate for garbage collection. | 372 // stale and a candidate for garbage collection. |
| 370 size_t stale_session_threshold_days_; | 373 size_t stale_session_threshold_days_; |
| 371 | 374 |
| 372 scoped_ptr<LocalSessionEventRouter> local_event_router_; | 375 scoped_ptr<LocalSessionEventRouter> local_event_router_; |
| 373 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; | 376 scoped_ptr<SyncedWindowDelegatesGetter> synced_window_getter_; |
| 374 | 377 |
| 375 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); | 378 DISALLOW_COPY_AND_ASSIGN(SessionsSyncManager); |
| 376 }; | 379 }; |
| 377 | 380 |
| 378 } // namespace browser_sync | 381 } // namespace browser_sync |
| 379 | 382 |
| 380 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ | 383 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSIONS_SYNC_MANAGER_H_ |
| OLD | NEW |