| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync_sessions/sessions_sync_manager.h" | 5 #include "components/sync_sessions/sessions_sync_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 it != tab_node_ids.end(); ++it) { | 99 it != tab_node_ids.end(); ++it) { |
| 100 change_output->push_back(syncer::SyncChange( | 100 change_output->push_back(syncer::SyncChange( |
| 101 FROM_HERE, SyncChange::ACTION_DELETE, | 101 FROM_HERE, SyncChange::ACTION_DELETE, |
| 102 SyncData::CreateLocalDelete(TabNodeIdToTag(machine_tag, *it), | 102 SyncData::CreateLocalDelete(TabNodeIdToTag(machine_tag, *it), |
| 103 syncer::SESSIONS))); | 103 syncer::SESSIONS))); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Ensure that the tab id is not invalid. | 107 // Ensure that the tab id is not invalid. |
| 108 bool ShouldSyncTabId(SessionID::id_type tab_id) { | 108 bool ShouldSyncTabId(SessionID::id_type tab_id) { |
| 109 if (tab_id == TabNodePool::kInvalidTabID) | 109 if (tab_id == kInvalidTabID) |
| 110 return false; | 110 return false; |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace | 114 } // namespace |
| 115 | 115 |
| 116 // |local_device| is owned by ProfileSyncService, its lifetime exceeds | 116 // |local_device| is owned by ProfileSyncService, its lifetime exceeds |
| 117 // lifetime of SessionSyncManager. | 117 // lifetime of SessionSyncManager. |
| 118 SessionsSyncManager::SessionsSyncManager( | 118 SessionsSyncManager::SessionsSyncManager( |
| 119 sync_sessions::SyncSessionsClient* sessions_client, | 119 sync_sessions::SyncSessionsClient* sessions_client, |
| 120 syncer::SyncPrefs* sync_prefs, | 120 syncer::SyncPrefs* sync_prefs, |
| 121 LocalDeviceInfoProvider* local_device, | 121 LocalDeviceInfoProvider* local_device, |
| 122 std::unique_ptr<LocalSessionEventRouter> router, | 122 LocalSessionEventRouter* router, |
| 123 const base::Closure& sessions_updated_callback, | 123 const base::Closure& sessions_updated_callback, |
| 124 const base::Closure& datatype_refresh_callback) | 124 const base::Closure& datatype_refresh_callback) |
| 125 : sessions_client_(sessions_client), | 125 : sessions_client_(sessions_client), |
| 126 session_tracker_(sessions_client), | 126 session_tracker_(sessions_client), |
| 127 favicon_cache_(sessions_client->GetFaviconService(), | 127 favicon_cache_(sessions_client->GetFaviconService(), |
| 128 sessions_client->GetHistoryService(), | 128 sessions_client->GetHistoryService(), |
| 129 kMaxSyncFavicons), | 129 kMaxSyncFavicons), |
| 130 local_tab_pool_out_of_sync_(true), | 130 local_tab_pool_out_of_sync_(true), |
| 131 sync_prefs_(sync_prefs), | 131 sync_prefs_(sync_prefs), |
| 132 local_device_(local_device), | 132 local_device_(local_device), |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 // TODO(zea): crbug.com/639009 update the tracker with the specifics | 674 // TODO(zea): crbug.com/639009 update the tracker with the specifics |
| 675 // from the header node as well. This will be necessary to preserve | 675 // from the header node as well. This will be necessary to preserve |
| 676 // the set of open tabs when a custom tab is opened. | 676 // the set of open tabs when a custom tab is opened. |
| 677 } else { | 677 } else { |
| 678 if (specifics.has_header() || !specifics.has_tab()) { | 678 if (specifics.has_header() || !specifics.has_tab()) { |
| 679 LOG(WARNING) << "Found more than one session header node with local " | 679 LOG(WARNING) << "Found more than one session header node with local " |
| 680 << "tag."; | 680 << "tag."; |
| 681 syncer::SyncChange tombstone(TombstoneTab(specifics)); | 681 syncer::SyncChange tombstone(TombstoneTab(specifics)); |
| 682 if (tombstone.IsValid()) | 682 if (tombstone.IsValid()) |
| 683 new_changes->push_back(tombstone); | 683 new_changes->push_back(tombstone); |
| 684 } else if (specifics.tab().tab_id() == TabNodePool::kInvalidTabID) { | 684 } else if (specifics.tab().tab_id() == kInvalidTabID) { |
| 685 LOG(WARNING) << "Found tab node with invalid tab id."; | 685 LOG(WARNING) << "Found tab node with invalid tab id."; |
| 686 syncer::SyncChange tombstone(TombstoneTab(specifics)); | 686 syncer::SyncChange tombstone(TombstoneTab(specifics)); |
| 687 if (tombstone.IsValid()) | 687 if (tombstone.IsValid()) |
| 688 new_changes->push_back(tombstone); | 688 new_changes->push_back(tombstone); |
| 689 } else { | 689 } else { |
| 690 // This is a valid old tab node, add it to the tracker and associate | 690 // This is a valid old tab node, add it to the tracker and associate |
| 691 // it. | 691 // it. |
| 692 DVLOG(1) << "Associating local tab " << specifics.tab().tab_id() | 692 DVLOG(1) << "Associating local tab " << specifics.tab().tab_id() |
| 693 << " with node " << specifics.tab_node_id(); | 693 << " with node " << specifics.tab_node_id(); |
| 694 session_tracker_.ReassociateLocalTab(specifics.tab_node_id(), | 694 session_tracker_.ReassociateLocalTab(specifics.tab_node_id(), |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 // static | 1141 // static |
| 1142 std::string SessionsSyncManager::TagHashFromSpecifics( | 1142 std::string SessionsSyncManager::TagHashFromSpecifics( |
| 1143 const sync_pb::SessionSpecifics& specifics) { | 1143 const sync_pb::SessionSpecifics& specifics) { |
| 1144 return syncer::GenerateSyncableHash(syncer::SESSIONS, | 1144 return syncer::GenerateSyncableHash(syncer::SESSIONS, |
| 1145 TagFromSpecifics(specifics)); | 1145 TagFromSpecifics(specifics)); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 }; // namespace sync_sessions | 1148 }; // namespace sync_sessions |
| OLD | NEW |