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

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

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 CHROME_BROWSER_SYNC_ENGINE_SYNCPROTO_H_
8 #define CHROME_BROWSER_SYNC_ENGINE_SYNCPROTO_H_
9
10 #include "chrome/browser/sync/protocol/sync.pb.h"
11 #include "chrome/browser/sync/syncable/syncable_id.h"
12
13 namespace browser_sync {
14
15 template<class Base>
16 class IdWrapper : public Base {
17 public:
18 syncable::Id id() const {
19 return syncable::Id::CreateFromServerId(Base::id_string());
20 }
21 void set_id(const syncable::Id& id) {
22 Base::set_id_string(id.GetServerId());
23 }
24 };
25
26 // These wrapper classes contain no data, so their super
27 // classes can be cast to them directly.
28 class SyncEntity : public IdWrapper<sync_pb::SyncEntity> {
29 public:
30 void set_parent_id(const syncable::Id& id) {
31 set_parent_id_string(id.GetServerId());
32 }
33 syncable::Id parent_id() const {
34 return syncable::Id::CreateFromServerId(parent_id_string());
35 }
36 void set_old_parent_id(const syncable::Id& id) {
37 IdWrapper<sync_pb::SyncEntity>::set_old_parent_id(
38 id.GetServerId());
39 }
40 syncable::Id old_parent_id() const {
41 return syncable::Id::CreateFromServerId(
42 sync_pb::SyncEntity::old_parent_id());
43 }
44 // Binary predicate helper to determine whether an Entity represents a folder
45 // or non-folder object. Use this instead of checking these properties
46 // directly, because the addition of bookmarks to the protobuf schema
47 // makes the check slightly more tricky.
48 bool IsFolder() const {
49 return (!has_bookmarkdata() || bookmarkdata().bookmark_folder());
50 }
51 };
52
53 class CommitResponse_EntryResponse
54 : public IdWrapper<sync_pb::CommitResponse_EntryResponse> {
55 };
56
57 class ClientToServerMessage : public sync_pb::ClientToServerMessage {
58 public:
59 ClientToServerMessage() {
60 set_protocol_version(protocol_version());
61 }
62 };
63
64 typedef sync_pb::CommitMessage CommitMessage;
65 typedef sync_pb::ClientToServerResponse ClientToServerResponse;
66 typedef sync_pb::CommitResponse CommitResponse;
67 typedef sync_pb::GetUpdatesResponse GetUpdatesResponse;
68 typedef sync_pb::GetUpdatesMessage GetUpdatesMessage;
69
70 } // namespace browser_sync
71
72 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCPROTO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698