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 COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ | 5 #ifndef COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ |
6 #define COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ | 6 #define COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // Note: |cryptographer| is an optional parameter for use in decrypting | 375 // Note: |cryptographer| is an optional parameter for use in decrypting |
376 // encrypted specifics. If it is NULL or the specifics are not decryptsble, | 376 // encrypted specifics. If it is NULL or the specifics are not decryptsble, |
377 // they will be serialized as empty proto's. | 377 // they will be serialized as empty proto's. |
378 base::DictionaryValue* ToValue(Cryptographer* cryptographer) const; | 378 base::DictionaryValue* ToValue(Cryptographer* cryptographer) const; |
379 | 379 |
380 private: | 380 private: |
381 // Tracks whether this entry needs to be saved to the database. | 381 // Tracks whether this entry needs to be saved to the database. |
382 bool dirty_; | 382 bool dirty_; |
383 }; | 383 }; |
384 | 384 |
| 385 template <typename T> |
385 class EntryKernelLessByMetaHandle { | 386 class EntryKernelLessByMetaHandle { |
386 public: | 387 public: |
387 inline bool operator()(const EntryKernel* a, const EntryKernel* b) const { | 388 inline bool operator()(T a, T b) const { |
388 return a->ref(META_HANDLE) < b->ref(META_HANDLE); | 389 return a->ref(META_HANDLE) < b->ref(META_HANDLE); |
389 } | 390 } |
390 }; | 391 }; |
391 | 392 |
392 typedef std::set<const EntryKernel*, EntryKernelLessByMetaHandle> | 393 typedef std::set<const EntryKernel*, |
| 394 EntryKernelLessByMetaHandle<const EntryKernel*>> |
393 EntryKernelSet; | 395 EntryKernelSet; |
394 | 396 |
| 397 typedef std::set< |
| 398 std::unique_ptr<EntryKernel>, |
| 399 EntryKernelLessByMetaHandle<const std::unique_ptr<EntryKernel>&>> |
| 400 OwnedEntryKernelSet; |
| 401 |
395 struct EntryKernelMutation { | 402 struct EntryKernelMutation { |
396 EntryKernel original, mutated; | 403 EntryKernel original, mutated; |
397 }; | 404 }; |
398 | 405 |
399 typedef std::map<int64_t, EntryKernelMutation> EntryKernelMutationMap; | 406 typedef std::map<int64_t, EntryKernelMutation> EntryKernelMutationMap; |
400 | 407 |
401 typedef Immutable<EntryKernelMutationMap> ImmutableEntryKernelMutationMap; | 408 typedef Immutable<EntryKernelMutationMap> ImmutableEntryKernelMutationMap; |
402 | 409 |
403 std::unique_ptr<base::DictionaryValue> EntryKernelMutationToValue( | 410 std::unique_ptr<base::DictionaryValue> EntryKernelMutationToValue( |
404 const EntryKernelMutation& mutation); | 411 const EntryKernelMutation& mutation); |
405 | 412 |
406 std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue( | 413 std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue( |
407 const EntryKernelMutationMap& mutations); | 414 const EntryKernelMutationMap& mutations); |
408 | 415 |
409 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel); | 416 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel); |
410 | 417 |
411 } // namespace syncable | 418 } // namespace syncable |
412 } // namespace syncer | 419 } // namespace syncer |
413 | 420 |
414 #endif // COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ | 421 #endif // COMPONENTS_SYNC_SYNCABLE_ENTRY_KERNEL_H_ |
OLD | NEW |