OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/sync/glue/session_model_associator.h" | 5 #include "chrome/browser/sync/glue/session_model_associator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service) | 35 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service) |
36 : tab_pool_(sync_service), | 36 : tab_pool_(sync_service), |
37 local_session_syncid_(sync_api::kInvalidId), | 37 local_session_syncid_(sync_api::kInvalidId), |
38 sync_service_(sync_service) { | 38 sync_service_(sync_service) { |
39 DCHECK(CalledOnValidThread()); | 39 DCHECK(CalledOnValidThread()); |
40 DCHECK(sync_service_); | 40 DCHECK(sync_service_); |
41 } | 41 } |
42 | 42 |
| 43 SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service, |
| 44 bool setup_for_test) |
| 45 : tab_pool_(sync_service), |
| 46 local_session_syncid_(sync_api::kInvalidId), |
| 47 sync_service_(sync_service), |
| 48 setup_for_test_(setup_for_test) { |
| 49 DCHECK(CalledOnValidThread()); |
| 50 DCHECK(sync_service_); |
| 51 } |
| 52 |
43 SessionModelAssociator::~SessionModelAssociator() { | 53 SessionModelAssociator::~SessionModelAssociator() { |
44 DCHECK(CalledOnValidThread()); | 54 DCHECK(CalledOnValidThread()); |
45 } | 55 } |
46 | 56 |
47 bool SessionModelAssociator::InitSyncNodeFromChromeId( | 57 bool SessionModelAssociator::InitSyncNodeFromChromeId( |
48 const std::string& id, | 58 const std::string& id, |
49 sync_api::BaseNode* sync_node) { | 59 sync_api::BaseNode* sync_node) { |
50 NOTREACHED(); | 60 NOTREACHED(); |
51 return false; | 61 return false; |
52 } | 62 } |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 DCHECK(tab_pool_.full()); | 496 DCHECK(tab_pool_.full()); |
487 | 497 |
488 return true; | 498 return true; |
489 } | 499 } |
490 | 500 |
491 bool SessionModelAssociator::AssociateForeignSpecifics( | 501 bool SessionModelAssociator::AssociateForeignSpecifics( |
492 const sync_pb::SessionSpecifics& specifics, | 502 const sync_pb::SessionSpecifics& specifics, |
493 const int64 modification_time) { | 503 const int64 modification_time) { |
494 DCHECK(CalledOnValidThread()); | 504 DCHECK(CalledOnValidThread()); |
495 std::string foreign_session_tag = specifics.session_tag(); | 505 std::string foreign_session_tag = specifics.session_tag(); |
496 DCHECK(foreign_session_tag != GetCurrentMachineTag() || | 506 DCHECK(foreign_session_tag != GetCurrentMachineTag() || setup_for_test_); |
497 sync_service_->cros_user() == "test user"); // For tests. | |
498 | 507 |
499 if (specifics.has_header()) { | 508 if (specifics.has_header()) { |
500 // Read in the header data for this foreign session. | 509 // Read in the header data for this foreign session. |
501 // Header data contains window information and ordered tab id's for each | 510 // Header data contains window information and ordered tab id's for each |
502 // window. | 511 // window. |
503 | 512 |
504 // Load (or create) the ForeignSession object for this client. | 513 // Load (or create) the ForeignSession object for this client. |
505 ForeignSession* foreign_session = | 514 ForeignSession* foreign_session = |
506 foreign_session_tracker_.GetForeignSession(foreign_session_tag); | 515 foreign_session_tracker_.GetForeignSession(foreign_session_tag); |
507 | 516 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 for (std::vector<TabNavigation>::const_iterator i = | 976 for (std::vector<TabNavigation>::const_iterator i = |
968 tab.navigations.begin(); i != tab.navigations.end(); ++i) { | 977 tab.navigations.begin(); i != tab.navigations.end(); ++i) { |
969 const TabNavigation navigation = *i; | 978 const TabNavigation navigation = *i; |
970 sync_pb::TabNavigation* tab_navigation = | 979 sync_pb::TabNavigation* tab_navigation = |
971 session_tab->add_navigation(); | 980 session_tab->add_navigation(); |
972 PopulateSessionSpecificsNavigation(&navigation, tab_navigation); | 981 PopulateSessionSpecificsNavigation(&navigation, tab_navigation); |
973 } | 982 } |
974 } | 983 } |
975 | 984 |
976 } // namespace browser_sync | 985 } // namespace browser_sync |
OLD | NEW |