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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 int64 SessionModelAssociator::GetSyncIdFromSessionTag(const std::string& tag) { | 75 int64 SessionModelAssociator::GetSyncIdFromSessionTag(const std::string& tag) { |
76 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
77 sync_api::ReadTransaction trans(sync_service_->GetUserShare()); | 77 sync_api::ReadTransaction trans(sync_service_->GetUserShare()); |
78 sync_api::ReadNode node(&trans); | 78 sync_api::ReadNode node(&trans); |
79 if (!node.InitByClientTagLookup(syncable::SESSIONS, tag)) | 79 if (!node.InitByClientTagLookup(syncable::SESSIONS, tag)) |
80 return sync_api::kInvalidId; | 80 return sync_api::kInvalidId; |
81 return node.GetId(); | 81 return node.GetId(); |
82 } | 82 } |
| 83 |
| 84 const TabContents* |
| 85 SessionModelAssociator::GetChromeNodeFromSyncId(int64 sync_id) { |
| 86 NOTREACHED(); |
| 87 return NULL; |
| 88 } |
| 89 |
| 90 bool SessionModelAssociator::InitSyncNodeFromChromeId( |
| 91 const size_t& id, |
| 92 sync_api::BaseNode* sync_node) { |
| 93 NOTREACHED(); |
| 94 return false; |
| 95 } |
| 96 |
83 void SessionModelAssociator::ReassociateWindows(bool reload_tabs) { | 97 void SessionModelAssociator::ReassociateWindows(bool reload_tabs) { |
84 DCHECK(CalledOnValidThread()); | 98 DCHECK(CalledOnValidThread()); |
85 sync_pb::SessionSpecifics specifics; | 99 sync_pb::SessionSpecifics specifics; |
86 specifics.set_session_tag(GetCurrentMachineTag()); | 100 specifics.set_session_tag(GetCurrentMachineTag()); |
87 sync_pb::SessionHeader* header_s = specifics.mutable_header(); | 101 sync_pb::SessionHeader* header_s = specifics.mutable_header(); |
88 | 102 |
89 for (BrowserList::const_iterator i = BrowserList::begin(); | 103 for (BrowserList::const_iterator i = BrowserList::begin(); |
90 i != BrowserList::end(); ++i) { | 104 i != BrowserList::end(); ++i) { |
91 // Make sure the browser has tabs and a window. Browsers destructor | 105 // Make sure the browser has tabs and a window. Browsers destructor |
92 // removes itself from the BrowserList. When a browser is closed the | 106 // removes itself from the BrowserList. When a browser is closed the |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // Associate all open windows and their tabs. | 699 // Associate all open windows and their tabs. |
686 ReassociateWindows(true); | 700 ReassociateWindows(true); |
687 } | 701 } |
688 | 702 |
689 SessionModelAssociator::TabNodePool::TabNodePool( | 703 SessionModelAssociator::TabNodePool::TabNodePool( |
690 ProfileSyncService* sync_service) | 704 ProfileSyncService* sync_service) |
691 : tab_pool_fp_(-1), | 705 : tab_pool_fp_(-1), |
692 sync_service_(sync_service) { | 706 sync_service_(sync_service) { |
693 } | 707 } |
694 | 708 |
| 709 SessionModelAssociator::TabNodePool::~TabNodePool() {} |
| 710 |
695 void SessionModelAssociator::TabNodePool::AddTabNode(int64 sync_id) { | 711 void SessionModelAssociator::TabNodePool::AddTabNode(int64 sync_id) { |
696 tab_syncid_pool_.resize(tab_syncid_pool_.size() + 1); | 712 tab_syncid_pool_.resize(tab_syncid_pool_.size() + 1); |
697 tab_syncid_pool_[static_cast<size_t>(++tab_pool_fp_)] = sync_id; | 713 tab_syncid_pool_[static_cast<size_t>(++tab_pool_fp_)] = sync_id; |
698 } | 714 } |
699 | 715 |
700 int64 SessionModelAssociator::TabNodePool::GetFreeTabNode() { | 716 int64 SessionModelAssociator::TabNodePool::GetFreeTabNode() { |
701 DCHECK_GT(machine_tag_.length(), 0U); | 717 DCHECK_GT(machine_tag_.length(), 0U); |
702 if (tab_pool_fp_ == -1) { | 718 if (tab_pool_fp_ == -1) { |
703 // Tab pool has no free nodes, allocate new one. | 719 // Tab pool has no free nodes, allocate new one. |
704 sync_api::WriteTransaction trans(sync_service_->GetUserShare()); | 720 sync_api::WriteTransaction trans(sync_service_->GetUserShare()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 for (std::vector<TabNavigation>::const_iterator i = | 967 for (std::vector<TabNavigation>::const_iterator i = |
952 tab.navigations.begin(); i != tab.navigations.end(); ++i) { | 968 tab.navigations.begin(); i != tab.navigations.end(); ++i) { |
953 const TabNavigation navigation = *i; | 969 const TabNavigation navigation = *i; |
954 sync_pb::TabNavigation* tab_navigation = | 970 sync_pb::TabNavigation* tab_navigation = |
955 session_tab->add_navigation(); | 971 session_tab->add_navigation(); |
956 PopulateSessionSpecificsNavigation(&navigation, tab_navigation); | 972 PopulateSessionSpecificsNavigation(&navigation, tab_navigation); |
957 } | 973 } |
958 } | 974 } |
959 | 975 |
960 } // namespace browser_sync | 976 } // namespace browser_sync |
OLD | NEW |