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> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Loads and reassociates the local tabs referenced in |tabs|. | 101 // Loads and reassociates the local tabs referenced in |tabs|. |
102 // |error| gets set if any association error occurred. | 102 // |error| gets set if any association error occurred. |
103 // Returns: false if the local session's sync nodes were deleted and | 103 // Returns: false if the local session's sync nodes were deleted and |
104 // reassociation is necessary, true otherwise. | 104 // reassociation is necessary, true otherwise. |
105 bool AssociateTabs(const std::vector<SyncedTabDelegate*>& tabs, | 105 bool AssociateTabs(const std::vector<SyncedTabDelegate*>& tabs, |
106 syncer::SyncError* error); | 106 syncer::SyncError* error); |
107 | 107 |
108 // Reassociates a single tab with the sync model. Will check if the tab | 108 // Reassociates a single tab with the sync model. Will check if the tab |
109 // already is associated with a sync node and allocate one if necessary. | 109 // already is associated with a sync node and allocate one if necessary. |
110 // |error| gets set if any association error occurred. | 110 // |error| gets set if any association error occurred. |
| 111 // |tab| will be updated with sync id if necessary. |
111 // Returns: false if the local session's sync nodes were deleted and | 112 // Returns: false if the local session's sync nodes were deleted and |
112 // reassociation is necessary, true otherwise. | 113 // reassociation is necessary, true otherwise. |
113 bool AssociateTab(const SyncedTabDelegate& tab, | 114 bool AssociateTab(SyncedTabDelegate* const tab, syncer::SyncError* error); |
114 syncer::SyncError* error); | |
115 | 115 |
116 // Load any foreign session info stored in sync db and update the sync db | 116 // Load any foreign session info stored in sync db and update the sync db |
117 // with local client data. Processes/reuses any sync nodes owned by this | 117 // with local client data. Processes/reuses any sync nodes owned by this |
118 // client and creates any further sync nodes needed to store local header and | 118 // client and creates any further sync nodes needed to store local header and |
119 // tab info. | 119 // tab info. |
120 virtual syncer::SyncError AssociateModels( | 120 virtual syncer::SyncError AssociateModels( |
121 syncer::SyncMergeResult* local_merge_result, | 121 syncer::SyncMergeResult* local_merge_result, |
122 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; | 122 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; |
123 | 123 |
124 // Clear local sync data buffers. Does not delete sync nodes to avoid | 124 // Clear local sync data buffers. Does not delete sync nodes to avoid |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // Returns true if this tab belongs to this profile and belongs to a window, | 322 // Returns true if this tab belongs to this profile and belongs to a window, |
323 // false otherwise. | 323 // false otherwise. |
324 bool IsValidTab(const SyncedTabDelegate& tab) const; | 324 bool IsValidTab(const SyncedTabDelegate& tab) const; |
325 | 325 |
326 // Having a valid entry is defined as the url being valid and and having a | 326 // Having a valid entry is defined as the url being valid and and having a |
327 // syncable scheme (non chrome:// and file:// url's). In other words, we don't | 327 // syncable scheme (non chrome:// and file:// url's). In other words, we don't |
328 // want to sync a tab that is nothing but chrome:// and file:// navigations or | 328 // want to sync a tab that is nothing but chrome:// and file:// navigations or |
329 // invalid url's. | 329 // invalid url's. |
330 bool TabHasValidEntry(const SyncedTabDelegate& tab) const; | 330 bool TabHasValidEntry(const SyncedTabDelegate& tab) const; |
331 | 331 |
| 332 // Update the tab id of the node associated with |sync_id| to |new_tab_id|. |
| 333 void UpdateTabIdIfNecessary(int64 sync_id, SessionID::id_type new_tab_id); |
| 334 |
332 // For testing only. | 335 // For testing only. |
333 void QuitLoopForSubtleTesting(); | 336 void QuitLoopForSubtleTesting(); |
334 | 337 |
335 // Unique client tag. | 338 // Unique client tag. |
336 std::string current_machine_tag_; | 339 std::string current_machine_tag_; |
337 | 340 |
338 // User-visible machine name. | 341 // User-visible machine name. |
339 std::string current_session_name_; | 342 std::string current_session_name_; |
340 | 343 |
341 // Pool of all used/available sync nodes associated with tabs. | 344 // Pool of all used/available sync nodes associated with tabs. |
(...skipping 30 matching lines...) Expand all Loading... |
372 | 375 |
373 // Our favicon cache. | 376 // Our favicon cache. |
374 FaviconCache favicon_cache_; | 377 FaviconCache favicon_cache_; |
375 | 378 |
376 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 379 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
377 }; | 380 }; |
378 | 381 |
379 } // namespace browser_sync | 382 } // namespace browser_sync |
380 | 383 |
381 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 384 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
OLD | NEW |