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 "chrome/browser/sync/sessions/sessions_sync_manager.h" | 5 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sync/glue/local_device_info_provider.h" | 9 #include "chrome/browser/sync/glue/local_device_info_provider.h" |
10 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | 10 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 // First, we iterate over sync data to update our session_tracker_. | 116 // First, we iterate over sync data to update our session_tracker_. |
117 syncer::SyncDataList restored_tabs; | 117 syncer::SyncDataList restored_tabs; |
118 if (!InitFromSyncModel(initial_sync_data, &restored_tabs, &new_changes)) { | 118 if (!InitFromSyncModel(initial_sync_data, &restored_tabs, &new_changes)) { |
119 // The sync db didn't have a header node for us. Create one. | 119 // The sync db didn't have a header node for us. Create one. |
120 sync_pb::EntitySpecifics specifics; | 120 sync_pb::EntitySpecifics specifics; |
121 sync_pb::SessionSpecifics* base_specifics = specifics.mutable_session(); | 121 sync_pb::SessionSpecifics* base_specifics = specifics.mutable_session(); |
122 base_specifics->set_session_tag(current_machine_tag()); | 122 base_specifics->set_session_tag(current_machine_tag()); |
123 sync_pb::SessionHeader* header_s = base_specifics->mutable_header(); | 123 sync_pb::SessionHeader* header_s = base_specifics->mutable_header(); |
124 header_s->set_client_name(current_session_name_); | 124 header_s->set_client_name(current_session_name_); |
125 header_s->set_device_type(DeviceInfo::GetLocalDeviceType()); | 125 header_s->set_device_type(local_device_info->device_type()); |
126 syncer::SyncData data = syncer::SyncData::CreateLocalData( | 126 syncer::SyncData data = syncer::SyncData::CreateLocalData( |
127 current_machine_tag(), current_session_name_, specifics); | 127 current_machine_tag(), current_session_name_, specifics); |
128 new_changes.push_back(syncer::SyncChange( | 128 new_changes.push_back(syncer::SyncChange( |
129 FROM_HERE, syncer::SyncChange::ACTION_ADD, data)); | 129 FROM_HERE, syncer::SyncChange::ACTION_ADD, data)); |
130 } | 130 } |
131 | 131 |
132 #if defined(OS_ANDROID) | 132 #if defined(OS_ANDROID) |
133 std::string sync_machine_tag(BuildMachineTag( | 133 std::string sync_machine_tag(BuildMachineTag( |
134 local_device_->GetLocalSyncCacheGUID())); | 134 local_device_->GetLocalSyncCacheGUID())); |
135 if (current_machine_tag_.compare(sync_machine_tag) != 0) | 135 if (current_machine_tag_.compare(sync_machine_tag) != 0) |
(...skipping 15 matching lines...) Expand all Loading... |
151 ReloadTabsOption option, | 151 ReloadTabsOption option, |
152 const syncer::SyncDataList& restored_tabs, | 152 const syncer::SyncDataList& restored_tabs, |
153 syncer::SyncChangeList* change_output) { | 153 syncer::SyncChangeList* change_output) { |
154 const std::string local_tag = current_machine_tag(); | 154 const std::string local_tag = current_machine_tag(); |
155 sync_pb::SessionSpecifics specifics; | 155 sync_pb::SessionSpecifics specifics; |
156 specifics.set_session_tag(local_tag); | 156 specifics.set_session_tag(local_tag); |
157 sync_pb::SessionHeader* header_s = specifics.mutable_header(); | 157 sync_pb::SessionHeader* header_s = specifics.mutable_header(); |
158 SyncedSession* current_session = session_tracker_.GetSession(local_tag); | 158 SyncedSession* current_session = session_tracker_.GetSession(local_tag); |
159 current_session->modified_time = base::Time::Now(); | 159 current_session->modified_time = base::Time::Now(); |
160 header_s->set_client_name(current_session_name_); | 160 header_s->set_client_name(current_session_name_); |
161 header_s->set_device_type(DeviceInfo::GetLocalDeviceType()); | 161 // SessionDataTypeController ensures that the local device info |
| 162 // is available before activating this datatype. |
| 163 DCHECK(local_device_); |
| 164 const DeviceInfo* local_device_info = local_device_->GetLocalDeviceInfo(); |
| 165 header_s->set_device_type(local_device_info->device_type()); |
162 | 166 |
163 session_tracker_.ResetSessionTracking(local_tag); | 167 session_tracker_.ResetSessionTracking(local_tag); |
164 std::set<SyncedWindowDelegate*> windows = | 168 std::set<SyncedWindowDelegate*> windows = |
165 synced_window_getter_->GetSyncedWindowDelegates(); | 169 synced_window_getter_->GetSyncedWindowDelegates(); |
166 | 170 |
167 for (std::set<SyncedWindowDelegate*>::const_iterator i = | 171 for (std::set<SyncedWindowDelegate*>::const_iterator i = |
168 windows.begin(); i != windows.end(); ++i) { | 172 windows.begin(); i != windows.end(); ++i) { |
169 // Make sure the window has tabs and a viewable window. The viewable window | 173 // Make sure the window has tabs and a viewable window. The viewable window |
170 // check is necessary because, for example, when a browser is closed the | 174 // check is necessary because, for example, when a browser is closed the |
171 // destructor is not necessarily run immediately. This means its possible | 175 // destructor is not necessarily run immediately. This means its possible |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 << " with age " << session_age_in_days << ", deleting."; | 1033 << " with age " << session_age_in_days << ", deleting."; |
1030 DeleteForeignSessionInternal(session_tag, &changes); | 1034 DeleteForeignSessionInternal(session_tag, &changes); |
1031 } | 1035 } |
1032 } | 1036 } |
1033 | 1037 |
1034 if (!changes.empty()) | 1038 if (!changes.empty()) |
1035 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 1039 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
1036 } | 1040 } |
1037 | 1041 |
1038 }; // namespace browser_sync | 1042 }; // namespace browser_sync |
OLD | NEW |