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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" |
14 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
19 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
20 #include "base/threading/non_thread_safe.h" | 21 #include "base/threading/non_thread_safe.h" |
21 #include "base/time.h" | 22 #include "base/time.h" |
22 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
23 #include "chrome/browser/sessions/session_id.h" | 24 #include "chrome/browser/sessions/session_id.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // Reassociates a single tab with the sync model. Will check if the tab | 118 // Reassociates a single tab with the sync model. Will check if the tab |
118 // already is associated with a sync node and allocate one if necessary. | 119 // already is associated with a sync node and allocate one if necessary. |
119 // Returns: false if the local session's sync nodes were deleted and | 120 // Returns: false if the local session's sync nodes were deleted and |
120 // reassociation is necessary, true otherwise. | 121 // reassociation is necessary, true otherwise. |
121 bool AssociateTab(const SyncedTabDelegate& tab); | 122 bool AssociateTab(const SyncedTabDelegate& tab); |
122 | 123 |
123 // Load any foreign session info stored in sync db and update the sync db | 124 // Load any foreign session info stored in sync db and update the sync db |
124 // with local client data. Processes/reuses any sync nodes owned by this | 125 // with local client data. Processes/reuses any sync nodes owned by this |
125 // client and creates any further sync nodes needed to store local header and | 126 // client and creates any further sync nodes needed to store local header and |
126 // tab info. | 127 // tab info. |
127 virtual bool AssociateModels(SyncError* error); | 128 virtual bool AssociateModels(SyncError* error) OVERRIDE; |
128 | 129 |
129 // Initializes the given sync node from the given chrome node id. | 130 // Initializes the given sync node from the given chrome node id. |
130 // Returns false if no sync node was found for the given chrome node id or | 131 // Returns false if no sync node was found for the given chrome node id or |
131 // if the initialization of sync node fails. | 132 // if the initialization of sync node fails. |
132 virtual bool InitSyncNodeFromChromeId(const std::string& id, | 133 virtual bool InitSyncNodeFromChromeId(const std::string& id, |
133 sync_api::BaseNode* sync_node); | 134 sync_api::BaseNode* sync_node); |
134 | 135 |
135 // Clear local sync data buffers. Does not delete sync nodes to avoid | 136 // Clear local sync data buffers. Does not delete sync nodes to avoid |
136 // tombstones. TODO(zea): way to eventually delete orphaned nodes. | 137 // tombstones. TODO(zea): way to eventually delete orphaned nodes. |
137 virtual bool DisassociateModels(SyncError* error); | 138 virtual bool DisassociateModels(SyncError* error) OVERRIDE; |
138 | 139 |
139 // Returns the tag used to uniquely identify this machine's session in the | 140 // Returns the tag used to uniquely identify this machine's session in the |
140 // sync model. | 141 // sync model. |
141 const std::string& GetCurrentMachineTag() const { | 142 const std::string& GetCurrentMachineTag() const { |
142 DCHECK(!current_machine_tag_.empty()); | 143 DCHECK(!current_machine_tag_.empty()); |
143 return current_machine_tag_; | 144 return current_machine_tag_; |
144 } | 145 } |
145 | 146 |
146 // Load and associate window and tab data for a foreign session | 147 // Load and associate window and tab data for a foreign session |
147 bool AssociateForeignSpecifics(const sync_pb::SessionSpecifics& specifics, | 148 bool AssociateForeignSpecifics(const sync_pb::SessionSpecifics& specifics, |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // is made. | 479 // is made. |
479 bool waiting_for_change_; | 480 bool waiting_for_change_; |
480 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; | 481 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; |
481 | 482 |
482 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 483 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
483 }; | 484 }; |
484 | 485 |
485 } // namespace browser_sync | 486 } // namespace browser_sync |
486 | 487 |
487 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 488 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
OLD | NEW |