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 #ifndef SYNC_TEST_FAKE_SERVER_UNIQUE_CLIENT_ENTITY_H_ | 5 #ifndef SYNC_TEST_FAKE_SERVER_UNIQUE_CLIENT_ENTITY_H_ |
6 #define SYNC_TEST_FAKE_SERVER_UNIQUE_CLIENT_ENTITY_H_ | 6 #define SYNC_TEST_FAKE_SERVER_UNIQUE_CLIENT_ENTITY_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "sync/internal_api/public/base/model_type.h" | 13 #include "sync/internal_api/public/base/model_type.h" |
13 #include "sync/test/fake_server/fake_server_entity.h" | 14 #include "sync/test/fake_server/fake_server_entity.h" |
14 | 15 |
15 namespace sync_pb { | 16 namespace sync_pb { |
16 class EntitySpecifics; | 17 class EntitySpecifics; |
17 class SyncEntity; | 18 class SyncEntity; |
18 } // namespace sync_pb | 19 } // namespace sync_pb |
19 | 20 |
20 namespace fake_server { | 21 namespace fake_server { |
21 | 22 |
22 // An entity that is unique per client account. | 23 // An entity that is unique per client account. |
23 // | 24 // |
24 // TODO(pvalenzuela): Reconsider the naming of this class. In some cases, this | 25 // TODO(pvalenzuela): Reconsider the naming of this class. In some cases, this |
25 // type is used to represent entities where the unique client tag is irrelevant | 26 // type is used to represent entities where the unique client tag is irrelevant |
26 // (e.g., Autofill Wallet). | 27 // (e.g., Autofill Wallet). |
27 class UniqueClientEntity : public FakeServerEntity { | 28 class UniqueClientEntity : public FakeServerEntity { |
28 public: | 29 public: |
29 UniqueClientEntity(const std::string& id, | 30 UniqueClientEntity(const std::string& id, |
30 syncer::ModelType model_type, | 31 syncer::ModelType model_type, |
31 int64 version, | 32 int64_t version, |
32 const std::string& name, | 33 const std::string& name, |
33 const std::string& client_defined_unique_tag, | 34 const std::string& client_defined_unique_tag, |
34 const sync_pb::EntitySpecifics& specifics, | 35 const sync_pb::EntitySpecifics& specifics, |
35 int64 creation_time, | 36 int64_t creation_time, |
36 int64 last_modified_time); | 37 int64_t last_modified_time); |
37 | 38 |
38 ~UniqueClientEntity() override; | 39 ~UniqueClientEntity() override; |
39 | 40 |
40 // Factory function for creating a UniqueClientEntity. | 41 // Factory function for creating a UniqueClientEntity. |
41 static scoped_ptr<FakeServerEntity> Create( | 42 static scoped_ptr<FakeServerEntity> Create( |
42 const sync_pb::SyncEntity& client_entity); | 43 const sync_pb::SyncEntity& client_entity); |
43 | 44 |
44 // Factory function for creating a UniqueClientEntity for use in the | 45 // Factory function for creating a UniqueClientEntity for use in the |
45 // FakeServer injection API. | 46 // FakeServer injection API. |
46 static scoped_ptr<FakeServerEntity> CreateForInjection( | 47 static scoped_ptr<FakeServerEntity> CreateForInjection( |
47 const std::string& name, | 48 const std::string& name, |
48 const sync_pb::EntitySpecifics& entity_specifics); | 49 const sync_pb::EntitySpecifics& entity_specifics); |
49 | 50 |
50 // Derives an ID from a unique client tagged entity. | 51 // Derives an ID from a unique client tagged entity. |
51 static std::string EffectiveIdForClientTaggedEntity( | 52 static std::string EffectiveIdForClientTaggedEntity( |
52 const sync_pb::SyncEntity& entity); | 53 const sync_pb::SyncEntity& entity); |
53 | 54 |
54 // FakeServerEntity implementation. | 55 // FakeServerEntity implementation. |
55 bool RequiresParentId() const override; | 56 bool RequiresParentId() const override; |
56 std::string GetParentId() const override; | 57 std::string GetParentId() const override; |
57 void SerializeAsProto(sync_pb::SyncEntity* proto) const override; | 58 void SerializeAsProto(sync_pb::SyncEntity* proto) const override; |
58 | 59 |
59 private: | 60 private: |
60 // These member values have equivalent fields in SyncEntity. | 61 // These member values have equivalent fields in SyncEntity. |
61 std::string client_defined_unique_tag_; | 62 std::string client_defined_unique_tag_; |
62 int64 creation_time_; | 63 int64_t creation_time_; |
63 int64 last_modified_time_; | 64 int64_t last_modified_time_; |
64 }; | 65 }; |
65 | 66 |
66 } // namespace fake_server | 67 } // namespace fake_server |
67 | 68 |
68 #endif // SYNC_TEST_FAKE_SERVER_UNIQUE_CLIENT_ENTITY_H_ | 69 #endif // SYNC_TEST_FAKE_SERVER_UNIQUE_CLIENT_ENTITY_H_ |
OLD | NEW |