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

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

Issue 1414203016: [Sync] Introduce GmsCoreSyncListener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move GetCustomPassphraseKey declaration. Created 5 years, 1 month 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/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 "sync/test/fake_server/fake_server.h" 5 #include "sync/test/fake_server/fake_server.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } // namespace 162 } // namespace
163 163
164 FakeServer::FakeServer() : version_(0), 164 FakeServer::FakeServer() : version_(0),
165 store_birthday_(0), 165 store_birthday_(0),
166 authenticated_(true), 166 authenticated_(true),
167 error_type_(sync_pb::SyncEnums::SUCCESS), 167 error_type_(sync_pb::SyncEnums::SUCCESS),
168 alternate_triggered_errors_(false), 168 alternate_triggered_errors_(false),
169 request_counter_(0), 169 request_counter_(0),
170 network_enabled_(true), 170 network_enabled_(true),
171 weak_ptr_factory_(this) { 171 weak_ptr_factory_(this) {
172 Init();
173 }
174
175 FakeServer::~FakeServer() {}
176
177 void FakeServer::Init() {
172 keystore_keys_.push_back(kDefaultKeystoreKey); 178 keystore_keys_.push_back(kDefaultKeystoreKey);
173 179
174 const bool create_result = CreateDefaultPermanentItems(); 180 const bool create_result = CreateDefaultPermanentItems();
175 DCHECK(create_result) << "Permanent items were not created successfully."; 181 DCHECK(create_result) << "Permanent items were not created successfully.";
176 } 182 }
177 183
178 FakeServer::~FakeServer() {}
179
180 bool FakeServer::CreatePermanentBookmarkFolder(const std::string& server_tag, 184 bool FakeServer::CreatePermanentBookmarkFolder(const std::string& server_tag,
181 const std::string& name) { 185 const std::string& name) {
182 DCHECK(thread_checker_.CalledOnValidThread()); 186 DCHECK(thread_checker_.CalledOnValidThread());
183 scoped_ptr<FakeServerEntity> entity = 187 scoped_ptr<FakeServerEntity> entity =
184 PermanentEntity::Create(syncer::BOOKMARKS, server_tag, name, 188 PermanentEntity::Create(syncer::BOOKMARKS, server_tag, name,
185 ModelTypeToRootTag(syncer::BOOKMARKS)); 189 ModelTypeToRootTag(syncer::BOOKMARKS));
186 if (!entity) 190 if (!entity)
187 return false; 191 return false;
188 192
189 SaveEntity(entity.Pass()); 193 SaveEntity(entity.Pass());
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 UpdateEntityVersion(entity.get()); 587 UpdateEntityVersion(entity.get());
584 entities_.insert(id, entity.Pass()); 588 entities_.insert(id, entity.Pass());
585 return true; 589 return true;
586 } 590 }
587 591
588 void FakeServer::ClearServerData() { 592 void FakeServer::ClearServerData() {
589 DCHECK(thread_checker_.CalledOnValidThread()); 593 DCHECK(thread_checker_.CalledOnValidThread());
590 entities_.clear(); 594 entities_.clear();
591 keystore_keys_.clear(); 595 keystore_keys_.clear();
592 ++store_birthday_; 596 ++store_birthday_;
597 Init();
593 } 598 }
594 599
595 void FakeServer::SetAuthenticated() { 600 void FakeServer::SetAuthenticated() {
596 DCHECK(thread_checker_.CalledOnValidThread()); 601 DCHECK(thread_checker_.CalledOnValidThread());
597 authenticated_ = true; 602 authenticated_ = true;
598 } 603 }
599 604
600 void FakeServer::SetUnauthenticated() { 605 void FakeServer::SetUnauthenticated() {
601 DCHECK(thread_checker_.CalledOnValidThread()); 606 DCHECK(thread_checker_.CalledOnValidThread());
602 authenticated_ = false; 607 authenticated_ = false;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 DCHECK(thread_checker_.CalledOnValidThread()); 701 DCHECK(thread_checker_.CalledOnValidThread());
697 return weak_ptr_factory_.GetWeakPtr(); 702 return weak_ptr_factory_.GetWeakPtr();
698 } 703 }
699 704
700 std::string FakeServer::GetStoreBirthday() const { 705 std::string FakeServer::GetStoreBirthday() const {
701 DCHECK(thread_checker_.CalledOnValidThread()); 706 DCHECK(thread_checker_.CalledOnValidThread());
702 return base::Int64ToString(store_birthday_); 707 return base::Int64ToString(store_birthday_);
703 } 708 }
704 709
705 } // namespace fake_server 710 } // namespace fake_server
OLDNEW
« no previous file with comments | « 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