| 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 <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 "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "sync/api/attachments/attachment.h" | 17 #include "sync/api/attachments/attachment.h" |
| 17 #include "sync/api/attachments/attachment_service_proxy.h" | 18 #include "sync/api/attachments/attachment_service_proxy.h" |
| 18 #include "sync/base/sync_export.h" | 19 #include "sync/base/sync_export.h" |
| 19 #include "sync/internal_api/public/base/model_type.h" | 20 #include "sync/internal_api/public/base/model_type.h" |
| 20 #include "sync/internal_api/public/util/immutable.h" | 21 #include "sync/internal_api/public/util/immutable.h" |
| 21 #include "sync/internal_api/public/util/weak_handle.h" | 22 #include "sync/internal_api/public/util/weak_handle.h" |
| 22 | 23 |
| 23 namespace sync_pb { | 24 namespace sync_pb { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const std::string& sync_tag, | 58 const std::string& sync_tag, |
| 58 const std::string& non_unique_title, | 59 const std::string& non_unique_title, |
| 59 const sync_pb::EntitySpecifics& specifics); | 60 const sync_pb::EntitySpecifics& specifics); |
| 60 static SyncData CreateLocalDataWithAttachments( | 61 static SyncData CreateLocalDataWithAttachments( |
| 61 const std::string& sync_tag, | 62 const std::string& sync_tag, |
| 62 const std::string& non_unique_title, | 63 const std::string& non_unique_title, |
| 63 const sync_pb::EntitySpecifics& specifics, | 64 const sync_pb::EntitySpecifics& specifics, |
| 64 const AttachmentList& attachments); | 65 const AttachmentList& attachments); |
| 65 | 66 |
| 66 // Helper method for creating SyncData objects originating from the syncer. | 67 // Helper method for creating SyncData objects originating from the syncer. |
| 67 // | |
| 68 // TODO(maniscalco): Replace all calls to 3-arg CreateRemoteData with calls to | |
| 69 // the 5-arg version (bug 353296). | |
| 70 static SyncData CreateRemoteData( | 68 static SyncData CreateRemoteData( |
| 71 int64 id, | 69 int64 id, |
| 72 const sync_pb::EntitySpecifics& specifics, | 70 const sync_pb::EntitySpecifics& specifics, |
| 73 const base::Time& last_modified_time, | 71 const base::Time& last_modified_time, |
| 74 const AttachmentIdList& attachment_ids, | 72 const AttachmentIdList& attachment_ids, |
| 75 const syncer::AttachmentServiceProxy& attachment_service); | 73 const scoped_refptr<syncer::AttachmentServiceProxy>& attachment_service); |
| 76 static SyncData CreateRemoteData(int64 id, | |
| 77 const sync_pb::EntitySpecifics& specifics, | |
| 78 const base::Time& last_modified_time); | |
| 79 | 74 |
| 80 // Whether this SyncData holds valid data. The only way to have a SyncData | 75 // Whether this SyncData holds valid data. The only way to have a SyncData |
| 81 // without valid data is to use the default constructor. | 76 // without valid data is to use the default constructor. |
| 82 bool IsValid() const; | 77 bool IsValid() const; |
| 83 | 78 |
| 84 // Return the datatype we're holding information about. Derived from the sync | 79 // Return the datatype we're holding information about. Derived from the sync |
| 85 // datatype specifics. | 80 // datatype specifics. |
| 86 ModelType GetDataType() const; | 81 ModelType GetDataType() const; |
| 87 | 82 |
| 88 // Return the current sync datatype specifics. | 83 // Return the current sync datatype specifics. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 int64 id_; | 126 int64 id_; |
| 132 | 127 |
| 133 // This may be null if the SyncData represents a deleted item. | 128 // This may be null if the SyncData represents a deleted item. |
| 134 base::Time remote_modification_time_; | 129 base::Time remote_modification_time_; |
| 135 | 130 |
| 136 // The actual shared sync entity being held. | 131 // The actual shared sync entity being held. |
| 137 ImmutableSyncEntity immutable_entity_; | 132 ImmutableSyncEntity immutable_entity_; |
| 138 | 133 |
| 139 Immutable<AttachmentList> attachments_; | 134 Immutable<AttachmentList> attachments_; |
| 140 | 135 |
| 141 AttachmentServiceProxy attachment_service_; | 136 scoped_refptr<AttachmentServiceProxy> attachment_service_; |
| 142 | 137 |
| 143 private: | 138 private: |
| 144 // Whether this SyncData holds valid data. | 139 // Whether this SyncData holds valid data. |
| 145 bool is_valid_; | 140 bool is_valid_; |
| 146 | 141 |
| 147 // Clears |entity| and |attachments|. | 142 // Clears |entity| and |attachments|. |
| 148 SyncData(int64 id, | 143 SyncData( |
| 149 sync_pb::SyncEntity* entity, | 144 int64 id, |
| 150 AttachmentList* attachments, | 145 sync_pb::SyncEntity* entity, |
| 151 const base::Time& remote_modification_time, | 146 AttachmentList* attachments, |
| 152 const syncer::AttachmentServiceProxy& attachment_service); | 147 const base::Time& remote_modification_time, |
| 148 const scoped_refptr<syncer::AttachmentServiceProxy>& attachment_service); |
| 153 }; | 149 }; |
| 154 | 150 |
| 155 // A SyncData going to the syncer. | 151 // A SyncData going to the syncer. |
| 156 class SYNC_EXPORT SyncDataLocal : public SyncData { | 152 class SYNC_EXPORT SyncDataLocal : public SyncData { |
| 157 public: | 153 public: |
| 158 // Construct a SyncDataLocal from a SyncData. | 154 // Construct a SyncDataLocal from a SyncData. |
| 159 // | 155 // |
| 160 // |sync_data|'s IsLocal() must be true. | 156 // |sync_data|'s IsLocal() must be true. |
| 161 explicit SyncDataLocal(const SyncData& sync_data); | 157 explicit SyncDataLocal(const SyncData& sync_data); |
| 162 ~SyncDataLocal(); | 158 ~SyncDataLocal(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 }; | 204 }; |
| 209 | 205 |
| 210 // gmock printer helper. | 206 // gmock printer helper. |
| 211 void PrintTo(const SyncData& sync_data, std::ostream* os); | 207 void PrintTo(const SyncData& sync_data, std::ostream* os); |
| 212 | 208 |
| 213 typedef std::vector<SyncData> SyncDataList; | 209 typedef std::vector<SyncData> SyncDataList; |
| 214 | 210 |
| 215 } // namespace syncer | 211 } // namespace syncer |
| 216 | 212 |
| 217 #endif // SYNC_API_SYNC_DATA_H_ | 213 #endif // SYNC_API_SYNC_DATA_H_ |
| OLD | NEW |