OLD | NEW |
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_entity.h" | 5 #include "sync/test/fake_server/fake_server_entity.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <limits> | 9 #include <limits> |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/basictypes.h" | |
12 #include "base/guid.h" | 13 #include "base/guid.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
21 #include "net/http/http_status_code.h" | 22 #include "net/http/http_status_code.h" |
(...skipping 17 matching lines...) Expand all Loading... |
39 FakeServerEntity::~FakeServerEntity() { } | 40 FakeServerEntity::~FakeServerEntity() { } |
40 | 41 |
41 const std::string& FakeServerEntity::GetId() const { | 42 const std::string& FakeServerEntity::GetId() const { |
42 return id_; | 43 return id_; |
43 } | 44 } |
44 | 45 |
45 ModelType FakeServerEntity::GetModelType() const { | 46 ModelType FakeServerEntity::GetModelType() const { |
46 return model_type_; | 47 return model_type_; |
47 } | 48 } |
48 | 49 |
49 int64 FakeServerEntity::GetVersion() const { | 50 int64_t FakeServerEntity::GetVersion() const { |
50 return version_; | 51 return version_; |
51 } | 52 } |
52 | 53 |
53 void FakeServerEntity::SetVersion(int64 version) { | 54 void FakeServerEntity::SetVersion(int64_t version) { |
54 version_ = version; | 55 version_ = version; |
55 } | 56 } |
56 | 57 |
57 const std::string& FakeServerEntity::GetName() const { | 58 const std::string& FakeServerEntity::GetName() const { |
58 return name_; | 59 return name_; |
59 } | 60 } |
60 | 61 |
61 void FakeServerEntity::SetName(const std::string& name) { | 62 void FakeServerEntity::SetName(const std::string& name) { |
62 name_ = name; | 63 name_ = name; |
63 } | 64 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 int field_number; | 105 int field_number; |
105 if (tokens.size() != 2 || !base::StringToInt(tokens[0], &field_number)) { | 106 if (tokens.size() != 2 || !base::StringToInt(tokens[0], &field_number)) { |
106 return syncer::UNSPECIFIED; | 107 return syncer::UNSPECIFIED; |
107 } | 108 } |
108 | 109 |
109 return syncer::GetModelTypeFromSpecificsFieldNumber(field_number); | 110 return syncer::GetModelTypeFromSpecificsFieldNumber(field_number); |
110 } | 111 } |
111 | 112 |
112 FakeServerEntity::FakeServerEntity(const string& id, | 113 FakeServerEntity::FakeServerEntity(const string& id, |
113 const ModelType& model_type, | 114 const ModelType& model_type, |
114 int64 version, | 115 int64_t version, |
115 const string& name) | 116 const string& name) |
116 : id_(id), | 117 : id_(id), model_type_(model_type), version_(version), name_(name) {} |
117 model_type_(model_type), | |
118 version_(version), | |
119 name_(name) {} | |
120 | 118 |
121 void FakeServerEntity::SerializeBaseProtoFields( | 119 void FakeServerEntity::SerializeBaseProtoFields( |
122 sync_pb::SyncEntity* sync_entity) const { | 120 sync_pb::SyncEntity* sync_entity) const { |
123 sync_pb::EntitySpecifics* specifics = sync_entity->mutable_specifics(); | 121 sync_pb::EntitySpecifics* specifics = sync_entity->mutable_specifics(); |
124 specifics->CopyFrom(specifics_); | 122 specifics->CopyFrom(specifics_); |
125 | 123 |
126 // FakeServerEntity fields | 124 // FakeServerEntity fields |
127 sync_entity->set_id_string(id_); | 125 sync_entity->set_id_string(id_); |
128 sync_entity->set_version(version_); | 126 sync_entity->set_version(version_); |
129 sync_entity->set_name(name_); | 127 sync_entity->set_name(name_); |
130 | 128 |
131 // Data via accessors | 129 // Data via accessors |
132 sync_entity->set_deleted(IsDeleted()); | 130 sync_entity->set_deleted(IsDeleted()); |
133 sync_entity->set_folder(IsFolder()); | 131 sync_entity->set_folder(IsFolder()); |
134 | 132 |
135 if (RequiresParentId()) | 133 if (RequiresParentId()) |
136 sync_entity->set_parent_id_string(GetParentId()); | 134 sync_entity->set_parent_id_string(GetParentId()); |
137 } | 135 } |
138 | 136 |
139 } // namespace fake_server | 137 } // namespace fake_server |
OLD | NEW |