OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/sync/protocol/session_specifics.pb.h" | 30 #include "chrome/browser/sync/protocol/session_specifics.pb.h" |
31 #include "chrome/browser/sync/syncable/model_type.h" | 31 #include "chrome/browser/sync/syncable/model_type.h" |
32 #include "chrome/browser/sync/util/weak_handle.h" | 32 #include "chrome/browser/sync/util/weak_handle.h" |
33 | 33 |
34 class Profile; | 34 class Profile; |
35 class ProfileSyncService; | 35 class ProfileSyncService; |
36 | 36 |
37 namespace sync_api { | 37 namespace sync_api { |
38 class BaseTransaction; | 38 class BaseTransaction; |
39 class ReadNode; | 39 class ReadNode; |
40 class WriteNode; | |
41 class WriteTransaction; | 40 class WriteTransaction; |
42 } // namespace sync_api | 41 } // namespace sync_api |
43 | 42 |
44 namespace sync_pb { | 43 namespace sync_pb { |
45 class SessionSpecifics; | 44 class SessionSpecifics; |
46 } // namespace sync_pb | 45 } // namespace sync_pb |
47 | 46 |
48 namespace browser_sync { | 47 namespace browser_sync { |
49 | 48 |
50 static const char kSessionsTag[] = "google_chrome_sessions"; | 49 static const char kSessionsTag[] = "google_chrome_sessions"; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 250 } |
252 TabLinks(int64 sync_id, const SessionTab* session_tab) | 251 TabLinks(int64 sync_id, const SessionTab* session_tab) |
253 : sync_id_(sync_id), | 252 : sync_id_(sync_id), |
254 tab_(NULL) { | 253 tab_(NULL) { |
255 session_tab_ = const_cast<SessionTab*>(session_tab); | 254 session_tab_ = const_cast<SessionTab*>(session_tab); |
256 } | 255 } |
257 | 256 |
258 int64 sync_id() const { return sync_id_; } | 257 int64 sync_id() const { return sync_id_; } |
259 const SessionTab* session_tab() const { return session_tab_; } | 258 const SessionTab* session_tab() const { return session_tab_; } |
260 const SyncedTabDelegate* tab() const { return tab_; } | 259 const SyncedTabDelegate* tab() const { return tab_; } |
| 260 |
261 private: | 261 private: |
262 int64 sync_id_; | 262 int64 sync_id_; |
263 SessionTab* session_tab_; | 263 SessionTab* session_tab_; |
264 SyncedTabDelegate* tab_; | 264 SyncedTabDelegate* tab_; |
265 }; | 265 }; |
266 | 266 |
267 // A pool for managing free/used tab sync nodes. Performs lazy creation | 267 // A pool for managing free/used tab sync nodes. Performs lazy creation |
268 // of sync nodes when necessary. | 268 // of sync nodes when necessary. |
269 class TabNodePool { | 269 class TabNodePool { |
270 public: | 270 public: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 bool empty() const { return tab_pool_fp_ == -1; } | 314 bool empty() const { return tab_pool_fp_ == -1; } |
315 | 315 |
316 // Return full status (no tab nodes are in use). | 316 // Return full status (no tab nodes are in use). |
317 bool full() { | 317 bool full() { |
318 return tab_pool_fp_ == static_cast<int64>(tab_syncid_pool_.size())-1; | 318 return tab_pool_fp_ == static_cast<int64>(tab_syncid_pool_.size())-1; |
319 } | 319 } |
320 | 320 |
321 void set_machine_tag(const std::string& machine_tag) { | 321 void set_machine_tag(const std::string& machine_tag) { |
322 machine_tag_ = machine_tag; | 322 machine_tag_ = machine_tag; |
323 } | 323 } |
| 324 |
324 private: | 325 private: |
325 // Pool of all available syncid's for tab's we have created. | 326 // Pool of all available syncid's for tab's we have created. |
326 std::vector<int64> tab_syncid_pool_; | 327 std::vector<int64> tab_syncid_pool_; |
327 | 328 |
328 // Free pointer for tab pool. Only those node id's, up to and including the | 329 // Free pointer for tab pool. Only those node id's, up to and including the |
329 // one indexed by the free pointer, are valid and free. The rest of the | 330 // one indexed by the free pointer, are valid and free. The rest of the |
330 // |tab_syncid_pool_| is invalid because the nodes are in use. | 331 // |tab_syncid_pool_| is invalid because the nodes are in use. |
331 // To get the next free node, use tab_syncid_pool_[tab_pool_fp_--]. | 332 // To get the next free node, use tab_syncid_pool_[tab_pool_fp_--]. |
332 int64 tab_pool_fp_; | 333 int64 tab_pool_fp_; |
333 | 334 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // is made. | 478 // is made. |
478 bool waiting_for_change_; | 479 bool waiting_for_change_; |
479 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; | 480 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; |
480 | 481 |
481 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 482 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
482 }; | 483 }; |
483 | 484 |
484 } // namespace browser_sync | 485 } // namespace browser_sync |
485 | 486 |
486 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 487 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
OLD | NEW |