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

Side by Side Diff: sync/test/fake_server/fake_server_entity.h

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
« no previous file with comments | « sync/test/fake_server/fake_server.cc ('k') | sync/test/fake_server/fake_server_entity.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_
6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <string>
12
13 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/protocol/sync.pb.h"
15
16 namespace fake_server {
17
18 // The representation of a Sync entity for the fake server.
19 class FakeServerEntity {
20 public:
21 // Creates an ID of the form <type><separator><inner-id> where
22 // <type> is the EntitySpecifics field number for |model_type|, <separator>
23 // is kIdSeparator, and <inner-id> is |inner_id|.
24 //
25 // If |inner_id| is globally unique, then the returned ID will also be
26 // globally unique.
27 static std::string CreateId(const syncer::ModelType& model_type,
28 const std::string& inner_id);
29
30 // Returns the ID string of the top level node for the specified type.
31 static std::string GetTopLevelId(const syncer::ModelType& model_type);
32
33 virtual ~FakeServerEntity();
34 const std::string& GetId() const;
35 syncer::ModelType GetModelType() const;
36 int64_t GetVersion() const;
37 void SetVersion(int64_t version);
38 const std::string& GetName() const;
39 void SetName(const std::string& name);
40
41 // Replaces |specifics_| with |updated_specifics|. This method is meant to be
42 // used to mimic a client commit.
43 void SetSpecifics(const sync_pb::EntitySpecifics& updated_specifics);
44
45 // Common data items needed by server
46 virtual bool RequiresParentId() const = 0;
47 virtual std::string GetParentId() const = 0;
48 virtual void SerializeAsProto(sync_pb::SyncEntity* proto) const = 0;
49 virtual bool IsDeleted() const;
50 virtual bool IsFolder() const;
51 virtual bool IsPermanent() const;
52
53 protected:
54 // Extracts the ModelType from |id|. If |id| is malformed or does not contain
55 // a valid ModelType, UNSPECIFIED is returned.
56 static syncer::ModelType GetModelTypeFromId(const std::string& id);
57
58 FakeServerEntity(const std::string& id,
59 const syncer::ModelType& model_type,
60 int64_t version,
61 const std::string& name);
62
63 void SerializeBaseProtoFields(sync_pb::SyncEntity* sync_entity) const;
64
65 private:
66 // The entity's ID.
67 std::string id_;
68
69 // The ModelType that categorizes this entity.
70 syncer::ModelType model_type_;
71
72 // The version of this entity.
73 int64_t version_;
74
75 // The name of the entity.
76 std::string name_;
77
78 // The EntitySpecifics for the entity.
79 sync_pb::EntitySpecifics specifics_;
80 };
81
82 } // namespace fake_server
83
84 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_
OLDNEW
« no previous file with comments | « sync/test/fake_server/fake_server.cc ('k') | sync/test/fake_server/fake_server_entity.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698