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

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

Issue 2240613002: [Sync] Convert sync to a static library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try getting rid of sync_core source set. Created 4 years, 4 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
« no previous file with comments | « components/sync/api/sync_change_processor.h ('k') | components/sync/api/sync_error.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 COMPONENTS_SYNC_API_SYNC_DATA_H_ 5 #ifndef COMPONENTS_SYNC_API_SYNC_DATA_H_
6 #define COMPONENTS_SYNC_API_SYNC_DATA_H_ 6 #define COMPONENTS_SYNC_API_SYNC_DATA_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iosfwd> 10 #include <iosfwd>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/sync/api/attachments/attachment_id.h" 18 #include "components/sync/api/attachments/attachment_id.h"
19 #include "components/sync/base/immutable.h" 19 #include "components/sync/base/immutable.h"
20 #include "components/sync/base/model_type.h" 20 #include "components/sync/base/model_type.h"
21 #include "components/sync/base/sync_export.h"
22 #include "components/sync/base/weak_handle.h" 21 #include "components/sync/base/weak_handle.h"
23 #include "components/sync/core/attachments/attachment_service_proxy.h" 22 #include "components/sync/core/attachments/attachment_service_proxy.h"
24 23
25 namespace sync_pb { 24 namespace sync_pb {
26 class EntitySpecifics; 25 class EntitySpecifics;
27 class SyncEntity; 26 class SyncEntity;
28 } // namespace sync_pb 27 } // namespace sync_pb
29 28
30 namespace syncer { 29 namespace syncer {
31 30
32 class AttachmentService; 31 class AttachmentService;
33 class SyncDataLocal; 32 class SyncDataLocal;
34 class SyncDataRemote; 33 class SyncDataRemote;
35 34
36 // A light-weight container for immutable sync data. Pass-by-value and storage 35 // A light-weight container for immutable sync data. Pass-by-value and storage
37 // in STL containers are supported and encouraged if helpful. 36 // in STL containers are supported and encouraged if helpful.
38 class SYNC_EXPORT SyncData { 37 class SyncData {
39 public: 38 public:
40 // Creates an empty and invalid SyncData. 39 // Creates an empty and invalid SyncData.
41 SyncData(); 40 SyncData();
42 SyncData(const SyncData& other); 41 SyncData(const SyncData& other);
43 ~SyncData(); 42 ~SyncData();
44 43
45 // Default copy and assign welcome. 44 // Default copy and assign welcome.
46 45
47 // Helper methods for creating SyncData objects for local data. 46 // Helper methods for creating SyncData objects for local data.
48 // 47 //
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 AttachmentIdList GetAttachmentIds() const; 103 AttachmentIdList GetAttachmentIds() const;
105 104
106 // TODO(zea): Query methods for other sync properties: parent, successor, etc. 105 // TODO(zea): Query methods for other sync properties: parent, successor, etc.
107 106
108 protected: 107 protected:
109 // These data members are protected so derived types like SyncDataLocal and 108 // These data members are protected so derived types like SyncDataLocal and
110 // SyncDataRemote can access them. 109 // SyncDataRemote can access them.
111 110
112 // Necessary since we forward-declare sync_pb::SyncEntity; see 111 // Necessary since we forward-declare sync_pb::SyncEntity; see
113 // comments in immutable.h. 112 // comments in immutable.h.
114 struct SYNC_EXPORT ImmutableSyncEntityTraits { 113 struct ImmutableSyncEntityTraits {
115 typedef sync_pb::SyncEntity* Wrapper; 114 typedef sync_pb::SyncEntity* Wrapper;
116 115
117 static void InitializeWrapper(Wrapper* wrapper); 116 static void InitializeWrapper(Wrapper* wrapper);
118 117
119 static void DestroyWrapper(Wrapper* wrapper); 118 static void DestroyWrapper(Wrapper* wrapper);
120 119
121 static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper); 120 static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper);
122 121
123 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper); 122 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper);
124 123
(...skipping 19 matching lines...) Expand all
144 bool is_valid_; 143 bool is_valid_;
145 144
146 // Clears |entity| and |attachments|. 145 // Clears |entity| and |attachments|.
147 SyncData(int64_t id, 146 SyncData(int64_t id,
148 sync_pb::SyncEntity* entity, 147 sync_pb::SyncEntity* entity,
149 const base::Time& remote_modification_time, 148 const base::Time& remote_modification_time,
150 const syncer::AttachmentServiceProxy& attachment_service); 149 const syncer::AttachmentServiceProxy& attachment_service);
151 }; 150 };
152 151
153 // A SyncData going to the syncer. 152 // A SyncData going to the syncer.
154 class SYNC_EXPORT SyncDataLocal : public SyncData { 153 class SyncDataLocal : public SyncData {
155 public: 154 public:
156 // Construct a SyncDataLocal from a SyncData. 155 // Construct a SyncDataLocal from a SyncData.
157 // 156 //
158 // |sync_data|'s IsLocal() must be true. 157 // |sync_data|'s IsLocal() must be true.
159 explicit SyncDataLocal(const SyncData& sync_data); 158 explicit SyncDataLocal(const SyncData& sync_data);
160 ~SyncDataLocal(); 159 ~SyncDataLocal();
161 160
162 // Return the value of the unique client tag. This is only set for data going 161 // Return the value of the unique client tag. This is only set for data going
163 // TO the syncer, not coming from. 162 // TO the syncer, not coming from.
164 const std::string& GetTag() const; 163 const std::string& GetTag() const;
165 }; 164 };
166 165
167 // A SyncData that comes from the syncer. 166 // A SyncData that comes from the syncer.
168 class SYNC_EXPORT SyncDataRemote : public SyncData { 167 class SyncDataRemote : public SyncData {
169 public: 168 public:
170 // Construct a SyncDataRemote from a SyncData. 169 // Construct a SyncDataRemote from a SyncData.
171 // 170 //
172 // |sync_data|'s IsLocal() must be false. 171 // |sync_data|'s IsLocal() must be false.
173 explicit SyncDataRemote(const SyncData& sync_data); 172 explicit SyncDataRemote(const SyncData& sync_data);
174 ~SyncDataRemote(); 173 ~SyncDataRemote();
175 174
176 // Return the last motification time according to the server. This may be null 175 // Return the last motification time according to the server. This may be null
177 // if the SyncData represents a deleted item. 176 // if the SyncData represents a deleted item.
178 const base::Time& GetModifiedTime() const; 177 const base::Time& GetModifiedTime() const;
(...skipping 12 matching lines...) Expand all
191 // 190 //
192 // Retrieving the requested attachments may require reading local storage or 191 // Retrieving the requested attachments may require reading local storage or
193 // requesting the attachments from the network. 192 // requesting the attachments from the network.
194 // 193 //
195 void GetOrDownloadAttachments( 194 void GetOrDownloadAttachments(
196 const AttachmentIdList& attachment_ids, 195 const AttachmentIdList& attachment_ids,
197 const AttachmentService::GetOrDownloadCallback& callback); 196 const AttachmentService::GetOrDownloadCallback& callback);
198 }; 197 };
199 198
200 // gmock printer helper. 199 // gmock printer helper.
201 void SYNC_EXPORT PrintTo(const SyncData& sync_data, std::ostream* os); 200 void PrintTo(const SyncData& sync_data, std::ostream* os);
202 201
203 typedef std::vector<SyncData> SyncDataList; 202 typedef std::vector<SyncData> SyncDataList;
204 203
205 } // namespace syncer 204 } // namespace syncer
206 205
207 #endif // COMPONENTS_SYNC_API_SYNC_DATA_H_ 206 #endif // COMPONENTS_SYNC_API_SYNC_DATA_H_
OLDNEW
« no previous file with comments | « components/sync/api/sync_change_processor.h ('k') | components/sync/api/sync_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698