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_driver/device_info_sync_service.h" | 5 #include "components/sync_driver/device_info_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
11 #include "components/sync_driver/local_device_info_provider.h" | 12 #include "components/sync_driver/local_device_info_provider.h" |
12 #include "sync/api/sync_change.h" | 13 #include "sync/api/sync_change.h" |
13 #include "sync/protocol/sync.pb.h" | 14 #include "sync/protocol/sync.pb.h" |
14 #include "sync/util/time.h" | 15 #include "sync/util/time.h" |
15 | 16 |
16 namespace sync_driver { | 17 namespace sync_driver { |
17 | 18 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ModelType type, | 71 ModelType type, |
71 const SyncDataList& initial_sync_data, | 72 const SyncDataList& initial_sync_data, |
72 scoped_ptr<SyncChangeProcessor> sync_processor, | 73 scoped_ptr<SyncChangeProcessor> sync_processor, |
73 scoped_ptr<SyncErrorFactory> error_handler) { | 74 scoped_ptr<SyncErrorFactory> error_handler) { |
74 DCHECK(sync_processor.get()); | 75 DCHECK(sync_processor.get()); |
75 DCHECK(error_handler.get()); | 76 DCHECK(error_handler.get()); |
76 DCHECK_EQ(type, syncer::DEVICE_INFO); | 77 DCHECK_EQ(type, syncer::DEVICE_INFO); |
77 | 78 |
78 DCHECK(!IsSyncing()); | 79 DCHECK(!IsSyncing()); |
79 | 80 |
80 sync_processor_ = sync_processor.Pass(); | 81 sync_processor_ = std::move(sync_processor); |
81 error_handler_ = error_handler.Pass(); | 82 error_handler_ = std::move(error_handler); |
82 | 83 |
83 // Initialization should be completed before this type is enabled | 84 // Initialization should be completed before this type is enabled |
84 // and local device info must be available. | 85 // and local device info must be available. |
85 const DeviceInfo* local_device_info = | 86 const DeviceInfo* local_device_info = |
86 local_device_info_provider_->GetLocalDeviceInfo(); | 87 local_device_info_provider_->GetLocalDeviceInfo(); |
87 DCHECK(local_device_info != NULL); | 88 DCHECK(local_device_info != NULL); |
88 | 89 |
89 // Indicates whether a local device has been added or updated. | 90 // Indicates whether a local device has been added or updated. |
90 // |change_type| defaults to ADD and might be changed to | 91 // |change_type| defaults to ADD and might be changed to |
91 // UPDATE to INVALID down below if the initial data contains | 92 // UPDATE to INVALID down below if the initial data contains |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 262 |
262 ScopedVector<DeviceInfo> DeviceInfoSyncService::GetAllDeviceInfo() const { | 263 ScopedVector<DeviceInfo> DeviceInfoSyncService::GetAllDeviceInfo() const { |
263 ScopedVector<DeviceInfo> list; | 264 ScopedVector<DeviceInfo> list; |
264 | 265 |
265 for (SyncDataMap::const_iterator iter = all_data_.begin(); | 266 for (SyncDataMap::const_iterator iter = all_data_.begin(); |
266 iter != all_data_.end(); | 267 iter != all_data_.end(); |
267 ++iter) { | 268 ++iter) { |
268 list.push_back(CreateDeviceInfo(iter->second)); | 269 list.push_back(CreateDeviceInfo(iter->second)); |
269 } | 270 } |
270 | 271 |
271 return list.Pass(); | 272 return list; |
272 } | 273 } |
273 | 274 |
274 void DeviceInfoSyncService::AddObserver(Observer* observer) { | 275 void DeviceInfoSyncService::AddObserver(Observer* observer) { |
275 observers_.AddObserver(observer); | 276 observers_.AddObserver(observer); |
276 } | 277 } |
277 | 278 |
278 void DeviceInfoSyncService::RemoveObserver(Observer* observer) { | 279 void DeviceInfoSyncService::RemoveObserver(Observer* observer) { |
279 observers_.RemoveObserver(observer); | 280 observers_.RemoveObserver(observer); |
280 } | 281 } |
281 | 282 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 SyncDataMap::iterator iter = all_data_.find(client_id); | 388 SyncDataMap::iterator iter = all_data_.find(client_id); |
388 if (iter != all_data_.end()) { | 389 if (iter != all_data_.end()) { |
389 DVLOG(1) << "Deleting DEVICE_INFO for " | 390 DVLOG(1) << "Deleting DEVICE_INFO for " |
390 << iter->second.GetSpecifics().device_info().client_name() | 391 << iter->second.GetSpecifics().device_info().client_name() |
391 << " with ID " << client_id; | 392 << " with ID " << client_id; |
392 all_data_.erase(iter); | 393 all_data_.erase(iter); |
393 } | 394 } |
394 } | 395 } |
395 | 396 |
396 } // namespace sync_driver | 397 } // namespace sync_driver |
OLD | NEW |