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

Side by Side Diff: components/sync_driver/device_info_service.cc

Issue 1888923003: [Sync] DeviceInfoService should format ClientTag in backwards compatible way (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_driver/device_info_service.h" 5 #include "components/sync_driver/device_info_service.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
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/strings/string_util.h"
13 #include "sync/api/entity_change.h" 14 #include "sync/api/entity_change.h"
14 #include "sync/api/metadata_batch.h" 15 #include "sync/api/metadata_batch.h"
15 #include "sync/api/sync_error.h" 16 #include "sync/api/sync_error.h"
16 #include "sync/internal_api/public/data_batch_impl.h" 17 #include "sync/internal_api/public/data_batch_impl.h"
17 #include "sync/internal_api/public/simple_metadata_change_list.h" 18 #include "sync/internal_api/public/simple_metadata_change_list.h"
18 #include "sync/protocol/data_type_state.pb.h" 19 #include "sync/protocol/data_type_state.pb.h"
19 #include "sync/protocol/sync.pb.h" 20 #include "sync/protocol/sync.pb.h"
20 21
21 namespace sync_driver_v2 { 22 namespace sync_driver_v2 {
22 23
(...skipping 10 matching lines...) Expand all
33 using sync_driver::DeviceInfo; 34 using sync_driver::DeviceInfo;
34 using sync_pb::DataTypeState; 35 using sync_pb::DataTypeState;
35 using sync_pb::DeviceInfoSpecifics; 36 using sync_pb::DeviceInfoSpecifics;
36 using sync_pb::EntitySpecifics; 37 using sync_pb::EntitySpecifics;
37 38
38 using Record = ModelTypeStore::Record; 39 using Record = ModelTypeStore::Record;
39 using RecordList = ModelTypeStore::RecordList; 40 using RecordList = ModelTypeStore::RecordList;
40 using Result = ModelTypeStore::Result; 41 using Result = ModelTypeStore::Result;
41 using WriteBatch = ModelTypeStore::WriteBatch; 42 using WriteBatch = ModelTypeStore::WriteBatch;
42 43
44 const char kClientTagPrefix[] = "DeviceInfo_";
skym 2016/04/14 21:08:26 Can old and new device info services share this co
maxbogue 2016/04/14 22:30:13 Or at least it should be in an anonymous namespace
pavely 2016/04/14 23:37:23 It would be nice. The best shared place for declar
pavely 2016/04/14 23:37:23 Done.
45
43 DeviceInfoService::DeviceInfoService( 46 DeviceInfoService::DeviceInfoService(
44 sync_driver::LocalDeviceInfoProvider* local_device_info_provider, 47 sync_driver::LocalDeviceInfoProvider* local_device_info_provider,
45 const StoreFactoryFunction& callback, 48 const StoreFactoryFunction& callback,
46 const ChangeProcessorFactory& change_processor_factory) 49 const ChangeProcessorFactory& change_processor_factory)
47 : ModelTypeService(change_processor_factory, syncer::DEVICE_INFO), 50 : ModelTypeService(change_processor_factory, syncer::DEVICE_INFO),
48 local_device_info_provider_(local_device_info_provider), 51 local_device_info_provider_(local_device_info_provider),
49 weak_factory_(this) { 52 weak_factory_(this) {
50 DCHECK(local_device_info_provider); 53 DCHECK(local_device_info_provider);
51 54
52 // This is not threadsafe, but presuably the provider initializes on the same 55 // This is not threadsafe, but presuably the provider initializes on the same
(...skipping 25 matching lines...) Expand all
78 FROM_HERE, SyncError::DATATYPE_ERROR, 81 FROM_HERE, SyncError::DATATYPE_ERROR,
79 "Cannot call MergeSyncData without provider, data, and processor.", 82 "Cannot call MergeSyncData without provider, data, and processor.",
80 syncer::DEVICE_INFO); 83 syncer::DEVICE_INFO);
81 } 84 }
82 85
83 // Local data should typically be near empty, with the only possible value 86 // Local data should typically be near empty, with the only possible value
84 // corresponding to this device. This is because on signout all device info 87 // corresponding to this device. This is because on signout all device info
85 // data is blown away. However, this simplification is being ignored here and 88 // data is blown away. However, this simplification is being ignored here and
86 // a full difference is going to be calculated to explore what other service 89 // a full difference is going to be calculated to explore what other service
87 // implementations may look like. 90 // implementations may look like.
88 std::set<std::string> local_tags_to_put; 91 std::set<std::string> local_guids_to_put;
89 for (const auto& kv : all_data_) { 92 for (const auto& kv : all_data_) {
90 local_tags_to_put.insert(kv.first); 93 local_guids_to_put.insert(kv.first);
91 } 94 }
92 95
93 bool has_changes = false; 96 bool has_changes = false;
94 const DeviceInfo* local_info = 97 const DeviceInfo* local_info =
95 local_device_info_provider_->GetLocalDeviceInfo(); 98 local_device_info_provider_->GetLocalDeviceInfo();
96 std::string local_tag = local_info->guid(); 99 std::string local_guid = local_info->guid();
97 scoped_ptr<WriteBatch> batch = store_->CreateWriteBatch(); 100 scoped_ptr<WriteBatch> batch = store_->CreateWriteBatch();
98 for (const auto& kv : entity_data_map) { 101 for (const auto& kv : entity_data_map) {
99 const std::string tag = GetClientTag(kv.second.value());
100 const DeviceInfoSpecifics& specifics = 102 const DeviceInfoSpecifics& specifics =
101 kv.second.value().specifics.device_info(); 103 kv.second.value().specifics.device_info();
102 if (tag == local_tag) { 104 DCHECK_EQ(kv.first, SpecificsToTag(specifics));
105 if (specifics.cache_guid() == local_guid) {
103 // Don't Put local data if it's the same as the remote copy. 106 // Don't Put local data if it's the same as the remote copy.
104 if (local_info->Equals(*CopyToModel(specifics))) { 107 if (local_info->Equals(*CopyToModel(specifics))) {
105 local_tags_to_put.erase(tag); 108 local_guids_to_put.erase(local_guid);
106 } 109 }
107 } else { 110 } else {
108 // Remote data wins conflicts. 111 // Remote data wins conflicts.
109 local_tags_to_put.erase(tag); 112 local_guids_to_put.erase(specifics.cache_guid());
110 has_changes = true; 113 has_changes = true;
111 StoreSpecifics(make_scoped_ptr(new DeviceInfoSpecifics(specifics)), 114 StoreSpecifics(make_scoped_ptr(new DeviceInfoSpecifics(specifics)),
112 batch.get()); 115 batch.get());
113 } 116 }
114 } 117 }
115 118
116 for (const std::string& tag : local_tags_to_put) { 119 for (const std::string& guid : local_guids_to_put) {
117 change_processor()->Put(tag, CopyToEntityData(*all_data_[tag]), 120 change_processor()->Put(SpecificsToTag(*all_data_[guid]),
121 CopyToEntityData(*all_data_[guid]),
118 metadata_change_list.get()); 122 metadata_change_list.get());
119 } 123 }
120 124
121 CommitAndNotify(std::move(batch), std::move(metadata_change_list), 125 CommitAndNotify(std::move(batch), std::move(metadata_change_list),
122 has_changes); 126 has_changes);
123 return syncer::SyncError(); 127 return syncer::SyncError();
124 } 128 }
125 129
126 SyncError DeviceInfoService::ApplySyncChanges( 130 SyncError DeviceInfoService::ApplySyncChanges(
127 scoped_ptr<MetadataChangeList> metadata_change_list, 131 scoped_ptr<MetadataChangeList> metadata_change_list,
128 EntityChangeList entity_changes) { 132 EntityChangeList entity_changes) {
129 if (!has_provider_initialized_ || !has_metadata_loaded_) { 133 if (!has_provider_initialized_ || !has_metadata_loaded_) {
130 return SyncError( 134 return SyncError(
131 FROM_HERE, SyncError::DATATYPE_ERROR, 135 FROM_HERE, SyncError::DATATYPE_ERROR,
132 "Cannot call ApplySyncChanges before provider and data have loaded.", 136 "Cannot call ApplySyncChanges before provider and data have loaded.",
133 syncer::DEVICE_INFO); 137 syncer::DEVICE_INFO);
134 } 138 }
135 139
136 scoped_ptr<WriteBatch> batch = store_->CreateWriteBatch(); 140 scoped_ptr<WriteBatch> batch = store_->CreateWriteBatch();
137 bool has_changes = false; 141 bool has_changes = false;
138 for (EntityChange& change : entity_changes) { 142 for (EntityChange& change : entity_changes) {
139 const std::string tag = change.client_tag(); 143 const std::string guid = TagToCacheGuid(change.client_tag());
140 // Each device is the authoritative source for itself, ignore any remote 144 // Each device is the authoritative source for itself, ignore any remote
141 // changes that have our local cache guid. 145 // changes that have our local cache guid.
142 if (tag == local_device_info_provider_->GetLocalDeviceInfo()->guid()) { 146 if (guid == local_device_info_provider_->GetLocalDeviceInfo()->guid()) {
143 continue; 147 continue;
144 } 148 }
145 149
146 if (change.type() == EntityChange::ACTION_DELETE) { 150 if (change.type() == EntityChange::ACTION_DELETE) {
147 has_changes |= DeleteSpecifics(tag, batch.get()); 151 has_changes |= DeleteSpecifics(guid, batch.get());
148 } else { 152 } else {
149 const DeviceInfoSpecifics& specifics = 153 const DeviceInfoSpecifics& specifics =
150 change.data().specifics.device_info(); 154 change.data().specifics.device_info();
151 DCHECK(tag == specifics.cache_guid()); 155 DCHECK(guid == specifics.cache_guid());
152 StoreSpecifics(make_scoped_ptr(new DeviceInfoSpecifics(specifics)), 156 StoreSpecifics(make_scoped_ptr(new DeviceInfoSpecifics(specifics)),
153 batch.get()); 157 batch.get());
154 has_changes = true; 158 has_changes = true;
155 } 159 }
156 } 160 }
157 161
158 CommitAndNotify(std::move(batch), std::move(metadata_change_list), 162 CommitAndNotify(std::move(batch), std::move(metadata_change_list),
159 has_changes); 163 has_changes);
160 return SyncError(); 164 return SyncError();
161 } 165 }
162 166
163 void DeviceInfoService::GetData(ClientTagList client_tags, 167 void DeviceInfoService::GetData(ClientTagList client_tags,
164 DataCallback callback) { 168 DataCallback callback) {
165 if (!has_metadata_loaded_) { 169 if (!has_metadata_loaded_) {
166 callback.Run( 170 callback.Run(
167 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, 171 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR,
168 "Should not call GetData before metadata has loaded.", 172 "Should not call GetData before metadata has loaded.",
169 syncer::DEVICE_INFO), 173 syncer::DEVICE_INFO),
170 scoped_ptr<DataBatchImpl>()); 174 scoped_ptr<DataBatchImpl>());
171 return; 175 return;
172 } 176 }
173 177
174 scoped_ptr<DataBatchImpl> batch(new DataBatchImpl()); 178 scoped_ptr<DataBatchImpl> batch(new DataBatchImpl());
175 for (const auto& tag : client_tags) { 179 for (const auto& tag : client_tags) {
176 const auto iter = all_data_.find(tag); 180 const auto& iter = all_data_.find(TagToCacheGuid(tag));
177 if (iter != all_data_.end()) { 181 if (iter != all_data_.end()) {
182 DCHECK_EQ(tag, SpecificsToTag(*iter->second));
178 batch->Put(tag, CopyToEntityData(*iter->second)); 183 batch->Put(tag, CopyToEntityData(*iter->second));
179 } 184 }
180 } 185 }
181 callback.Run(syncer::SyncError(), std::move(batch)); 186 callback.Run(syncer::SyncError(), std::move(batch));
182 } 187 }
183 188
184 void DeviceInfoService::GetAllData(DataCallback callback) { 189 void DeviceInfoService::GetAllData(DataCallback callback) {
185 if (!has_metadata_loaded_) { 190 if (!has_metadata_loaded_) {
186 callback.Run( 191 callback.Run(
187 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, 192 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR,
188 "Should not call GetAllData before metadata has loaded.", 193 "Should not call GetAllData before metadata has loaded.",
189 syncer::DEVICE_INFO), 194 syncer::DEVICE_INFO),
190 scoped_ptr<DataBatchImpl>()); 195 scoped_ptr<DataBatchImpl>());
191 return; 196 return;
192 } 197 }
193 198
194 scoped_ptr<DataBatchImpl> batch(new DataBatchImpl()); 199 scoped_ptr<DataBatchImpl> batch(new DataBatchImpl());
195 for (const auto& kv : all_data_) { 200 for (const auto& kv : all_data_) {
196 batch->Put(kv.first, CopyToEntityData(*kv.second)); 201 batch->Put(SpecificsToTag(*kv.second), CopyToEntityData(*kv.second));
197 } 202 }
198 callback.Run(syncer::SyncError(), std::move(batch)); 203 callback.Run(syncer::SyncError(), std::move(batch));
199 } 204 }
200 205
201 std::string DeviceInfoService::GetClientTag(const EntityData& entity_data) { 206 std::string DeviceInfoService::GetClientTag(const EntityData& entity_data) {
202 DCHECK(entity_data.specifics.has_device_info()); 207 DCHECK(entity_data.specifics.has_device_info());
203 return entity_data.specifics.device_info().cache_guid(); 208 return SpecificsToTag(entity_data.specifics.device_info());
204 } 209 }
205 210
206 void DeviceInfoService::OnChangeProcessorSet() { 211 void DeviceInfoService::OnChangeProcessorSet() {
207 // We've recieved a new processor that needs metadata. If we're still in the 212 // We've recieved a new processor that needs metadata. If we're still in the
208 // process of loading data and/or metadata, then |has_metadata_loaded_| is 213 // process of loading data and/or metadata, then |has_metadata_loaded_| is
209 // false and we'll wait for those async reads to happen. If we've already 214 // false and we'll wait for those async reads to happen. If we've already
210 // loaded metadata and then subsequently we get a new processor, we must not 215 // loaded metadata and then subsequently we get a new processor, we must not
211 // have created the processor ourselves because we had no metadata. So there 216 // have created the processor ourselves because we had no metadata. So there
212 // must not be any metadata on disk. 217 // must not be any metadata on disk.
213 if (has_metadata_loaded_) { 218 if (has_metadata_loaded_) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 256
252 int DeviceInfoService::CountActiveDevices() const { 257 int DeviceInfoService::CountActiveDevices() const {
253 // TODO(skym): crbug.com/590006: Implementation. 258 // TODO(skym): crbug.com/590006: Implementation.
254 return 0; 259 return 0;
255 } 260 }
256 261
257 void DeviceInfoService::NotifyObservers() { 262 void DeviceInfoService::NotifyObservers() {
258 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceInfoChange()); 263 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceInfoChange());
259 } 264 }
260 265
266 std::string DeviceInfoService::SpecificsToTag(
267 const sync_pb::DeviceInfoSpecifics& specifics) {
268 return kClientTagPrefix + specifics.cache_guid();
269 }
270
271 std::string DeviceInfoService::TagToCacheGuid(const std::string& tag) {
272 DCHECK(base::StartsWith(tag, kClientTagPrefix, base::CompareCase::SENSITIVE));
273 return tag.substr(strlen(kClientTagPrefix));
274 }
275
261 // TODO(skym): crbug.com/543406: It might not make sense for this to be a 276 // TODO(skym): crbug.com/543406: It might not make sense for this to be a
262 // scoped_ptr. 277 // scoped_ptr.
263 // Static. 278 // Static.
264 scoped_ptr<DeviceInfoSpecifics> DeviceInfoService::CopyToSpecifics( 279 scoped_ptr<DeviceInfoSpecifics> DeviceInfoService::CopyToSpecifics(
265 const DeviceInfo& info) { 280 const DeviceInfo& info) {
266 scoped_ptr<DeviceInfoSpecifics> specifics = 281 scoped_ptr<DeviceInfoSpecifics> specifics =
267 make_scoped_ptr(new DeviceInfoSpecifics); 282 make_scoped_ptr(new DeviceInfoSpecifics);
268 specifics->set_cache_guid(info.guid()); 283 specifics->set_cache_guid(info.guid());
269 specifics->set_client_name(info.client_name()); 284 specifics->set_client_name(info.client_name());
270 specifics->set_chrome_version(info.chrome_version()); 285 specifics->set_chrome_version(info.chrome_version());
(...skipping 10 matching lines...) Expand all
281 specifics.cache_guid(), specifics.client_name(), 296 specifics.cache_guid(), specifics.client_name(),
282 specifics.chrome_version(), specifics.sync_user_agent(), 297 specifics.chrome_version(), specifics.sync_user_agent(),
283 specifics.device_type(), specifics.signin_scoped_device_id())); 298 specifics.device_type(), specifics.signin_scoped_device_id()));
284 } 299 }
285 300
286 // Static. 301 // Static.
287 scoped_ptr<EntityData> DeviceInfoService::CopyToEntityData( 302 scoped_ptr<EntityData> DeviceInfoService::CopyToEntityData(
288 const DeviceInfoSpecifics& specifics) { 303 const DeviceInfoSpecifics& specifics) {
289 scoped_ptr<EntityData> entity_data(new EntityData()); 304 scoped_ptr<EntityData> entity_data(new EntityData());
290 *entity_data->specifics.mutable_device_info() = specifics; 305 *entity_data->specifics.mutable_device_info() = specifics;
306 entity_data->non_unique_name = specifics.client_name();
291 return entity_data; 307 return entity_data;
292 } 308 }
293 309
294 void DeviceInfoService::StoreSpecifics( 310 void DeviceInfoService::StoreSpecifics(
295 scoped_ptr<DeviceInfoSpecifics> specifics, 311 scoped_ptr<DeviceInfoSpecifics> specifics,
296 WriteBatch* batch) { 312 WriteBatch* batch) {
297 const std::string tag = specifics->cache_guid(); 313 const std::string guid = specifics->cache_guid();
298 DVLOG(1) << "Storing DEVICE_INFO for " << specifics->client_name() 314 DVLOG(1) << "Storing DEVICE_INFO for " << specifics->client_name()
299 << " with ID " << tag; 315 << " with ID " << guid;
300 store_->WriteData(batch, tag, specifics->SerializeAsString()); 316 store_->WriteData(batch, guid, specifics->SerializeAsString());
301 all_data_[tag] = std::move(specifics); 317 all_data_[guid] = std::move(specifics);
302 } 318 }
303 319
304 bool DeviceInfoService::DeleteSpecifics(const std::string& tag, 320 bool DeviceInfoService::DeleteSpecifics(const std::string& guid,
305 WriteBatch* batch) { 321 WriteBatch* batch) {
306 ClientIdToSpecifics::const_iterator iter = all_data_.find(tag); 322 ClientIdToSpecifics::const_iterator iter = all_data_.find(guid);
307 if (iter != all_data_.end()) { 323 if (iter != all_data_.end()) {
308 DVLOG(1) << "Deleting DEVICE_INFO for " << iter->second->client_name() 324 DVLOG(1) << "Deleting DEVICE_INFO for " << iter->second->client_name()
309 << " with ID " << tag; 325 << " with ID " << guid;
310 store_->DeleteData(batch, tag); 326 store_->DeleteData(batch, guid);
311 all_data_.erase(iter); 327 all_data_.erase(iter);
312 return true; 328 return true;
313 } else { 329 } else {
314 return false; 330 return false;
315 } 331 }
316 } 332 }
317 333
318 void DeviceInfoService::OnProviderInitialized() { 334 void DeviceInfoService::OnProviderInitialized() {
319 has_provider_initialized_ = true; 335 has_provider_initialized_ = true;
320 TryReconcileLocalAndStored(); 336 TryReconcileLocalAndStored();
(...skipping 18 matching lines...) Expand all
339 LOG(WARNING) << "Initial load of data failed."; 355 LOG(WARNING) << "Initial load of data failed.";
340 // TODO(skym, crbug.com/582460): Handle unrecoverable initialization 356 // TODO(skym, crbug.com/582460): Handle unrecoverable initialization
341 // failure. 357 // failure.
342 return; 358 return;
343 } 359 }
344 360
345 for (const Record& r : *record_list.get()) { 361 for (const Record& r : *record_list.get()) {
346 scoped_ptr<DeviceInfoSpecifics> specifics( 362 scoped_ptr<DeviceInfoSpecifics> specifics(
347 make_scoped_ptr(new DeviceInfoSpecifics())); 363 make_scoped_ptr(new DeviceInfoSpecifics()));
348 if (specifics->ParseFromString(r.value)) { 364 if (specifics->ParseFromString(r.value)) {
349 all_data_[r.id] = std::move(specifics); 365 std::string guid = specifics->cache_guid();
skym 2016/04/14 21:08:26 Does this do an unnecessary copy?
pavely 2016/04/14 23:37:23 Done.
366 all_data_[guid] = std::move(specifics);
350 } else { 367 } else {
351 LOG(WARNING) << "Failed to deserialize specifics."; 368 LOG(WARNING) << "Failed to deserialize specifics.";
352 // TODO(skym, crbug.com/582460): Handle unrecoverable initialization 369 // TODO(skym, crbug.com/582460): Handle unrecoverable initialization
353 // failure. 370 // failure.
354 } 371 }
355 } 372 }
356 store_->ReadAllMetadata(base::Bind(&DeviceInfoService::OnReadAllMetadata, 373 store_->ReadAllMetadata(base::Bind(&DeviceInfoService::OnReadAllMetadata,
357 weak_factory_.GetWeakPtr())); 374 weak_factory_.GetWeakPtr()));
358 } 375 }
359 376
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 PutAndStore(*current_info); 459 PutAndStore(*current_info);
443 } 460 }
444 } 461 }
445 } 462 }
446 463
447 void DeviceInfoService::PutAndStore(const DeviceInfo& device_info) { 464 void DeviceInfoService::PutAndStore(const DeviceInfo& device_info) {
448 scoped_ptr<DeviceInfoSpecifics> specifics = CopyToSpecifics(device_info); 465 scoped_ptr<DeviceInfoSpecifics> specifics = CopyToSpecifics(device_info);
449 466
450 scoped_ptr<MetadataChangeList> metadata_change_list = 467 scoped_ptr<MetadataChangeList> metadata_change_list =
451 CreateMetadataChangeList(); 468 CreateMetadataChangeList();
452 change_processor()->Put(device_info.guid(), CopyToEntityData(*specifics), 469 change_processor()->Put(SpecificsToTag(*specifics),
470 CopyToEntityData(*specifics),
453 metadata_change_list.get()); 471 metadata_change_list.get());
454 472
455 scoped_ptr<WriteBatch> batch = store_->CreateWriteBatch(); 473 scoped_ptr<WriteBatch> batch = store_->CreateWriteBatch();
456 StoreSpecifics(std::move(specifics), batch.get()); 474 StoreSpecifics(std::move(specifics), batch.get());
457 475
458 CommitAndNotify(std::move(batch), std::move(metadata_change_list), true); 476 CommitAndNotify(std::move(batch), std::move(metadata_change_list), true);
459 } 477 }
460 478
461 void DeviceInfoService::CommitAndNotify( 479 void DeviceInfoService::CommitAndNotify(
462 scoped_ptr<WriteBatch> batch, 480 scoped_ptr<WriteBatch> batch,
463 scoped_ptr<MetadataChangeList> metadata_change_list, 481 scoped_ptr<MetadataChangeList> metadata_change_list,
464 bool should_notify) { 482 bool should_notify) {
465 static_cast<SimpleMetadataChangeList*>(metadata_change_list.get()) 483 static_cast<SimpleMetadataChangeList*>(metadata_change_list.get())
466 ->TransferChanges(store_.get(), batch.get()); 484 ->TransferChanges(store_.get(), batch.get());
467 store_->CommitWriteBatch( 485 store_->CommitWriteBatch(
468 std::move(batch), 486 std::move(batch),
469 base::Bind(&DeviceInfoService::OnCommit, weak_factory_.GetWeakPtr())); 487 base::Bind(&DeviceInfoService::OnCommit, weak_factory_.GetWeakPtr()));
470 if (should_notify) { 488 if (should_notify) {
471 NotifyObservers(); 489 NotifyObservers();
472 } 490 }
473 } 491 }
474 492
475 } // namespace sync_driver_v2 493 } // namespace sync_driver_v2
OLDNEW
« no previous file with comments | « components/sync_driver/device_info_service.h ('k') | components/sync_driver/device_info_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698