OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <bitset> | 10 #include <bitset> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "base/tracked.h" | 26 #include "base/tracked.h" |
27 #include "chrome/browser/sync/protocol/sync.pb.h" | 27 #include "chrome/browser/sync/protocol/sync.pb.h" |
28 #include "chrome/browser/sync/syncable/blob.h" | 28 #include "chrome/browser/sync/syncable/blob.h" |
29 #include "chrome/browser/sync/syncable/dir_open_result.h" | 29 #include "chrome/browser/sync/syncable/dir_open_result.h" |
30 #include "chrome/browser/sync/syncable/directory_event.h" | 30 #include "chrome/browser/sync/syncable/directory_event.h" |
31 #include "chrome/browser/sync/syncable/syncable_id.h" | 31 #include "chrome/browser/sync/syncable/syncable_id.h" |
32 #include "chrome/browser/sync/syncable/model_type.h" | 32 #include "chrome/browser/sync/syncable/model_type.h" |
33 #include "chrome/browser/sync/util/dbgq.h" | 33 #include "chrome/browser/sync/util/dbgq.h" |
34 #include "chrome/common/deprecated/event_sys.h" | 34 #include "chrome/common/deprecated/event_sys.h" |
35 | 35 |
| 36 struct PurgeInfo; |
| 37 |
| 38 namespace base { |
36 class DictionaryValue; | 39 class DictionaryValue; |
37 struct PurgeInfo; | 40 class ListValue; |
| 41 } |
38 | 42 |
39 namespace sync_api { | 43 namespace sync_api { |
40 class ReadTransaction; | 44 class ReadTransaction; |
41 class WriteNode; | 45 class WriteNode; |
42 class ReadNode; | 46 class ReadNode; |
43 } // sync_api | 47 } // sync_api |
44 | 48 |
45 namespace syncable { | 49 namespace syncable { |
46 class DirectoryChangeDelegate; | 50 class DirectoryChangeDelegate; |
47 class TransactionObserver; | 51 class TransactionObserver; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 inline Id& mutable_ref(IdField field) { | 341 inline Id& mutable_ref(IdField field) { |
338 return id_fields[field - ID_FIELDS_BEGIN]; | 342 return id_fields[field - ID_FIELDS_BEGIN]; |
339 } | 343 } |
340 | 344 |
341 // Does a case in-sensitive search for a given string, which must be | 345 // Does a case in-sensitive search for a given string, which must be |
342 // lower case. | 346 // lower case. |
343 bool ContainsString(const std::string& lowercase_query) const; | 347 bool ContainsString(const std::string& lowercase_query) const; |
344 | 348 |
345 // Dumps all kernel info into a DictionaryValue and returns it. | 349 // Dumps all kernel info into a DictionaryValue and returns it. |
346 // Transfers ownership of the DictionaryValue to the caller. | 350 // Transfers ownership of the DictionaryValue to the caller. |
347 DictionaryValue* ToValue() const; | 351 base::DictionaryValue* ToValue() const; |
348 | 352 |
349 private: | 353 private: |
350 // Tracks whether this entry needs to be saved to the database. | 354 // Tracks whether this entry needs to be saved to the database. |
351 bool dirty_; | 355 bool dirty_; |
352 }; | 356 }; |
353 | 357 |
354 // A read-only meta entry. | 358 // A read-only meta entry. |
355 class Entry { | 359 class Entry { |
356 friend class Directory; | 360 friend class Directory; |
357 friend std::ostream& operator << (std::ostream& s, const Entry& e); | 361 friend std::ostream& operator << (std::ostream& s, const Entry& e); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 } | 431 } |
428 | 432 |
429 // Compute a local predecessor position for |update_item|, based on its | 433 // Compute a local predecessor position for |update_item|, based on its |
430 // absolute server position. The returned ID will be a valid predecessor | 434 // absolute server position. The returned ID will be a valid predecessor |
431 // under SERVER_PARENT_ID that is consistent with the | 435 // under SERVER_PARENT_ID that is consistent with the |
432 // SERVER_POSITION_IN_PARENT ordering. | 436 // SERVER_POSITION_IN_PARENT ordering. |
433 Id ComputePrevIdFromServerPosition(const Id& parent_id) const; | 437 Id ComputePrevIdFromServerPosition(const Id& parent_id) const; |
434 | 438 |
435 // Dumps all entry info into a DictionaryValue and returns it. | 439 // Dumps all entry info into a DictionaryValue and returns it. |
436 // Transfers ownership of the DictionaryValue to the caller. | 440 // Transfers ownership of the DictionaryValue to the caller. |
437 DictionaryValue* ToValue() const; | 441 base::DictionaryValue* ToValue() const; |
438 | 442 |
439 protected: // Don't allow creation on heap, except by sync API wrappers. | 443 protected: // Don't allow creation on heap, except by sync API wrappers. |
440 friend class sync_api::ReadNode; | 444 friend class sync_api::ReadNode; |
441 void* operator new(size_t size) { return (::operator new)(size); } | 445 void* operator new(size_t size) { return (::operator new)(size); } |
442 | 446 |
443 inline Entry(BaseTransaction* trans) | 447 inline Entry(BaseTransaction* trans) |
444 : basetrans_(trans), | 448 : basetrans_(trans), |
445 kernel_(NULL) { } | 449 kernel_(NULL) { } |
446 | 450 |
447 protected: | 451 protected: |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 const EntryKernelMutation& b) const { | 564 const EntryKernelMutation& b) const { |
561 DCHECK_EQ(a.original.ref(META_HANDLE), a.mutated.ref(META_HANDLE)); | 565 DCHECK_EQ(a.original.ref(META_HANDLE), a.mutated.ref(META_HANDLE)); |
562 DCHECK_EQ(b.original.ref(META_HANDLE), b.mutated.ref(META_HANDLE)); | 566 DCHECK_EQ(b.original.ref(META_HANDLE), b.mutated.ref(META_HANDLE)); |
563 return a.original.ref(META_HANDLE) < b.original.ref(META_HANDLE); | 567 return a.original.ref(META_HANDLE) < b.original.ref(META_HANDLE); |
564 } | 568 } |
565 }; | 569 }; |
566 typedef std::set<EntryKernelMutation, EntryKernelMutationLessByMetaHandle> | 570 typedef std::set<EntryKernelMutation, EntryKernelMutationLessByMetaHandle> |
567 EntryKernelMutationSet; | 571 EntryKernelMutationSet; |
568 | 572 |
569 // Caller owns the return value. | 573 // Caller owns the return value. |
570 ListValue* EntryKernelMutationSetToValue( | 574 base::ListValue* EntryKernelMutationSetToValue( |
571 const EntryKernelMutationSet& mutations); | 575 const EntryKernelMutationSet& mutations); |
572 | 576 |
573 // How syncable indices & Indexers work. | 577 // How syncable indices & Indexers work. |
574 // | 578 // |
575 // The syncable Directory maintains several indices on the Entries it tracks. | 579 // The syncable Directory maintains several indices on the Entries it tracks. |
576 // The indices follow a common pattern: | 580 // The indices follow a common pattern: |
577 // (a) The index allows efficient lookup of an Entry* with particular | 581 // (a) The index allows efficient lookup of an Entry* with particular |
578 // field values. This is done by use of a std::set<> and a custom | 582 // field values. This is done by use of a std::set<> and a custom |
579 // comparator. | 583 // comparator. |
580 // (b) There may be conditions for inclusion in the index -- for example, | 584 // (b) There may be conditions for inclusion in the index -- for example, |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 | 1208 |
1205 // This is not a reset. It just sets the numeric fields which are not | 1209 // This is not a reset. It just sets the numeric fields which are not |
1206 // initialized by the constructor to zero. | 1210 // initialized by the constructor to zero. |
1207 void ZeroFields(EntryKernel* entry, int first_field); | 1211 void ZeroFields(EntryKernel* entry, int first_field); |
1208 | 1212 |
1209 } // namespace syncable | 1213 } // namespace syncable |
1210 | 1214 |
1211 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1215 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
1212 | 1216 |
1213 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1217 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
OLD | NEW |