| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Returns sync_api::kInvalidId if the sync node is not found for the given | 70 // Returns sync_api::kInvalidId if the sync node is not found for the given |
| 71 // chrome id. | 71 // chrome id. |
| 72 virtual int64 GetSyncIdFromChromeId(const size_t& id); | 72 virtual int64 GetSyncIdFromChromeId(const size_t& id); |
| 73 | 73 |
| 74 // Returns sync id for the given session tag. | 74 // Returns sync id for the given session tag. |
| 75 // Returns sync_api::kInvalidId if the sync node is not found for the given | 75 // Returns sync_api::kInvalidId if the sync node is not found for the given |
| 76 // tag | 76 // tag |
| 77 virtual int64 GetSyncIdFromSessionTag(const std::string& tag); | 77 virtual int64 GetSyncIdFromSessionTag(const std::string& tag); |
| 78 | 78 |
| 79 // Not used. | 79 // Not used. |
| 80 virtual const TabContents* GetChromeNodeFromSyncId(int64 sync_id) { | 80 virtual const TabContents* GetChromeNodeFromSyncId(int64 sync_id); |
| 81 NOTREACHED(); | |
| 82 return NULL; | |
| 83 } | |
| 84 | 81 |
| 85 // Not used. | 82 // Not used. |
| 86 bool InitSyncNodeFromChromeId(const size_t& id, | 83 virtual bool InitSyncNodeFromChromeId(const size_t& id, |
| 87 sync_api::BaseNode* sync_node) { | 84 sync_api::BaseNode* sync_node); |
| 88 NOTREACHED(); | |
| 89 return false; | |
| 90 } | |
| 91 | 85 |
| 92 // Resync local window information. Updates the local sessions header node | 86 // Resync local window information. Updates the local sessions header node |
| 93 // with the status of open windows and the order of tabs they contain. Should | 87 // with the status of open windows and the order of tabs they contain. Should |
| 94 // only be called for changes that affect a window, not a change within a | 88 // only be called for changes that affect a window, not a change within a |
| 95 // single tab. | 89 // single tab. |
| 96 // | 90 // |
| 97 // If |reload_tabs| is true, will also resync all tabs (same as calling | 91 // If |reload_tabs| is true, will also resync all tabs (same as calling |
| 98 // ReassociateTabs with a vector of all tabs). | 92 // ReassociateTabs with a vector of all tabs). |
| 99 void ReassociateWindows(bool reload_tabs); | 93 void ReassociateWindows(bool reload_tabs); |
| 100 | 94 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 int64 sync_id_; | 211 int64 sync_id_; |
| 218 SessionTab* session_tab_; | 212 SessionTab* session_tab_; |
| 219 TabContents* tab_; | 213 TabContents* tab_; |
| 220 }; | 214 }; |
| 221 | 215 |
| 222 // A pool for managing free/used tab sync nodes. Performs lazy creation | 216 // A pool for managing free/used tab sync nodes. Performs lazy creation |
| 223 // of sync nodes when necessary. | 217 // of sync nodes when necessary. |
| 224 class TabNodePool { | 218 class TabNodePool { |
| 225 public: | 219 public: |
| 226 explicit TabNodePool(ProfileSyncService* sync_service); | 220 explicit TabNodePool(ProfileSyncService* sync_service); |
| 221 ~TabNodePool(); |
| 227 | 222 |
| 228 // Add a previously allocated tab sync node to our pool. Increases the size | 223 // Add a previously allocated tab sync node to our pool. Increases the size |
| 229 // of tab_syncid_pool_ by one and marks the new tab node as free. | 224 // of tab_syncid_pool_ by one and marks the new tab node as free. |
| 230 // Note: this should only be called when we discover tab sync nodes from | 225 // Note: this should only be called when we discover tab sync nodes from |
| 231 // previous sessions, not for freeing tab nodes we created through | 226 // previous sessions, not for freeing tab nodes we created through |
| 232 // GetFreeTabNode (use FreeTabNode below for that). | 227 // GetFreeTabNode (use FreeTabNode below for that). |
| 233 void AddTabNode(int64 sync_id); | 228 void AddTabNode(int64 sync_id); |
| 234 | 229 |
| 235 // Returns the sync_id for the next free tab node. If none are available, | 230 // Returns the sync_id for the next free tab node. If none are available, |
| 236 // creates a new tab node. | 231 // creates a new tab node. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 399 |
| 405 // Consumer used to obtain the current session. | 400 // Consumer used to obtain the current session. |
| 406 CancelableRequestConsumer consumer_; | 401 CancelableRequestConsumer consumer_; |
| 407 | 402 |
| 408 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 403 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
| 409 }; | 404 }; |
| 410 | 405 |
| 411 } // namespace browser_sync | 406 } // namespace browser_sync |
| 412 | 407 |
| 413 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 408 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |