OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_service.h" | 5 #include "components/sync_driver/device_info_service.h" |
6 | 6 |
| 7 #include <utility> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "sync/api/model_type_change_processor.h" | 11 #include "sync/api/model_type_change_processor.h" |
11 #include "sync/api/sync_error.h" | 12 #include "sync/api/sync_error.h" |
12 #include "sync/protocol/sync.pb.h" | 13 #include "sync/protocol/sync.pb.h" |
13 #include "sync/util/time.h" | 14 #include "sync/util/time.h" |
14 | 15 |
15 namespace sync_driver_v2 { | 16 namespace sync_driver_v2 { |
16 | 17 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 94 } |
94 | 95 |
95 ScopedVector<DeviceInfo> DeviceInfoService::GetAllDeviceInfo() const { | 96 ScopedVector<DeviceInfo> DeviceInfoService::GetAllDeviceInfo() const { |
96 ScopedVector<DeviceInfo> list; | 97 ScopedVector<DeviceInfo> list; |
97 | 98 |
98 for (ClientIdToSpecifics::const_iterator iter = all_data_.begin(); | 99 for (ClientIdToSpecifics::const_iterator iter = all_data_.begin(); |
99 iter != all_data_.end(); ++iter) { | 100 iter != all_data_.end(); ++iter) { |
100 list.push_back(CreateDeviceInfo(*iter->second)); | 101 list.push_back(CreateDeviceInfo(*iter->second)); |
101 } | 102 } |
102 | 103 |
103 return list.Pass(); | 104 return list; |
104 } | 105 } |
105 | 106 |
106 void DeviceInfoService::AddObserver(Observer* observer) { | 107 void DeviceInfoService::AddObserver(Observer* observer) { |
107 observers_.AddObserver(observer); | 108 observers_.AddObserver(observer); |
108 } | 109 } |
109 | 110 |
110 void DeviceInfoService::RemoveObserver(Observer* observer) { | 111 void DeviceInfoService::RemoveObserver(Observer* observer) { |
111 observers_.RemoveObserver(observer); | 112 observers_.RemoveObserver(observer); |
112 } | 113 } |
113 | 114 |
(...skipping 11 matching lines...) Expand all Loading... |
125 // TODO(skym): Should this be a less than instead of not equal check? | 126 // TODO(skym): Should this be a less than instead of not equal check? |
126 if (GetLocalDeviceBackupTime() != backup_time) { | 127 if (GetLocalDeviceBackupTime() != backup_time) { |
127 // TODO(skym): Storing this field doesn't really make sense, remove. | 128 // TODO(skym): Storing this field doesn't really make sense, remove. |
128 set_local_device_backup_time(syncer::TimeToProtoTime(backup_time)); | 129 set_local_device_backup_time(syncer::TimeToProtoTime(backup_time)); |
129 scoped_ptr<DeviceInfoSpecifics> new_specifics = CreateLocalSpecifics(); | 130 scoped_ptr<DeviceInfoSpecifics> new_specifics = CreateLocalSpecifics(); |
130 | 131 |
131 // TODO(skym): Create correct update datastructure, such as EntityChange, | 132 // TODO(skym): Create correct update datastructure, such as EntityChange, |
132 // EntityMetadata, or CommitRequestData. | 133 // EntityMetadata, or CommitRequestData. |
133 // TODO(skym): Call ProcessChanges on SMTP. | 134 // TODO(skym): Call ProcessChanges on SMTP. |
134 // TODO(skym): Persist metadata and data. | 135 // TODO(skym): Persist metadata and data. |
135 StoreSpecifics(new_specifics.Pass()); | 136 StoreSpecifics(std::move(new_specifics)); |
136 } | 137 } |
137 | 138 |
138 // Don't call NotifyObservers() because backup time is not part of | 139 // Don't call NotifyObservers() because backup time is not part of |
139 // DeviceInfoTracker interface. | 140 // DeviceInfoTracker interface. |
140 } | 141 } |
141 | 142 |
142 base::Time DeviceInfoService::GetLocalDeviceBackupTime() const { | 143 base::Time DeviceInfoService::GetLocalDeviceBackupTime() const { |
143 return has_local_device_backup_time() | 144 return has_local_device_backup_time() |
144 ? syncer::ProtoTimeToTime(local_device_backup_time()) | 145 ? syncer::ProtoTimeToTime(local_device_backup_time()) |
145 : base::Time(); | 146 : base::Time(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 << " with ID " << client_id; | 196 << " with ID " << client_id; |
196 all_data_.erase(iter); | 197 all_data_.erase(iter); |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 void DeviceInfoService::OnProviderInitialized() { | 201 void DeviceInfoService::OnProviderInitialized() { |
201 // TODO(skym): Do we need this? | 202 // TODO(skym): Do we need this? |
202 } | 203 } |
203 | 204 |
204 } // namespace sync_driver_v2 | 205 } // namespace sync_driver_v2 |
OLD | NEW |