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

Side by Side Diff: sync/engine/syncproto.h

Issue 10735041: Remove syncproto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address most comments Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sync/engine/syncer_util.cc ('k') | sync/engine/syncproto_unittest.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 (c) 2012 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 // Wrappers to help us work with ids and protobuffers.
6
7 #ifndef SYNC_ENGINE_SYNCPROTO_H_
8 #define SYNC_ENGINE_SYNCPROTO_H_
9
10 #include "sync/internal_api/public/base/model_type.h"
11 #include "sync/protocol/sync.pb.h"
12 #include "sync/syncable/syncable_id.h"
13
14 namespace syncer {
15
16 template<class Base>
17 class IdWrapper : public Base {
18 public:
19 IdWrapper() {}
20 explicit IdWrapper(const Base& other) : Base(other) {
21 }
22 syncable::Id id() const {
23 return syncable::Id::CreateFromServerId(Base::id_string());
24 }
25 void set_id(const syncable::Id& id) {
26 Base::set_id_string(id.GetServerId());
27 }
28 };
29
30 // These wrapper classes contain no data, so their super classes can be cast to
31 // them directly.
32 class SyncEntity : public IdWrapper<sync_pb::SyncEntity> {
33 public:
34 SyncEntity() {}
35 explicit SyncEntity(const sync_pb::SyncEntity& other)
36 : IdWrapper<sync_pb::SyncEntity>(other) {
37 }
38
39 void set_parent_id(const syncable::Id& id) {
40 set_parent_id_string(id.GetServerId());
41 }
42 syncable::Id parent_id() const {
43 return syncable::Id::CreateFromServerId(parent_id_string());
44 }
45 void set_old_parent_id(const syncable::Id& id) {
46 IdWrapper<sync_pb::SyncEntity>::set_old_parent_id(
47 id.GetServerId());
48 }
49 syncable::Id old_parent_id() const {
50 return syncable::Id::CreateFromServerId(
51 sync_pb::SyncEntity::old_parent_id());
52 }
53 // Binary predicate helper to determine whether an Entity represents a folder
54 // or non-folder object. Use this instead of checking these properties
55 // directly, because the addition of bookmarks to the protobuf schema
56 // makes the check slightly more tricky.
57 bool IsFolder() const {
58 return ((has_folder() && folder()) ||
59 (has_bookmarkdata() && bookmarkdata().bookmark_folder()));
60 }
61
62 syncer::ModelType GetModelType() const {
63 return syncer::GetModelType(*this);
64 }
65 };
66
67 class CommitResponse_EntryResponse
68 : public IdWrapper<sync_pb::CommitResponse_EntryResponse> {
69 };
70
71 class ClientToServerMessage : public sync_pb::ClientToServerMessage {
72 public:
73 ClientToServerMessage() {
74 set_protocol_version(protocol_version());
75 }
76 };
77
78 typedef sync_pb::CommitMessage CommitMessage;
79 typedef sync_pb::ClientToServerResponse ClientToServerResponse;
80 typedef sync_pb::CommitResponse CommitResponse;
81 typedef sync_pb::GetUpdatesResponse GetUpdatesResponse;
82 typedef sync_pb::GetUpdatesMessage GetUpdatesMessage;
83
84 } // namespace syncer
85
86 #endif // SYNC_ENGINE_SYNCPROTO_H_
OLDNEW
« no previous file with comments | « sync/engine/syncer_util.cc ('k') | sync/engine/syncproto_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698