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

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

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

Powered by Google App Engine
This is Rietveld 408576698