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