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

Side by Side Diff: components/sync/engine_impl/loopback_server/persistent_bookmark_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_BOOKMARK_ENTITY_H _
6 #define COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_PERSISTENT_BOOKMARK_ENTITY_H _
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <memory>
12 #include <string>
13
14 #include "components/sync/base/model_type.h"
15 #include "components/sync/engine_impl/loopback_server/loopback_server_entity.h"
16 #include "components/sync/protocol/sync.pb.h"
17
18 namespace syncer {
19
20 // A bookmark version of LoopbackServerEntity. This type represents entities
21 // that are non-deleted, client-created, and not unique per client account.
22 class PersistentBookmarkEntity : public LoopbackServerEntity {
23 public:
24 ~PersistentBookmarkEntity() override;
25
26 // Factory function for PersistentBookmarkEntity. This factory should be used
27 // only for the first time that a specific bookmark is seen by the server.
28 static std::unique_ptr<LoopbackServerEntity> CreateNew(
29 const sync_pb::SyncEntity& client_entity,
30 const std::string& parent_id,
31 const std::string& client_guid);
32
33 // Factory function for PersistentBookmarkEntity. The server's current entity
34 // for this ID, |current_server_entity|, is passed here because the client
35 // does not always send the complete entity over the wire. This requires
36 // copying of some of the existing entity when creating a new entity.
37 static std::unique_ptr<LoopbackServerEntity> CreateUpdatedVersion(
38 const sync_pb::SyncEntity& client_entity,
39 const LoopbackServerEntity& current_server_entity,
40 const std::string& parent_id);
41
42 // Factory function for PersistentBookmarkEntity used when de-serializing the
43 // information stored in the persistent storage.
44 static std::unique_ptr<LoopbackServerEntity> CreateFromEntity(
45 const sync_pb::SyncEntity& client_entity);
46
47 PersistentBookmarkEntity(const std::string& id,
48 int64_t version,
49 const std::string& name,
50 const std::string& originator_cache_guid,
51 const std::string& originator_client_item_id,
52 const sync_pb::UniquePosition& unique_position,
53 const sync_pb::EntitySpecifics& specifics,
54 bool is_folder,
55 const std::string& parent_id,
56 int64_t creation_time,
57 int64_t last_modified_time);
58
59 void SetParentId(const std::string& parent_id);
60
61 // LoopbackServerEntity implementation.
62 bool RequiresParentId() const override;
63 std::string GetParentId() const override;
64 void SerializeAsProto(sync_pb::SyncEntity* proto) const override;
65 bool IsFolder() const override;
66 sync_pb::LoopbackServerEntity_Type GetLoopbackServerEntityType()
67 const override;
68
69 private:
70 // All member values have equivalent fields in SyncEntity.
71 std::string originator_cache_guid_;
72 std::string originator_client_item_id_;
73 sync_pb::UniquePosition unique_position_;
74 bool is_folder_;
75 std::string parent_id_;
76 int64_t creation_time_;
77 int64_t last_modified_time_;
78 };
79
80 } // namespace syncer
81
82 #endif // COMPONENTS_SYNC_ENGINE_IMPL_LOOPBACK_SERVER_PERSISTENT_BOOKMARK_ENTIT Y_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698