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/format_macros.h" | 14 #include "base/format_macros.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
19 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
| 21 #include "base/time.h" |
21 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
22 #include "chrome/browser/sessions/session_id.h" | 23 #include "chrome/browser/sessions/session_id.h" |
23 #include "chrome/browser/sessions/session_service.h" | 24 #include "chrome/browser/sessions/session_service.h" |
24 #include "chrome/browser/sessions/session_types.h" | 25 #include "chrome/browser/sessions/session_types.h" |
25 #include "chrome/browser/sync/glue/model_associator.h" | 26 #include "chrome/browser/sync/glue/model_associator.h" |
26 #include "chrome/browser/sync/glue/synced_session_tracker.h" | 27 #include "chrome/browser/sync/glue/synced_session_tracker.h" |
27 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | 28 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
28 #include "chrome/browser/sync/glue/synced_window_delegate.h" | 29 #include "chrome/browser/sync/glue/synced_window_delegate.h" |
29 #include "chrome/browser/sync/protocol/session_specifics.pb.h" | 30 #include "chrome/browser/sync/protocol/session_specifics.pb.h" |
30 #include "chrome/browser/sync/syncable/model_type.h" | 31 #include "chrome/browser/sync/syncable/model_type.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 134 |
134 // Returns the tag used to uniquely identify this machine's session in the | 135 // Returns the tag used to uniquely identify this machine's session in the |
135 // sync model. | 136 // sync model. |
136 inline const std::string& GetCurrentMachineTag() { | 137 inline const std::string& GetCurrentMachineTag() { |
137 DCHECK(!current_machine_tag_.empty()); | 138 DCHECK(!current_machine_tag_.empty()); |
138 return current_machine_tag_; | 139 return current_machine_tag_; |
139 } | 140 } |
140 | 141 |
141 // Load and associate window and tab data for a foreign session | 142 // Load and associate window and tab data for a foreign session |
142 bool AssociateForeignSpecifics(const sync_pb::SessionSpecifics& specifics, | 143 bool AssociateForeignSpecifics(const sync_pb::SessionSpecifics& specifics, |
143 int64 modification_time); | 144 const base::Time& modification_time); |
144 | 145 |
145 // Removes a foreign session from our internal bookkeeping. | 146 // Removes a foreign session from our internal bookkeeping. |
146 void DisassociateForeignSession(const std::string& foreign_session_tag); | 147 void DisassociateForeignSession(const std::string& foreign_session_tag); |
147 | 148 |
148 // Sets |*local_session| to point to the associator's representation of the | 149 // Sets |*local_session| to point to the associator's representation of the |
149 // local machine. Used primarily for testing. | 150 // local machine. Used primarily for testing. |
150 bool GetLocalSession(const SyncedSession* * local_session); | 151 bool GetLocalSession(const SyncedSession* * local_session); |
151 | 152 |
152 // Builds a list of all foreign sessions. | 153 // Builds a list of all foreign sessions. |
153 // Caller does NOT own ForeignSession objects. | 154 // Caller does NOT own ForeignSession objects. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // provided. | 369 // provided. |
369 static void PopulateSessionHeaderFromSpecifics( | 370 static void PopulateSessionHeaderFromSpecifics( |
370 const sync_pb::SessionHeader& header_specifics, | 371 const sync_pb::SessionHeader& header_specifics, |
371 SyncedSession* session_header); | 372 SyncedSession* session_header); |
372 | 373 |
373 // Used to populate a session window from the session specifics window | 374 // Used to populate a session window from the session specifics window |
374 // provided. Tracks any foreign session data created through |tracker|. | 375 // provided. Tracks any foreign session data created through |tracker|. |
375 static void PopulateSessionWindowFromSpecifics( | 376 static void PopulateSessionWindowFromSpecifics( |
376 const std::string& foreign_session_tag, | 377 const std::string& foreign_session_tag, |
377 const sync_pb::SessionWindow& window, | 378 const sync_pb::SessionWindow& window, |
378 const int64 mtime, | 379 const base::Time& mtime, |
379 SessionWindow* session_window, | 380 SessionWindow* session_window, |
380 SyncedSessionTracker* tracker); | 381 SyncedSessionTracker* tracker); |
381 | 382 |
382 // Used to populate a session tab from the session specifics tab provided. | 383 // Used to populate a session tab from the session specifics tab provided. |
383 static void PopulateSessionTabFromSpecifics(const sync_pb::SessionTab& tab, | 384 static void PopulateSessionTabFromSpecifics(const sync_pb::SessionTab& tab, |
384 const int64 mtime, | 385 const base::Time& mtime, |
385 SessionTab* session_tab); | 386 SessionTab* session_tab); |
386 | 387 |
387 // Used to populate a session tab from the session specifics tab provided. | 388 // Used to populate a session tab from the session specifics tab provided. |
388 static void AppendSessionTabNavigation( | 389 static void AppendSessionTabNavigation( |
389 const sync_pb::TabNavigation& navigation, | 390 const sync_pb::TabNavigation& navigation, |
390 std::vector<TabNavigation>* navigations); | 391 std::vector<TabNavigation>* navigations); |
391 | 392 |
392 // Populates the navigation portion of the session specifics. | 393 // Populates the navigation portion of the session specifics. |
393 static void PopulateSessionSpecificsNavigation( | 394 static void PopulateSessionSpecificsNavigation( |
394 const TabNavigation* navigation, | 395 const TabNavigation* navigation, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // is made. | 459 // is made. |
459 bool waiting_for_change_; | 460 bool waiting_for_change_; |
460 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; | 461 ScopedRunnableMethodFactory<SessionModelAssociator> test_method_factory_; |
461 | 462 |
462 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); | 463 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); |
463 }; | 464 }; |
464 | 465 |
465 } // namespace browser_sync | 466 } // namespace browser_sync |
466 | 467 |
467 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ | 468 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ |
OLD | NEW |