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

Side by Side Diff: sync/test/fake_server/fake_server.cc

Issue 1539843002: Convert Pass()→std::move() in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up Created 4 years, 12 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
« no previous file with comments | « sync/syncable/entry_kernel.cc ('k') | sync/tools/sync_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "sync/test/fake_server/fake_server.h" 5 #include "sync/test/fake_server/fake_server.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 bool FakeServer::CreatePermanentBookmarkFolder(const std::string& server_tag, 185 bool FakeServer::CreatePermanentBookmarkFolder(const std::string& server_tag,
186 const std::string& name) { 186 const std::string& name) {
187 DCHECK(thread_checker_.CalledOnValidThread()); 187 DCHECK(thread_checker_.CalledOnValidThread());
188 scoped_ptr<FakeServerEntity> entity = 188 scoped_ptr<FakeServerEntity> entity =
189 PermanentEntity::Create(syncer::BOOKMARKS, server_tag, name, 189 PermanentEntity::Create(syncer::BOOKMARKS, server_tag, name,
190 ModelTypeToRootTag(syncer::BOOKMARKS)); 190 ModelTypeToRootTag(syncer::BOOKMARKS));
191 if (!entity) 191 if (!entity)
192 return false; 192 return false;
193 193
194 SaveEntity(entity.Pass()); 194 SaveEntity(std::move(entity));
195 return true; 195 return true;
196 } 196 }
197 197
198 bool FakeServer::CreateDefaultPermanentItems() { 198 bool FakeServer::CreateDefaultPermanentItems() {
199 // Permanent folders are always required for Bookmarks (hierarchical 199 // Permanent folders are always required for Bookmarks (hierarchical
200 // structure) and Nigori (data stored in permanent root folder). 200 // structure) and Nigori (data stored in permanent root folder).
201 ModelTypeSet permanent_folder_types = 201 ModelTypeSet permanent_folder_types =
202 ModelTypeSet(syncer::BOOKMARKS, syncer::NIGORI); 202 ModelTypeSet(syncer::BOOKMARKS, syncer::NIGORI);
203 203
204 for (ModelTypeSet::Iterator it = permanent_folder_types.First(); it.Good(); 204 for (ModelTypeSet::Iterator it = permanent_folder_types.First(); it.Good();
205 it.Inc()) { 205 it.Inc()) {
206 ModelType model_type = it.Get(); 206 ModelType model_type = it.Get();
207 207
208 scoped_ptr<FakeServerEntity> top_level_entity = 208 scoped_ptr<FakeServerEntity> top_level_entity =
209 PermanentEntity::CreateTopLevel(model_type); 209 PermanentEntity::CreateTopLevel(model_type);
210 if (!top_level_entity) { 210 if (!top_level_entity) {
211 return false; 211 return false;
212 } 212 }
213 SaveEntity(top_level_entity.Pass()); 213 SaveEntity(std::move(top_level_entity));
214 214
215 if (model_type == syncer::BOOKMARKS) { 215 if (model_type == syncer::BOOKMARKS) {
216 if (!CreatePermanentBookmarkFolder(kBookmarkBarFolderServerTag, 216 if (!CreatePermanentBookmarkFolder(kBookmarkBarFolderServerTag,
217 kBookmarkBarFolderName)) 217 kBookmarkBarFolderName))
218 return false; 218 return false;
219 if (!CreatePermanentBookmarkFolder(kOtherBookmarksFolderServerTag, 219 if (!CreatePermanentBookmarkFolder(kOtherBookmarksFolderServerTag,
220 kOtherBookmarksFolderName)) 220 kOtherBookmarksFolderName))
221 return false; 221 return false;
222 } 222 }
223 } 223 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 401 }
402 } 402 }
403 403
404 if (!entity) { 404 if (!entity) {
405 // TODO(pvalenzuela): Add logging so that it is easier to determine why 405 // TODO(pvalenzuela): Add logging so that it is easier to determine why
406 // creation failed. 406 // creation failed.
407 return string(); 407 return string();
408 } 408 }
409 409
410 const std::string id = entity->GetId(); 410 const std::string id = entity->GetId();
411 SaveEntity(entity.Pass()); 411 SaveEntity(std::move(entity));
412 BuildEntryResponseForSuccessfulCommit(id, entry_response); 412 BuildEntryResponseForSuccessfulCommit(id, entry_response);
413 return id; 413 return id;
414 } 414 }
415 415
416 void FakeServer::BuildEntryResponseForSuccessfulCommit( 416 void FakeServer::BuildEntryResponseForSuccessfulCommit(
417 const std::string& entity_id, 417 const std::string& entity_id,
418 sync_pb::CommitResponse_EntryResponse* entry_response) { 418 sync_pb::CommitResponse_EntryResponse* entry_response) {
419 EntityMap::const_iterator iter = entities_.find(entity_id); 419 EntityMap::const_iterator iter = entities_.find(entity_id);
420 CHECK(iter != entities_.end()); 420 CHECK(iter != entities_.end());
421 const FakeServerEntity& entity = *iter->second; 421 const FakeServerEntity& entity = *iter->second;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 if (!dictionary->GetList(ModelTypeToString(entity.GetModelType()), 524 if (!dictionary->GetList(ModelTypeToString(entity.GetModelType()),
525 &list_value)) { 525 &list_value)) {
526 return scoped_ptr<base::DictionaryValue>(); 526 return scoped_ptr<base::DictionaryValue>();
527 } 527 }
528 // TODO(pvalenzuela): Store more data for each entity so additional 528 // TODO(pvalenzuela): Store more data for each entity so additional
529 // verification can be performed. One example of additional verification 529 // verification can be performed. One example of additional verification
530 // is checking the correctness of the bookmark hierarchy. 530 // is checking the correctness of the bookmark hierarchy.
531 list_value->Append(new base::StringValue(entity.GetName())); 531 list_value->Append(new base::StringValue(entity.GetName()));
532 } 532 }
533 533
534 return dictionary.Pass(); 534 return dictionary;
535 } 535 }
536 536
537 std::vector<sync_pb::SyncEntity> FakeServer::GetSyncEntitiesByModelType( 537 std::vector<sync_pb::SyncEntity> FakeServer::GetSyncEntitiesByModelType(
538 ModelType model_type) { 538 ModelType model_type) {
539 std::vector<sync_pb::SyncEntity> sync_entities; 539 std::vector<sync_pb::SyncEntity> sync_entities;
540 DCHECK(thread_checker_.CalledOnValidThread()); 540 DCHECK(thread_checker_.CalledOnValidThread());
541 for (EntityMap::const_iterator it = entities_.begin(); it != entities_.end(); 541 for (EntityMap::const_iterator it = entities_.begin(); it != entities_.end();
542 ++it) { 542 ++it) {
543 const FakeServerEntity& entity = *it->second; 543 const FakeServerEntity& entity = *it->second;
544 if (!IsDeletedOrPermanent(entity) && entity.GetModelType() == model_type) { 544 if (!IsDeletedOrPermanent(entity) && entity.GetModelType() == model_type) {
545 sync_pb::SyncEntity sync_entity; 545 sync_pb::SyncEntity sync_entity;
546 entity.SerializeAsProto(&sync_entity); 546 entity.SerializeAsProto(&sync_entity);
547 sync_entities.push_back(sync_entity); 547 sync_entities.push_back(sync_entity);
548 } 548 }
549 } 549 }
550 return sync_entities; 550 return sync_entities;
551 } 551 }
552 552
553 void FakeServer::InjectEntity(scoped_ptr<FakeServerEntity> entity) { 553 void FakeServer::InjectEntity(scoped_ptr<FakeServerEntity> entity) {
554 DCHECK(thread_checker_.CalledOnValidThread()); 554 DCHECK(thread_checker_.CalledOnValidThread());
555 SaveEntity(entity.Pass()); 555 SaveEntity(std::move(entity));
556 } 556 }
557 557
558 bool FakeServer::ModifyEntitySpecifics( 558 bool FakeServer::ModifyEntitySpecifics(
559 const std::string& id, 559 const std::string& id,
560 const sync_pb::EntitySpecifics& updated_specifics) { 560 const sync_pb::EntitySpecifics& updated_specifics) {
561 EntityMap::const_iterator iter = entities_.find(id); 561 EntityMap::const_iterator iter = entities_.find(id);
562 if (iter == entities_.end() || 562 if (iter == entities_.end() ||
563 iter->second->GetModelType() != 563 iter->second->GetModelType() !=
564 GetModelTypeFromSpecifics(updated_specifics)) { 564 GetModelTypeFromSpecifics(updated_specifics)) {
565 return false; 565 return false;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 DCHECK(thread_checker_.CalledOnValidThread()); 705 DCHECK(thread_checker_.CalledOnValidThread());
706 return weak_ptr_factory_.GetWeakPtr(); 706 return weak_ptr_factory_.GetWeakPtr();
707 } 707 }
708 708
709 std::string FakeServer::GetStoreBirthday() const { 709 std::string FakeServer::GetStoreBirthday() const {
710 DCHECK(thread_checker_.CalledOnValidThread()); 710 DCHECK(thread_checker_.CalledOnValidThread());
711 return base::Int64ToString(store_birthday_); 711 return base::Int64ToString(store_birthday_);
712 } 712 }
713 713
714 } // namespace fake_server 714 } // namespace fake_server
OLDNEW
« no previous file with comments | « sync/syncable/entry_kernel.cc ('k') | sync/tools/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698