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

Side by Side Diff: components/sync/test/engine/mock_connection_manager.cc

Issue 2656303006: Remove Scopevector in //components/sync/ (Closed)
Patch Set: Created 3 years, 10 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/engine/mock_connection_manager.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/engine/mock_connection_manager.h" 5 #include "components/sync/test/engine/mock_connection_manager.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "components/sync/engine_impl/syncer_proto_util.h" 12 #include "components/sync/engine_impl/syncer_proto_util.h"
12 #include "components/sync/protocol/bookmark_specifics.pb.h" 13 #include "components/sync/protocol/bookmark_specifics.pb.h"
13 #include "components/sync/syncable/directory.h" 14 #include "components/sync/syncable/directory.h"
14 #include "components/sync/syncable/syncable_write_transaction.h" 15 #include "components/sync/syncable/syncable_write_transaction.h"
15 #include "components/sync/test/engine/test_id_factory.h" 16 #include "components/sync/test/engine/test_id_factory.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using std::find; 19 using std::find;
19 using std::map; 20 using std::map;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 588 }
588 589
589 void MockConnectionManager::ProcessCommit( 590 void MockConnectionManager::ProcessCommit(
590 sync_pb::ClientToServerMessage* csm, 591 sync_pb::ClientToServerMessage* csm,
591 sync_pb::ClientToServerResponse* response_buffer) { 592 sync_pb::ClientToServerResponse* response_buffer) {
592 CHECK(csm->has_commit()); 593 CHECK(csm->has_commit());
593 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::COMMIT); 594 ASSERT_EQ(csm->message_contents(), ClientToServerMessage::COMMIT);
594 map<string, string> changed_ids; 595 map<string, string> changed_ids;
595 const CommitMessage& commit_message = csm->commit(); 596 const CommitMessage& commit_message = csm->commit();
596 CommitResponse* commit_response = response_buffer->mutable_commit(); 597 CommitResponse* commit_response = response_buffer->mutable_commit();
597 commit_messages_.push_back(new CommitMessage); 598 commit_messages_.push_back(base::MakeUnique<CommitMessage>());
598 commit_messages_.back()->CopyFrom(commit_message); 599 commit_messages_.back()->CopyFrom(commit_message);
599 map<string, sync_pb::CommitResponse_EntryResponse*> response_map; 600 map<string, sync_pb::CommitResponse_EntryResponse*> response_map;
600 for (int i = 0; i < commit_message.entries_size(); i++) { 601 for (int i = 0; i < commit_message.entries_size(); i++) {
601 const sync_pb::SyncEntity& entry = commit_message.entries(i); 602 const sync_pb::SyncEntity& entry = commit_message.entries(i);
602 CHECK(entry.has_id_string()); 603 CHECK(entry.has_id_string());
603 string id_string = entry.id_string(); 604 string id_string = entry.id_string();
604 ASSERT_LT(entry.name().length(), 256ul) 605 ASSERT_LT(entry.name().length(), 256ul)
605 << " name probably too long. True " 606 << " name probably too long. True "
606 "server name checking not implemented"; 607 "server name checking not implemented";
607 syncable::Id id; 608 syncable::Id id;
(...skipping 30 matching lines...) Expand all
638 er->set_parent_id_string(parent_id_string); 639 er->set_parent_id_string(parent_id_string);
639 } 640 }
640 if (entry.has_version() && 0 != entry.version()) { 641 if (entry.has_version() && 0 != entry.version()) {
641 er->set_id_string(id_string); // Allows verification. 642 er->set_id_string(id_string); // Allows verification.
642 } else { 643 } else {
643 string new_id = base::StringPrintf("mock_server:%d", next_new_id_++); 644 string new_id = base::StringPrintf("mock_server:%d", next_new_id_++);
644 changed_ids[id_string] = new_id; 645 changed_ids[id_string] = new_id;
645 er->set_id_string(new_id); 646 er->set_id_string(new_id);
646 } 647 }
647 } 648 }
648 commit_responses_.push_back(new CommitResponse(*commit_response)); 649 commit_responses_.push_back(
650 base::MakeUnique<CommitResponse>(*commit_response));
649 651
650 if (commit_client_command_) { 652 if (commit_client_command_) {
651 response_buffer->mutable_client_command()->CopyFrom( 653 response_buffer->mutable_client_command()->CopyFrom(
652 *commit_client_command_.get()); 654 *commit_client_command_.get());
653 } 655 }
654 } 656 }
655 657
656 void MockConnectionManager::ProcessClearServerData( 658 void MockConnectionManager::ProcessClearServerData(
657 sync_pb::ClientToServerMessage* csm, 659 sync_pb::ClientToServerMessage* csm,
658 sync_pb::ClientToServerResponse* response) { 660 sync_pb::ClientToServerResponse* response) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 server_status_ = HttpResponse::SERVER_CONNECTION_OK; 764 server_status_ = HttpResponse::SERVER_CONNECTION_OK;
763 } 765 }
764 } 766 }
765 767
766 void MockConnectionManager::SetServerStatus( 768 void MockConnectionManager::SetServerStatus(
767 HttpResponse::ServerConnectionCode server_status) { 769 HttpResponse::ServerConnectionCode server_status) {
768 server_status_ = server_status; 770 server_status_ = server_status;
769 } 771 }
770 772
771 } // namespace syncer 773 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/test/engine/mock_connection_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698