Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: components/sync/device_info/device_info_service.cc

Issue 2416823003: [Sync] Move some things from core/ to model(_impl)/. (Closed)
Patch Set: Rebase. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/device_info/device_info_service.h" 5 #include "components/sync/device_info/device_info_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "components/sync/base/time.h" 15 #include "components/sync/base/time.h"
16 #include "components/sync/core/data_batch_impl.h"
17 #include "components/sync/device_info/device_info_util.h" 16 #include "components/sync/device_info/device_info_util.h"
18 #include "components/sync/model/entity_change.h" 17 #include "components/sync/model/entity_change.h"
19 #include "components/sync/model/metadata_batch.h" 18 #include "components/sync/model/metadata_batch.h"
19 #include "components/sync/model/mutable_data_batch.h"
20 #include "components/sync/model/sync_error.h" 20 #include "components/sync/model/sync_error.h"
21 #include "components/sync/protocol/model_type_state.pb.h" 21 #include "components/sync/protocol/model_type_state.pb.h"
22 #include "components/sync/protocol/sync.pb.h" 22 #include "components/sync/protocol/sync.pb.h"
23 23
24 namespace syncer { 24 namespace syncer {
25 25
26 using base::Time; 26 using base::Time;
27 using base::TimeDelta; 27 using base::TimeDelta;
28 using sync_pb::DeviceInfoSpecifics; 28 using sync_pb::DeviceInfoSpecifics;
29 using sync_pb::EntitySpecifics; 29 using sync_pb::EntitySpecifics;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 } 145 }
146 146
147 CommitAndNotify(std::move(batch), std::move(metadata_change_list), 147 CommitAndNotify(std::move(batch), std::move(metadata_change_list),
148 has_changes); 148 has_changes);
149 return SyncError(); 149 return SyncError();
150 } 150 }
151 151
152 void DeviceInfoService::GetData(StorageKeyList storage_keys, 152 void DeviceInfoService::GetData(StorageKeyList storage_keys,
153 DataCallback callback) { 153 DataCallback callback) {
154 std::unique_ptr<DataBatchImpl> batch(new DataBatchImpl()); 154 auto batch = base::MakeUnique<MutableDataBatch>();
155 for (const auto& key : storage_keys) { 155 for (const auto& key : storage_keys) {
156 const auto& iter = all_data_.find(key); 156 const auto& iter = all_data_.find(key);
157 if (iter != all_data_.end()) { 157 if (iter != all_data_.end()) {
158 DCHECK_EQ(key, iter->second->cache_guid()); 158 DCHECK_EQ(key, iter->second->cache_guid());
159 batch->Put(key, CopyToEntityData(*iter->second)); 159 batch->Put(key, CopyToEntityData(*iter->second));
160 } 160 }
161 } 161 }
162 callback.Run(SyncError(), std::move(batch)); 162 callback.Run(SyncError(), std::move(batch));
163 } 163 }
164 164
165 void DeviceInfoService::GetAllData(DataCallback callback) { 165 void DeviceInfoService::GetAllData(DataCallback callback) {
166 std::unique_ptr<DataBatchImpl> batch(new DataBatchImpl()); 166 auto batch = base::MakeUnique<MutableDataBatch>();
167 for (const auto& kv : all_data_) { 167 for (const auto& kv : all_data_) {
168 batch->Put(kv.first, CopyToEntityData(*kv.second)); 168 batch->Put(kv.first, CopyToEntityData(*kv.second));
169 } 169 }
170 callback.Run(SyncError(), std::move(batch)); 170 callback.Run(SyncError(), std::move(batch));
171 } 171 }
172 172
173 std::string DeviceInfoService::GetClientTag(const EntityData& entity_data) { 173 std::string DeviceInfoService::GetClientTag(const EntityData& entity_data) {
174 DCHECK(entity_data.specifics.has_device_info()); 174 DCHECK(entity_data.specifics.has_device_info());
175 return DeviceInfoUtil::SpecificsToTag(entity_data.specifics.device_info()); 175 return DeviceInfoUtil::SpecificsToTag(entity_data.specifics.device_info());
176 } 176 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 Time DeviceInfoService::GetLastUpdateTime( 459 Time DeviceInfoService::GetLastUpdateTime(
460 const DeviceInfoSpecifics& specifics) { 460 const DeviceInfoSpecifics& specifics) {
461 if (specifics.has_last_updated_timestamp()) { 461 if (specifics.has_last_updated_timestamp()) {
462 return ProtoTimeToTime(specifics.last_updated_timestamp()); 462 return ProtoTimeToTime(specifics.last_updated_timestamp());
463 } else { 463 } else {
464 return Time(); 464 return Time();
465 } 465 }
466 } 466 }
467 467
468 } // namespace syncer 468 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/device_info/device_info_service.h ('k') | components/sync/device_info/device_info_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698