OLD | NEW |
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 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 <stdint.h> |
| 9 |
8 #include <iosfwd> | 10 #include <iosfwd> |
9 #include <string> | 11 #include <string> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/basictypes.h" | |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "sync/api/attachments/attachment_id.h" | 18 #include "sync/api/attachments/attachment_id.h" |
18 #include "sync/base/sync_export.h" | 19 #include "sync/base/sync_export.h" |
19 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" | 20 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" |
20 #include "sync/internal_api/public/base/model_type.h" | 21 #include "sync/internal_api/public/base/model_type.h" |
21 #include "sync/internal_api/public/util/immutable.h" | 22 #include "sync/internal_api/public/util/immutable.h" |
22 #include "sync/internal_api/public/util/weak_handle.h" | 23 #include "sync/internal_api/public/util/weak_handle.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const std::string& non_unique_title, | 65 const std::string& non_unique_title, |
65 const sync_pb::EntitySpecifics& specifics); | 66 const sync_pb::EntitySpecifics& specifics); |
66 static SyncData CreateLocalDataWithAttachments( | 67 static SyncData CreateLocalDataWithAttachments( |
67 const std::string& sync_tag, | 68 const std::string& sync_tag, |
68 const std::string& non_unique_title, | 69 const std::string& non_unique_title, |
69 const sync_pb::EntitySpecifics& specifics, | 70 const sync_pb::EntitySpecifics& specifics, |
70 const AttachmentIdList& attachment_ids); | 71 const AttachmentIdList& attachment_ids); |
71 | 72 |
72 // Helper method for creating SyncData objects originating from the syncer. | 73 // Helper method for creating SyncData objects originating from the syncer. |
73 static SyncData CreateRemoteData( | 74 static SyncData CreateRemoteData( |
74 int64 id, | 75 int64_t id, |
75 const sync_pb::EntitySpecifics& specifics, | 76 const sync_pb::EntitySpecifics& specifics, |
76 const base::Time& last_modified_time, | 77 const base::Time& last_modified_time, |
77 const AttachmentIdList& attachment_ids, | 78 const AttachmentIdList& attachment_ids, |
78 const syncer::AttachmentServiceProxy& attachment_service); | 79 const syncer::AttachmentServiceProxy& attachment_service); |
79 | 80 |
80 // Whether this SyncData holds valid data. The only way to have a SyncData | 81 // Whether this SyncData holds valid data. The only way to have a SyncData |
81 // without valid data is to use the default constructor. | 82 // without valid data is to use the default constructor. |
82 bool IsValid() const; | 83 bool IsValid() const; |
83 | 84 |
84 // Return the datatype we're holding information about. Derived from the sync | 85 // Return the datatype we're holding information about. Derived from the sync |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 122 |
122 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper); | 123 static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper); |
123 | 124 |
124 static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2); | 125 static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2); |
125 }; | 126 }; |
126 | 127 |
127 typedef Immutable<sync_pb::SyncEntity, ImmutableSyncEntityTraits> | 128 typedef Immutable<sync_pb::SyncEntity, ImmutableSyncEntityTraits> |
128 ImmutableSyncEntity; | 129 ImmutableSyncEntity; |
129 | 130 |
130 // Equal to kInvalidId iff this is local. | 131 // Equal to kInvalidId iff this is local. |
131 int64 id_; | 132 int64_t id_; |
132 | 133 |
133 // This may be null if the SyncData represents a deleted item. | 134 // This may be null if the SyncData represents a deleted item. |
134 base::Time remote_modification_time_; | 135 base::Time remote_modification_time_; |
135 | 136 |
136 // The actual shared sync entity being held. | 137 // The actual shared sync entity being held. |
137 ImmutableSyncEntity immutable_entity_; | 138 ImmutableSyncEntity immutable_entity_; |
138 | 139 |
139 AttachmentServiceProxy attachment_service_; | 140 AttachmentServiceProxy attachment_service_; |
140 | 141 |
141 private: | 142 private: |
142 // Whether this SyncData holds valid data. | 143 // Whether this SyncData holds valid data. |
143 bool is_valid_; | 144 bool is_valid_; |
144 | 145 |
145 // Clears |entity| and |attachments|. | 146 // Clears |entity| and |attachments|. |
146 SyncData(int64 id, | 147 SyncData(int64_t id, |
147 sync_pb::SyncEntity* entity, | 148 sync_pb::SyncEntity* entity, |
148 const base::Time& remote_modification_time, | 149 const base::Time& remote_modification_time, |
149 const syncer::AttachmentServiceProxy& attachment_service); | 150 const syncer::AttachmentServiceProxy& attachment_service); |
150 }; | 151 }; |
151 | 152 |
152 // A SyncData going to the syncer. | 153 // A SyncData going to the syncer. |
153 class SYNC_EXPORT SyncDataLocal : public SyncData { | 154 class SYNC_EXPORT SyncDataLocal : public SyncData { |
154 public: | 155 public: |
155 // Construct a SyncDataLocal from a SyncData. | 156 // Construct a SyncDataLocal from a SyncData. |
156 // | 157 // |
(...skipping 12 matching lines...) Expand all Loading... |
169 // Construct a SyncDataRemote from a SyncData. | 170 // Construct a SyncDataRemote from a SyncData. |
170 // | 171 // |
171 // |sync_data|'s IsLocal() must be false. | 172 // |sync_data|'s IsLocal() must be false. |
172 explicit SyncDataRemote(const SyncData& sync_data); | 173 explicit SyncDataRemote(const SyncData& sync_data); |
173 ~SyncDataRemote(); | 174 ~SyncDataRemote(); |
174 | 175 |
175 // Return the last motification time according to the server. This may be null | 176 // Return the last motification time according to the server. This may be null |
176 // if the SyncData represents a deleted item. | 177 // if the SyncData represents a deleted item. |
177 const base::Time& GetModifiedTime() const; | 178 const base::Time& GetModifiedTime() const; |
178 | 179 |
179 int64 GetId() const; | 180 int64_t GetId() const; |
180 | 181 |
181 // Retrieve the attachments indentified by |attachment_ids|. Invoke | 182 // Retrieve the attachments indentified by |attachment_ids|. Invoke |
182 // |callback| with the requested attachments. | 183 // |callback| with the requested attachments. |
183 // | 184 // |
184 // |callback| will be invoked when the operation is complete (successfully | 185 // |callback| will be invoked when the operation is complete (successfully |
185 // or otherwise). | 186 // or otherwise). |
186 // | 187 // |
187 // Retrieving the requested attachments may require reading local storage or | 188 // Retrieving the requested attachments may require reading local storage or |
188 // requesting the attachments from the network. | 189 // requesting the attachments from the network. |
189 // | 190 // |
190 void GetOrDownloadAttachments( | 191 void GetOrDownloadAttachments( |
191 const AttachmentIdList& attachment_ids, | 192 const AttachmentIdList& attachment_ids, |
192 const AttachmentService::GetOrDownloadCallback& callback); | 193 const AttachmentService::GetOrDownloadCallback& callback); |
193 }; | 194 }; |
194 | 195 |
195 // gmock printer helper. | 196 // gmock printer helper. |
196 void SYNC_EXPORT PrintTo(const SyncData& sync_data, std::ostream* os); | 197 void SYNC_EXPORT PrintTo(const SyncData& sync_data, std::ostream* os); |
197 | 198 |
198 typedef std::vector<SyncData> SyncDataList; | 199 typedef std::vector<SyncData> SyncDataList; |
199 | 200 |
200 } // namespace syncer | 201 } // namespace syncer |
201 | 202 |
202 #endif // SYNC_API_SYNC_DATA_H_ | 203 #endif // SYNC_API_SYNC_DATA_H_ |
OLD | NEW |