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

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

Issue 2973833002: [Sync] Added integ tests to verify UserEvents retry on TRANSIENT_ERROR. (Closed)
Patch Set: Created 3 years, 5 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 | « components/sync/test/fake_server/fake_server.h ('k') | no next file » | 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 "components/sync/test/fake_server/fake_server.h" 5 #include "components/sync/test/fake_server/fake_server.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } else { 394 } else {
395 entity = UniqueClientEntity::Create(client_entity); 395 entity = UniqueClientEntity::Create(client_entity);
396 } 396 }
397 397
398 const std::string id = entity->id(); 398 const std::string id = entity->id();
399 SaveEntity(std::move(entity)); 399 SaveEntity(std::move(entity));
400 BuildEntryResponseForSuccessfulCommit(id, entry_response); 400 BuildEntryResponseForSuccessfulCommit(id, entry_response);
401 return id; 401 return id;
402 } 402 }
403 403
404 void FakeServer::OverrideResponseType(
405 ResponseTypeProvider response_type_override) {
406 response_type_override_ = std::move(response_type_override);
407 }
408
404 void FakeServer::BuildEntryResponseForSuccessfulCommit( 409 void FakeServer::BuildEntryResponseForSuccessfulCommit(
405 const std::string& entity_id, 410 const std::string& entity_id,
406 sync_pb::CommitResponse_EntryResponse* entry_response) { 411 sync_pb::CommitResponse_EntryResponse* entry_response) {
407 EntityMap::const_iterator iter = entities_.find(entity_id); 412 EntityMap::const_iterator iter = entities_.find(entity_id);
408 CHECK(iter != entities_.end()); 413 CHECK(iter != entities_.end());
409 const FakeServerEntity& entity = *iter->second; 414 const FakeServerEntity& entity = *iter->second;
410 entry_response->set_response_type(sync_pb::CommitResponse::SUCCESS); 415 entry_response->set_response_type(response_type_override_
416 ? response_type_override_.Run(entity)
417 : sync_pb::CommitResponse::SUCCESS);
411 entry_response->set_id_string(entity.id()); 418 entry_response->set_id_string(entity.id());
412 419
413 if (entity.IsDeleted()) { 420 if (entity.IsDeleted()) {
414 entry_response->set_version(entity.GetVersion() + 1); 421 entry_response->set_version(entity.GetVersion() + 1);
415 } else { 422 } else {
416 entry_response->set_version(entity.GetVersion()); 423 entry_response->set_version(entity.GetVersion());
417 entry_response->set_name(entity.GetName()); 424 entry_response->set_name(entity.GetName());
418 } 425 }
419 } 426 }
420 427
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 DCHECK(thread_checker_.CalledOnValidThread()); 703 DCHECK(thread_checker_.CalledOnValidThread());
697 return weak_ptr_factory_.GetWeakPtr(); 704 return weak_ptr_factory_.GetWeakPtr();
698 } 705 }
699 706
700 std::string FakeServer::GetStoreBirthday() const { 707 std::string FakeServer::GetStoreBirthday() const {
701 DCHECK(thread_checker_.CalledOnValidThread()); 708 DCHECK(thread_checker_.CalledOnValidThread());
702 return base::Int64ToString(store_birthday_); 709 return base::Int64ToString(store_birthday_);
703 } 710 }
704 711
705 } // namespace fake_server 712 } // namespace fake_server
OLDNEW
« no previous file with comments | « components/sync/test/fake_server/fake_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698