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 COMPONENTS_SYNC_DRIVER_TAB_NODE_POOL_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_TAB_NODE_POOL_H_ |
6 #define COMPONENTS_SYNC_DRIVER_TAB_NODE_POOL_H_ | 6 #define COMPONENTS_SYNC_DRIVER_TAB_NODE_POOL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | |
14 #include "components/sessions/core/session_id.h" | 13 #include "components/sessions/core/session_id.h" |
15 #include "sync/api/sync_change_processor.h" | 14 #include "sync/api/sync_change_processor.h" |
16 | 15 |
17 namespace syncer { | 16 namespace syncer { |
18 class SyncChangeProcessor; | 17 class SyncChangeProcessor; |
19 } | 18 } |
20 | 19 |
21 namespace browser_sync { | 20 namespace browser_sync { |
22 | 21 |
23 // A pool for managing free/used tab sync nodes for the *local* session. | 22 // A pool for managing free/used tab sync nodes for the *local* session. |
24 // Performs lazy creation of sync nodes when necessary. | 23 // Performs lazy creation of sync nodes when necessary. |
25 // Note: We make use of the following "id's" | 24 // Note: We make use of the following "id's" |
26 // - a tab_id: created by session service, unique to this client | 25 // - a tab_id: created by session service, unique to this client |
27 // - a tab_node_id: the id for a particular sync tab node. This is used | 26 // - a tab_node_id: the id for a particular sync tab node. This is used |
28 // to generate the sync tab node tag through: | 27 // to generate the sync tab node tag through: |
29 // tab_tag = StringPrintf("%s_%ui", local_session_tag, tab_node_id); | 28 // tab_tag = StringPrintf("%s_%ui", local_session_tag, tab_node_id); |
30 // | 29 // |
31 // A sync node can be in one of the three states: | 30 // A sync node can be in one of the three states: |
32 // 1. Associated : Sync node is used and associated with a tab. | 31 // 1. Associated : Sync node is used and associated with a tab. |
33 // 2. Unassociated : Sync node is used but currently unassociated with any tab. | 32 // 2. Unassociated : Sync node is used but currently unassociated with any tab. |
34 // This is true for old nodes that remain from a session | 33 // This is true for old nodes that remain from a session |
35 // restart. Nodes are only unassociated temporarily while the | 34 // restart. Nodes are only unassociated temporarily while the |
36 // model associator figures out which tabs belong to which | 35 // model associator figures out which tabs belong to which |
37 // nodes. Eventually any remaining unassociated nodes are | 36 // nodes. Eventually any remaining unassociated nodes are |
38 // freed. | 37 // freed. |
39 // 3. Free : Sync node is unused. | 38 // 3. Free : Sync node is unused. |
40 | 39 |
41 class TabNodePool { | 40 class TabNodePool { |
42 public: | 41 public: |
43 TabNodePool(); | 42 TabNodePool(); |
44 ~TabNodePool(); | 43 ~TabNodePool(); |
45 enum InvalidTab { | 44 enum InvalidTab { |
46 kInvalidTabID = -1 | 45 kInvalidTabID = -1 |
47 }; | 46 }; |
48 | 47 |
49 // If free nodes > kFreeNodesHighWatermark, delete all free nodes until | 48 // If free nodes > kFreeNodesHighWatermark, delete all free nodes until |
50 // free nodes <= kFreeNodesLowWatermark. | 49 // free nodes <= kFreeNodesLowWatermark. |
51 static const size_t kFreeNodesLowWatermark; | 50 static const size_t kFreeNodesLowWatermark; |
52 | 51 |
53 // Maximum limit of FreeNodes allowed on the client. | 52 // Maximum limit of FreeNodes allowed on the client. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // The machine tag associated with this tab pool. Used in the title of new | 155 // The machine tag associated with this tab pool. Used in the title of new |
157 // sync nodes. | 156 // sync nodes. |
158 std::string machine_tag_; | 157 std::string machine_tag_; |
159 | 158 |
160 DISALLOW_COPY_AND_ASSIGN(TabNodePool); | 159 DISALLOW_COPY_AND_ASSIGN(TabNodePool); |
161 }; | 160 }; |
162 | 161 |
163 } // namespace browser_sync | 162 } // namespace browser_sync |
164 | 163 |
165 #endif // COMPONENTS_SYNC_DRIVER_TAB_NODE_POOL_H_ | 164 #endif // COMPONENTS_SYNC_DRIVER_TAB_NODE_POOL_H_ |
OLD | NEW |