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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
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/engine/single_type_mock_server.h" 5 #include "components/sync/test/engine/single_type_mock_server.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "sync/util/time.h" 10 #include "components/sync/base/time.h"
11 11
12 using google::protobuf::RepeatedPtrField; 12 using google::protobuf::RepeatedPtrField;
13 13
14 namespace syncer { 14 namespace syncer {
15 15
16 SingleTypeMockServer::SingleTypeMockServer(syncer::ModelType type) 16 SingleTypeMockServer::SingleTypeMockServer(syncer::ModelType type)
17 : type_(type), type_root_id_(ModelTypeToRootTag(type)) { 17 : type_(type), type_root_id_(ModelTypeToRootTag(type)) {}
18 }
19 18
20 SingleTypeMockServer::~SingleTypeMockServer() { 19 SingleTypeMockServer::~SingleTypeMockServer() {}
21 }
22 20
23 sync_pb::SyncEntity SingleTypeMockServer::TypeRootUpdate() { 21 sync_pb::SyncEntity SingleTypeMockServer::TypeRootUpdate() {
24 sync_pb::SyncEntity entity; 22 sync_pb::SyncEntity entity;
25 23
26 entity.set_id_string(type_root_id_); 24 entity.set_id_string(type_root_id_);
27 entity.set_parent_id_string("r"); 25 entity.set_parent_id_string("r");
28 entity.set_version(1000); 26 entity.set_version(1000);
29 entity.set_ctime(TimeToProtoTime(base::Time::UnixEpoch())); 27 entity.set_ctime(TimeToProtoTime(base::Time::UnixEpoch()));
30 entity.set_mtime(TimeToProtoTime(base::Time::UnixEpoch())); 28 entity.set_mtime(TimeToProtoTime(base::Time::UnixEpoch()));
31 entity.set_server_defined_unique_tag(ModelTypeToRootTag(type_)); 29 entity.set_server_defined_unique_tag(ModelTypeToRootTag(type_));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 const sync_pb::ClientToServerMessage& message) { 94 const sync_pb::ClientToServerMessage& message) {
97 commit_messages_.push_back(message); 95 commit_messages_.push_back(message);
98 96
99 sync_pb::ClientToServerResponse response; 97 sync_pb::ClientToServerResponse response;
100 sync_pb::CommitResponse* commit_response = response.mutable_commit(); 98 sync_pb::CommitResponse* commit_response = response.mutable_commit();
101 99
102 const RepeatedPtrField<sync_pb::SyncEntity>& entries = 100 const RepeatedPtrField<sync_pb::SyncEntity>& entries =
103 message.commit().entries(); 101 message.commit().entries();
104 for (RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it = 102 for (RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it =
105 entries.begin(); 103 entries.begin();
106 it != entries.end(); 104 it != entries.end(); ++it) {
107 ++it) {
108 const std::string tag_hash = it->client_defined_unique_tag(); 105 const std::string tag_hash = it->client_defined_unique_tag();
109 106
110 committed_items_[tag_hash] = *it; 107 committed_items_[tag_hash] = *it;
111 108
112 // Every commit increments the version number. 109 // Every commit increments the version number.
113 int64_t version = GetServerVersion(tag_hash); 110 int64_t version = GetServerVersion(tag_hash);
114 version++; 111 version++;
115 SetServerVersion(tag_hash, version); 112 SetServerVersion(tag_hash, version);
116 113
117 sync_pb::CommitResponse_EntryResponse* entryresponse = 114 sync_pb::CommitResponse_EntryResponse* entryresponse =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return it->second; 170 return it->second;
174 } 171 }
175 } 172 }
176 173
177 void SingleTypeMockServer::SetServerVersion(const std::string& tag_hash, 174 void SingleTypeMockServer::SetServerVersion(const std::string& tag_hash,
178 int64_t version) { 175 int64_t version) {
179 server_versions_[tag_hash] = version; 176 server_versions_[tag_hash] = version;
180 } 177 }
181 178
182 } // namespace syncer 179 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/test/engine/single_type_mock_server.h ('k') | components/sync/test/engine/test_directory_setter_upper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698