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

Side by Side Diff: sync/api/sync_data.h

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent 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/api/sync_change_unittest.cc ('k') | sync/api/sync_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SYNC_API_SYNC_DATA_H_ 5 #ifndef SYNC_API_SYNC_DATA_H_
6 #define SYNC_API_SYNC_DATA_H_ 6 #define SYNC_API_SYNC_DATA_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "sync/internal_api/public/base/model_type.h" 13 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/internal_api/public/util/immutable.h" 14 #include "sync/internal_api/public/util/immutable.h"
15 15
16 namespace sync_pb { 16 namespace sync_pb {
17 class EntitySpecifics; 17 class EntitySpecifics;
18 class SyncEntity; 18 class SyncEntity;
19 } // namespace sync_pb 19 } // namespace sync_pb
20 20
21 namespace syncer { 21 namespace syncer {
22 22
23 typedef syncer::ModelType SyncDataType;
24
25 // A light-weight container for immutable sync data. Pass-by-value and storage 23 // A light-weight container for immutable sync data. Pass-by-value and storage
26 // in STL containers are supported and encouraged if helpful. 24 // in STL containers are supported and encouraged if helpful.
27 class SyncData { 25 class SyncData {
28 public: 26 public:
29 // Creates an empty and invalid SyncData. 27 // Creates an empty and invalid SyncData.
30 SyncData(); 28 SyncData();
31 ~SyncData(); 29 ~SyncData();
32 30
33 // Default copy and assign welcome. 31 // Default copy and assign welcome.
34 32
35 // Helper methods for creating SyncData objects for local data. 33 // Helper methods for creating SyncData objects for local data.
36 // The sync tag must be a string unique to this datatype and is used as a node 34 // The sync tag must be a string unique to this datatype and is used as a node
37 // identifier server-side. 35 // identifier server-side.
38 // For deletes: |datatype| must specify the datatype who node is being 36 // For deletes: |datatype| must specify the datatype who node is being
39 // deleted. 37 // deleted.
40 // For adds/updates: the specifics must be valid and the non-unique title (can 38 // For adds/updates: the specifics must be valid and the non-unique title (can
41 // be the same as sync tag) must be specfied. 39 // be the same as sync tag) must be specfied.
42 // Note: the non_unique_title is primarily for debug purposes, and will be 40 // Note: the non_unique_title is primarily for debug purposes, and will be
43 // overwritten if the datatype is encrypted. 41 // overwritten if the datatype is encrypted.
44 static SyncData CreateLocalDelete( 42 static SyncData CreateLocalDelete(
45 const std::string& sync_tag, 43 const std::string& sync_tag,
46 syncer::ModelType datatype); 44 ModelType datatype);
47 static SyncData CreateLocalData( 45 static SyncData CreateLocalData(
48 const std::string& sync_tag, 46 const std::string& sync_tag,
49 const std::string& non_unique_title, 47 const std::string& non_unique_title,
50 const sync_pb::EntitySpecifics& specifics); 48 const sync_pb::EntitySpecifics& specifics);
51 49
52 // Helper method for creating SyncData objects originating from the syncer. 50 // Helper method for creating SyncData objects originating from the syncer.
53 static SyncData CreateRemoteData( 51 static SyncData CreateRemoteData(
54 int64 id, const sync_pb::EntitySpecifics& specifics); 52 int64 id, const sync_pb::EntitySpecifics& specifics);
55 53
56 // Whether this SyncData holds valid data. The only way to have a SyncData 54 // Whether this SyncData holds valid data. The only way to have a SyncData
57 // without valid data is to use the default constructor. 55 // without valid data is to use the default constructor.
58 bool IsValid() const; 56 bool IsValid() const;
59 57
60 // Return the datatype we're holding information about. Derived from the sync 58 // Return the datatype we're holding information about. Derived from the sync
61 // datatype specifics. 59 // datatype specifics.
62 SyncDataType GetDataType() const; 60 ModelType GetDataType() const;
63 61
64 // Return the current sync datatype specifics. 62 // Return the current sync datatype specifics.
65 const sync_pb::EntitySpecifics& GetSpecifics() const; 63 const sync_pb::EntitySpecifics& GetSpecifics() const;
66 64
67 // Returns the value of the unique client tag. This is only set for data going 65 // Returns the value of the unique client tag. This is only set for data going
68 // TO the syncer, not coming from. 66 // TO the syncer, not coming from.
69 const std::string& GetTag() const; 67 const std::string& GetTag() const;
70 68
71 // Returns the non unique title (for debugging). Currently only set for data 69 // Returns the non unique title (for debugging). Currently only set for data
72 // going TO the syncer, not from. 70 // going TO the syncer, not from.
(...skipping 19 matching lines...) Expand all
92 90
93 static void DestroyWrapper(Wrapper* wrapper); 91 static void DestroyWrapper(Wrapper* wrapper);
94 92
95 static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper); 93 static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper);
96 94
97 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper); 95 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper);
98 96
99 static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2); 97 static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2);
100 }; 98 };
101 99
102 typedef syncer::Immutable< 100 typedef Immutable<sync_pb::SyncEntity, ImmutableSyncEntityTraits>
103 sync_pb::SyncEntity, ImmutableSyncEntityTraits>
104 ImmutableSyncEntity; 101 ImmutableSyncEntity;
105 102
106 // Clears |entity|. 103 // Clears |entity|.
107 SyncData(int64 id, sync_pb::SyncEntity* entity); 104 SyncData(int64 id, sync_pb::SyncEntity* entity);
108 105
109 // Whether this SyncData holds valid data. 106 // Whether this SyncData holds valid data.
110 bool is_valid_; 107 bool is_valid_;
111 108
112 // Equal to syncer::kInvalidId iff this is local. 109 // Equal to kInvalidId iff this is local.
113 int64 id_; 110 int64 id_;
114 111
115 // The actual shared sync entity being held. 112 // The actual shared sync entity being held.
116 ImmutableSyncEntity immutable_entity_; 113 ImmutableSyncEntity immutable_entity_;
117 }; 114 };
118 115
119 // gmock printer helper. 116 // gmock printer helper.
120 void PrintTo(const SyncData& sync_data, std::ostream* os); 117 void PrintTo(const SyncData& sync_data, std::ostream* os);
121 118
122 } // namespace syncer 119 } // namespace syncer
123 120
124 #endif // SYNC_API_SYNC_DATA_H_ 121 #endif // SYNC_API_SYNC_DATA_H_
OLDNEW
« no previous file with comments | « sync/api/sync_change_unittest.cc ('k') | sync/api/sync_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698