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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // local machine. Used primarily for testing. | 150 // local machine. Used primarily for testing. |
151 bool GetLocalSession(const SyncedSession* * local_session); | 151 bool GetLocalSession(const SyncedSession* * local_session); |
152 | 152 |
153 // Builds a list of all foreign sessions. | 153 // Builds a list of all foreign sessions. |
154 // Caller does NOT own ForeignSession objects. | 154 // Caller does NOT own ForeignSession objects. |
155 bool GetAllForeignSessions(std::vector<const SyncedSession*>* sessions); | 155 bool GetAllForeignSessions(std::vector<const SyncedSession*>* sessions); |
156 | 156 |
157 // Loads all windows for foreign session with session tag |tag|. | 157 // Loads all windows for foreign session with session tag |tag|. |
158 // Caller does NOT own SyncedSession objects. | 158 // Caller does NOT own SyncedSession objects. |
159 bool GetForeignSession(const std::string& tag, | 159 bool GetForeignSession(const std::string& tag, |
160 std::vector<SessionWindow*>* windows); | 160 std::vector<const SessionWindow*>* windows); |
161 | 161 |
162 // Looks up the foreign tab identified by |tab_id| and belonging to foreign | 162 // Looks up the foreign tab identified by |tab_id| and belonging to foreign |
163 // session |tag|. | 163 // session |tag|. |
164 // Caller does NOT own the SessionTab object. | 164 // Caller does NOT own the SessionTab object. |
165 bool GetForeignTab(const std::string& tag, | 165 bool GetForeignTab(const std::string& tag, |
166 const SessionID::id_type tab_id, | 166 const SessionID::id_type tab_id, |
167 const SessionTab** tab); | 167 const SessionTab** tab); |
168 | 168 |
169 // Specifies whether the window has tabs to sync. The new tab page does not | |
170 // count. If no tabs to sync, it returns true, otherwise false; | |
171 static bool SessionWindowHasNoTabsToSync(const SessionWindow& window); | |
172 | |
173 // Control which local tabs we're interested in syncing. | 169 // Control which local tabs we're interested in syncing. |
174 // Ensures the profile matches sync's profile and that the tab has at least | 170 // Ensures the profile matches sync's profile and that the tab has at least |
175 // one navigation entry and is not an empty tab. | 171 // one navigation entry and is not an empty tab. |
176 bool IsValidTab(const SyncedTabDelegate& tab); | 172 bool IsValidTab(const SyncedTabDelegate& tab) const; |
177 | |
178 // Control which foreign tabs we're interested in displaying. | |
179 // Checks that the tab has navigations and is not a new tab. | |
180 // Note: a new tab page with back/forward history is valid. | |
181 static bool IsValidSessionTab(const SessionTab& tab); | |
182 | 173 |
183 // Returns the syncable model type. | 174 // Returns the syncable model type. |
184 static syncable::ModelType model_type() { return syncable::SESSIONS; } | 175 static syncable::ModelType model_type() { return syncable::SESSIONS; } |
185 | 176 |
186 // Testing only. Will cause the associator to call MessageLoop::Quit() | 177 // Testing only. Will cause the associator to call MessageLoop::Quit() |
187 // when a local change is made, or when timeout_milli occurs, whichever is | 178 // when a local change is made, or when timeout_milli occurs, whichever is |
188 // first. | 179 // first. |
189 void BlockUntilLocalChangeForTest(int64 timeout_milli); | 180 void BlockUntilLocalChangeForTest(int64 timeout_milli); |
190 | 181 |
191 // Callback for when the session name has been computed. | 182 // Callback for when the session name has been computed. |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // is made. | 450 // is made. |
460 bool waiting_for_change_; | 451 bool waiting_for_change_; |
461 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; | 452 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; |
462 | 453 |
463 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 454 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
464 }; | 455 }; |
465 | 456 |
466 } // namespace browser_sync | 457 } // namespace browser_sync |
467 | 458 |
468 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 459 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
OLD | NEW |