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

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

Issue 1849563005: [Sync] Add cookie jar mismatch logging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests again 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
« 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 ShouldSendTriggeredError()) { 270 ShouldSendTriggeredError()) {
271 response_proto.set_error_code(error_type_); 271 response_proto.set_error_code(error_type_);
272 } else if (triggered_actionable_error_.get() && ShouldSendTriggeredError()) { 272 } else if (triggered_actionable_error_.get() && ShouldSendTriggeredError()) {
273 sync_pb::ClientToServerResponse_Error* error = 273 sync_pb::ClientToServerResponse_Error* error =
274 response_proto.mutable_error(); 274 response_proto.mutable_error();
275 error->CopyFrom(*(triggered_actionable_error_.get())); 275 error->CopyFrom(*(triggered_actionable_error_.get()));
276 } else { 276 } else {
277 bool success = false; 277 bool success = false;
278 switch (message.message_contents()) { 278 switch (message.message_contents()) {
279 case sync_pb::ClientToServerMessage::GET_UPDATES: 279 case sync_pb::ClientToServerMessage::GET_UPDATES:
280 last_getupdates_message_ = message;
280 success = HandleGetUpdatesRequest(message.get_updates(), 281 success = HandleGetUpdatesRequest(message.get_updates(),
281 response_proto.mutable_get_updates()); 282 response_proto.mutable_get_updates());
282 break; 283 break;
283 case sync_pb::ClientToServerMessage::COMMIT: 284 case sync_pb::ClientToServerMessage::COMMIT:
285 last_commit_message_ = message;
284 success = HandleCommitRequest(message.commit(), 286 success = HandleCommitRequest(message.commit(),
285 message.invalidator_client_id(), 287 message.invalidator_client_id(),
286 response_proto.mutable_commit()); 288 response_proto.mutable_commit());
287 break; 289 break;
288 case sync_pb::ClientToServerMessage::CLEAR_SERVER_DATA: 290 case sync_pb::ClientToServerMessage::CLEAR_SERVER_DATA:
289 ClearServerData(); 291 ClearServerData();
290 response_proto.mutable_clear_server_data(); 292 response_proto.mutable_clear_server_data();
291 success = true; 293 success = true;
292 break; 294 break;
293 default: 295 default:
(...skipping 18 matching lines...) Expand all
312 } 314 }
313 315
314 response_proto.set_store_birthday(GetStoreBirthday()); 316 response_proto.set_store_birthday(GetStoreBirthday());
315 317
316 *error_code = 0; 318 *error_code = 0;
317 *response_code = net::HTTP_OK; 319 *response_code = net::HTTP_OK;
318 *response = response_proto.SerializeAsString(); 320 *response = response_proto.SerializeAsString();
319 completion_closure.Run(); 321 completion_closure.Run();
320 } 322 }
321 323
324 bool FakeServer::GetLastCommitMessage(
325 sync_pb::ClientToServerMessage* message) {
326 if (!last_commit_message_.has_commit())
327 return false;
328
329 message->CopyFrom(last_commit_message_);
330 return true;
331 }
332
333 bool FakeServer::GetLastGetUpdatesMessage(
334 sync_pb::ClientToServerMessage* message) {
335 if (!last_getupdates_message_.has_get_updates())
336 return false;
337
338 message->CopyFrom(last_getupdates_message_);
339 return true;
340 }
341
322 bool FakeServer::HandleGetUpdatesRequest( 342 bool FakeServer::HandleGetUpdatesRequest(
323 const sync_pb::GetUpdatesMessage& get_updates, 343 const sync_pb::GetUpdatesMessage& get_updates,
324 sync_pb::GetUpdatesResponse* response) { 344 sync_pb::GetUpdatesResponse* response) {
325 // TODO(pvalenzuela): Implement batching instead of sending all information 345 // TODO(pvalenzuela): Implement batching instead of sending all information
326 // at once. 346 // at once.
327 response->set_changes_remaining(0); 347 response->set_changes_remaining(0);
328 348
329 scoped_ptr<UpdateSieve> sieve = UpdateSieve::Create(get_updates); 349 scoped_ptr<UpdateSieve> sieve = UpdateSieve::Create(get_updates);
330 350
331 // This folder is called "Synced Bookmarks" by sync and is renamed 351 // This folder is called "Synced Bookmarks" by sync and is renamed
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 DCHECK(thread_checker_.CalledOnValidThread()); 725 DCHECK(thread_checker_.CalledOnValidThread());
706 return weak_ptr_factory_.GetWeakPtr(); 726 return weak_ptr_factory_.GetWeakPtr();
707 } 727 }
708 728
709 std::string FakeServer::GetStoreBirthday() const { 729 std::string FakeServer::GetStoreBirthday() const {
710 DCHECK(thread_checker_.CalledOnValidThread()); 730 DCHECK(thread_checker_.CalledOnValidThread());
711 return base::Int64ToString(store_birthday_); 731 return base::Int64ToString(store_birthday_);
712 } 732 }
713 733
714 } // namespace fake_server 734 } // 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