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

Side by Side Diff: components/sync/engine_impl/loopback_server/persistent_permanent_entity.h

Issue 2360703002: [Sync] Implements the loopback sync server. (Closed)
Patch Set: Address comment. Created 4 years, 2 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
(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 COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_PERSISTENT_PERMANENT_ENTITY_ H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_PERSISTENT_PERMANENT_ENTITY_ H_
7
8 #include <memory>
9 #include <string>
10
11 #include "components/sync/base/model_type.h"
12 #include "components/sync/engine_impl/loopback_server/loopback_server_entity.h"
13 #include "components/sync/protocol/sync.pb.h"
14
15 namespace syncer {
16
17 // A server-created, permanent entity.
18 class PersistentPermanentEntity : public LoopbackServerEntity {
19 public:
20 PersistentPermanentEntity(const std::string& id,
21 int64_t version,
22 const syncer::ModelType& model_type,
23 const std::string& name,
24 const std::string& parent_id,
25 const std::string& server_defined_unique_tag,
26 const sync_pb::EntitySpecifics& entity_specifics);
27
28 ~PersistentPermanentEntity() override;
29
30 // Factory function for PersistentPermanentEntity. |server_tag| should be a
31 // globally unique identifier.
32 static std::unique_ptr<LoopbackServerEntity> Create(
33 const syncer::ModelType& model_type,
34 const std::string& server_tag,
35 const std::string& name,
36 const std::string& parent_server_tag);
37
38 // Factory function for a top level PersistentPermanentEntity. Top level means
39 // that the entity's parent is the root entity (no PersistentPermanentEntity
40 // exists for root).
41 static std::unique_ptr<LoopbackServerEntity> CreateTopLevel(
42 const syncer::ModelType& model_type);
43
44 // Factory function for creating an updated version of a
45 // PersistentPermanentEntity. This function should only be called for the
46 // Nigori entity.
47 static std::unique_ptr<LoopbackServerEntity> CreateUpdatedNigoriEntity(
48 const sync_pb::SyncEntity& client_entity,
49 const LoopbackServerEntity& current_server_entity);
50
51 // LoopbackServerEntity implementation.
52 bool RequiresParentId() const override;
53 std::string GetParentId() const override;
54 void SerializeAsProto(sync_pb::SyncEntity* proto) const override;
55 bool IsFolder() const override;
56 bool IsPermanent() const override;
57 sync_pb::LoopbackServerEntity_Type GetLoopbackServerEntityType()
58 const override;
59
60 private:
61 // All member values have equivalent fields in SyncEntity.
62 std::string server_defined_unique_tag_;
63 std::string parent_id_;
64 };
65
66 } // namespace syncer
67
68 #endif // COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_PERSISTENT_PERMANENT_ENTI TY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698