Index: chrome/browser/sync/glue/tab_node_pool.h |
diff --git a/chrome/browser/sync/glue/tab_node_pool.h b/chrome/browser/sync/glue/tab_node_pool.h |
index 8327d061e08551ecf4fb835e39b06b80f1a613f5..15f6a78d45156b6876ff4e901d129207c29e5c0d 100644 |
--- a/chrome/browser/sync/glue/tab_node_pool.h |
+++ b/chrome/browser/sync/glue/tab_node_pool.h |
@@ -5,10 +5,12 @@ |
#ifndef CHROME_BROWSER_SYNC_GLUE_TAB_NODE_POOL_H_ |
#define CHROME_BROWSER_SYNC_GLUE_TAB_NODE_POOL_H_ |
+#include <set> |
#include <string> |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/gtest_prod_util.h" |
class ProfileSyncService; |
@@ -26,11 +28,11 @@ class TabNodePool { |
size_t tab_node_id); |
// Add a previously allocated tab sync node to our pool. Increases the size |
- // of tab_syncid_pool_ by one and marks the new tab node as free. |
+ // of tab_syncid_pool_ by one and adds node to old tab nodes set.. |
// Note: this should only be called when we discover tab sync nodes from |
// previous sessions, not for freeing tab nodes we created through |
// GetFreeTabNode (use FreeTabNode below for that). |
- void AddTabNode(int64 sync_id); |
+ void AddOldTabNode(int64 sync_id, size_t tab_node_id); |
Nicolas Zea
2013/06/06 21:27:39
I think this should be moved down to be next to th
shashi
2013/06/11 19:15:06
Done.
|
// Returns the sync_id for the next free tab node. If none are available, |
// creates a new tab node. |
@@ -54,10 +56,19 @@ class TabNodePool { |
// associated with this machine. |
void FreeTabNode(int64 sync_id); |
+ // If there is no old node with id |sync_id| return false. Otherwise remove |
+ // |sync_id| from old ids pool and return true. |
+ bool RemoveIfOldSyncNodeExists(int64 sync_id); |
+ |
+ // Return all the old sync ids that are not in |used_sync_ids| to the free |
+ // node pool. |
+ void FreeUnusedOldSyncNodes(const std::set<int64>& used_sync_ids); |
+ |
// Clear tab pool. |
void clear() { |
tab_syncid_pool_.clear(); |
tab_pool_fp_ = -1; |
+ old_node_syncids_.clear(); |
} |
// Return the number of tab nodes this client currently has allocated |
@@ -77,6 +88,8 @@ class TabNodePool { |
} |
private: |
+ FRIEND_TEST_ALL_PREFIXES(SyncTabNodePoolTest, TabNodeIdIncreases); |
+ |
// Pool of all available syncid's for tab's we have created. |
std::vector<int64> tab_syncid_pool_; |
@@ -86,7 +99,14 @@ class TabNodePool { |
// To get the next free node, use tab_syncid_pool_[tab_pool_fp_--]. |
int64 tab_pool_fp_; |
- // The machiine tag associated with this tab pool. Used in the title of new |
+ // The maximum used tab_node id for a sync node. A new sync node will always |
+ // be created with max_used_tab_node_id_ + 1. |
+ size_t max_used_tab_node_id_; |
+ |
+ // Set of old sync ids. |
+ std::set<int64> old_node_syncids_; |
+ |
+ // The machine tag associated with this tab pool. Used in the title of new |
// sync nodes. |
std::string machine_tag_; |