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 #include "sync/internal_api/public/test/test_entry_factory.h" | 5 #include "sync/internal_api/public/test/test_entry_factory.h" |
6 | 6 |
7 #include "sync/syncable/directory.h" | 7 #include "sync/syncable/directory.h" |
8 #include "sync/syncable/entry.h" | 8 #include "sync/syncable/entry.h" |
9 #include "sync/syncable/mutable_entry.h" | 9 #include "sync/syncable/mutable_entry.h" |
10 #include "sync/syncable/syncable_id.h" | 10 #include "sync/syncable/syncable_id.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 | 233 |
234 const sync_pb::EntitySpecifics& TestEntryFactory::GetLocalSpecificsForItem( | 234 const sync_pb::EntitySpecifics& TestEntryFactory::GetLocalSpecificsForItem( |
235 int64 meta_handle) const { | 235 int64 meta_handle) const { |
236 syncable::ReadTransaction trans(FROM_HERE, directory_); | 236 syncable::ReadTransaction trans(FROM_HERE, directory_); |
237 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); | 237 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
238 DCHECK(entry.good()); | 238 DCHECK(entry.good()); |
239 return entry.GetSpecifics(); | 239 return entry.GetSpecifics(); |
240 } | 240 } |
241 | 241 |
| 242 bool TestEntryFactory::SetServerAttachmentMetadataForItem( |
| 243 int64 meta_handle, |
| 244 const sync_pb::AttachmentMetadata metadata) { |
| 245 WriteTransaction trans(FROM_HERE, UNITTEST, directory_); |
| 246 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
| 247 if (!entry.good()) { |
| 248 return false; |
| 249 } |
| 250 entry.PutServerAttachmentMetadata(metadata); |
| 251 entry.PutIsUnappliedUpdate(true); |
| 252 return true; |
| 253 |
| 254 } |
| 255 |
| 256 bool TestEntryFactory::SetLocalAttachmentMetadataForItem( |
| 257 int64 meta_handle, |
| 258 const sync_pb::AttachmentMetadata metadata) { |
| 259 WriteTransaction trans(FROM_HERE, UNITTEST, directory_); |
| 260 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
| 261 if (!entry.good()) { |
| 262 return false; |
| 263 } |
| 264 entry.PutAttachmentMetadata(metadata); |
| 265 entry.PutIsUnsynced(true); |
| 266 return true; |
| 267 } |
| 268 |
| 269 const sync_pb::AttachmentMetadata& |
| 270 TestEntryFactory::GetServerAttachmentMetadataForItem(int64 meta_handle) const { |
| 271 syncable::ReadTransaction trans(FROM_HERE, directory_); |
| 272 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
| 273 DCHECK(entry.good()); |
| 274 return entry.GetServerAttachmentMetadata(); |
| 275 } |
| 276 |
| 277 const sync_pb::AttachmentMetadata& |
| 278 TestEntryFactory::GetLocalAttachmentMetadataForItem(int64 meta_handle) const { |
| 279 syncable::ReadTransaction trans(FROM_HERE, directory_); |
| 280 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
| 281 DCHECK(entry.good()); |
| 282 return entry.GetAttachmentMetadata(); |
| 283 } |
| 284 |
242 bool TestEntryFactory::GetIsUnsyncedForItem(int64 meta_handle) const { | 285 bool TestEntryFactory::GetIsUnsyncedForItem(int64 meta_handle) const { |
243 syncable::ReadTransaction trans(FROM_HERE, directory_); | 286 syncable::ReadTransaction trans(FROM_HERE, directory_); |
244 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); | 287 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
245 if (!entry.good()) { | 288 if (!entry.good()) { |
246 NOTREACHED(); | 289 NOTREACHED(); |
247 return false; | 290 return false; |
248 } | 291 } |
249 return entry.GetIsUnsynced(); | 292 return entry.GetIsUnsynced(); |
250 } | 293 } |
251 | 294 |
252 bool TestEntryFactory::GetIsUnappliedForItem(int64 meta_handle) const { | 295 bool TestEntryFactory::GetIsUnappliedForItem(int64 meta_handle) const { |
253 syncable::ReadTransaction trans(FROM_HERE, directory_); | 296 syncable::ReadTransaction trans(FROM_HERE, directory_); |
254 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); | 297 syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, meta_handle); |
255 if (!entry.good()) { | 298 if (!entry.good()) { |
256 NOTREACHED(); | 299 NOTREACHED(); |
257 return false; | 300 return false; |
258 } | 301 } |
259 return entry.GetIsUnappliedUpdate(); | 302 return entry.GetIsUnappliedUpdate(); |
260 } | 303 } |
261 | 304 |
262 int64 TestEntryFactory::GetNextRevision() { | 305 int64 TestEntryFactory::GetNextRevision() { |
263 return next_revision_++; | 306 return next_revision_++; |
264 } | 307 } |
265 | 308 |
266 } // namespace syncer | 309 } // namespace syncer |
OLD | NEW |