| OLD | NEW |
| 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_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_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/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "chrome/browser/sessions/session_id.h" | 20 #include "chrome/browser/sessions/session_id.h" |
| 21 #include "chrome/browser/sessions/session_service.h" | 21 #include "chrome/browser/sessions/session_service.h" |
| 22 #include "chrome/browser/sessions/session_types.h" | 22 #include "chrome/browser/sessions/session_types.h" |
| 23 #include "chrome/browser/sync/glue/favicon_cache.h" | 23 #include "chrome/browser/sync/glue/favicon_cache.h" |
| 24 #include "chrome/browser/sync/glue/model_associator.h" | 24 #include "chrome/browser/sync/glue/model_associator.h" |
| 25 #include "chrome/browser/sync/glue/synced_session_tracker.h" | 25 #include "chrome/browser/sync/glue/synced_session_tracker.h" |
| 26 #include "chrome/browser/sync/glue/tab_node_pool.h" | 26 #include "chrome/browser/sync/glue/tab_node_pool.h" |
| 27 |
| 27 #include "sync/internal_api/public/base/model_type.h" | 28 #include "sync/internal_api/public/base/model_type.h" |
| 28 | 29 |
| 29 class PrefServiceSyncable; | 30 class PrefServiceSyncable; |
| 30 class Profile; | 31 class Profile; |
| 31 class ProfileSyncService; | 32 class ProfileSyncService; |
| 32 | 33 |
| 33 namespace syncer { | 34 namespace syncer { |
| 34 class ReadNode; | 35 class ReadNode; |
| 35 class WriteTransaction; | 36 class WriteTransaction; |
| 36 } // namespace syncer | 37 } // namespace syncer |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // Returns: false if the local session's sync nodes were deleted and | 123 // Returns: false if the local session's sync nodes were deleted and |
| 123 // reassociation is necessary, true otherwise. | 124 // reassociation is necessary, true otherwise. |
| 124 bool AssociateTabs(const std::vector<SyncedTabDelegate*>& tabs, | 125 bool AssociateTabs(const std::vector<SyncedTabDelegate*>& tabs, |
| 125 syncer::SyncError* error); | 126 syncer::SyncError* error); |
| 126 | 127 |
| 127 // Reassociates a single tab with the sync model. Will check if the tab | 128 // Reassociates a single tab with the sync model. Will check if the tab |
| 128 // already is associated with a sync node and allocate one if necessary. | 129 // already is associated with a sync node and allocate one if necessary. |
| 129 // |error| gets set if any association error occurred. | 130 // |error| gets set if any association error occurred. |
| 130 // Returns: false if the local session's sync nodes were deleted and | 131 // Returns: false if the local session's sync nodes were deleted and |
| 131 // reassociation is necessary, true otherwise. | 132 // reassociation is necessary, true otherwise. |
| 132 bool AssociateTab(const SyncedTabDelegate& tab, | 133 bool AssociateTab(SyncedTabDelegate& tab, syncer::SyncError* error); |
| 133 syncer::SyncError* error); | |
| 134 | 134 |
| 135 // Load any foreign session info stored in sync db and update the sync db | 135 // Load any foreign session info stored in sync db and update the sync db |
| 136 // with local client data. Processes/reuses any sync nodes owned by this | 136 // with local client data. Processes/reuses any sync nodes owned by this |
| 137 // client and creates any further sync nodes needed to store local header and | 137 // client and creates any further sync nodes needed to store local header and |
| 138 // tab info. | 138 // tab info. |
| 139 virtual syncer::SyncError AssociateModels( | 139 virtual syncer::SyncError AssociateModels( |
| 140 syncer::SyncMergeResult* local_merge_result, | 140 syncer::SyncMergeResult* local_merge_result, |
| 141 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; | 141 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; |
| 142 | 142 |
| 143 // Initializes the given sync node from the given chrome node id. | 143 // Initializes the given sync node from the given chrome node id. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // Return the favicon url of the current tab, even if it's pending. | 311 // Return the favicon url of the current tab, even if it's pending. |
| 312 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); | 312 static GURL GetCurrentFaviconURL(const SyncedTabDelegate& tab_delegate); |
| 313 | 313 |
| 314 // Fills a tab sync node with data from a WebContents object. Updates | 314 // Fills a tab sync node with data from a WebContents object. Updates |
| 315 // |tab_link| with the current url if it's valid and triggers a favicon | 315 // |tab_link| with the current url if it's valid and triggers a favicon |
| 316 // load if the url has changed. | 316 // load if the url has changed. |
| 317 // Returns true on success, false if we need to reassociate due to corruption. | 317 // Returns true on success, false if we need to reassociate due to corruption. |
| 318 bool WriteTabContentsToSyncModel(TabLink* tab_link, | 318 bool WriteTabContentsToSyncModel(TabLink* tab_link, |
| 319 syncer::SyncError* error); | 319 syncer::SyncError* error); |
| 320 | 320 |
| 321 void UpdateTabIdForOldTab(int64 sync_id, SessionID::id_type new_tab_id); |
| 322 |
| 321 // Set |session_tab| from |tab_delegate| and |mtime|. | 323 // Set |session_tab| from |tab_delegate| and |mtime|. |
| 322 static void SetSessionTabFromDelegate( | 324 static void SetSessionTabFromDelegate( |
| 323 const SyncedTabDelegate& tab_delegate, | 325 const SyncedTabDelegate& tab_delegate, |
| 324 base::Time mtime, | 326 base::Time mtime, |
| 325 SessionTab* session_tab); | 327 SessionTab* session_tab); |
| 326 | 328 |
| 327 // Used to populate a session header from the session specifics header | 329 // Used to populate a session header from the session specifics header |
| 328 // provided. | 330 // provided. |
| 329 static void PopulateSessionHeaderFromSpecifics( | 331 static void PopulateSessionHeaderFromSpecifics( |
| 330 const sync_pb::SessionHeader& header_specifics, | 332 const sync_pb::SessionHeader& header_specifics, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 350 | 352 |
| 351 // Having a valid entry is defined as the url being valid and and having a | 353 // Having a valid entry is defined as the url being valid and and having a |
| 352 // syncable scheme (non chrome:// and file:// url's). In other words, we don't | 354 // syncable scheme (non chrome:// and file:// url's). In other words, we don't |
| 353 // want to sync a tab that is nothing but chrome:// and file:// navigations or | 355 // want to sync a tab that is nothing but chrome:// and file:// navigations or |
| 354 // invalid url's. | 356 // invalid url's. |
| 355 bool TabHasValidEntry(const SyncedTabDelegate& tab) const; | 357 bool TabHasValidEntry(const SyncedTabDelegate& tab) const; |
| 356 | 358 |
| 357 // For testing only. | 359 // For testing only. |
| 358 void QuitLoopForSubtleTesting(); | 360 void QuitLoopForSubtleTesting(); |
| 359 | 361 |
| 362 void NotifySyncIdGenerated(const SyncedTabDelegate& tab); |
| 363 |
| 360 // Unique client tag. | 364 // Unique client tag. |
| 361 std::string current_machine_tag_; | 365 std::string current_machine_tag_; |
| 362 | 366 |
| 363 // User-visible machine name. | 367 // User-visible machine name. |
| 364 std::string current_session_name_; | 368 std::string current_session_name_; |
| 365 | 369 |
| 366 // Pool of all used/available sync nodes associated with tabs. | 370 // Pool of all used/available sync nodes associated with tabs. |
| 367 TabNodePool tab_pool_; | 371 TabNodePool tab_pool_; |
| 368 | 372 |
| 369 // SyncID for the sync node containing all the window information for this | 373 // SyncID for the sync node containing all the window information for this |
| (...skipping 27 matching lines...) Expand all Loading... |
| 397 | 401 |
| 398 // Our favicon cache. | 402 // Our favicon cache. |
| 399 FaviconCache favicon_cache_; | 403 FaviconCache favicon_cache_; |
| 400 | 404 |
| 401 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 405 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
| 402 }; | 406 }; |
| 403 | 407 |
| 404 } // namespace browser_sync | 408 } // namespace browser_sync |
| 405 | 409 |
| 406 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 410 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |