| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 inline std::string& mutable_ref(StringField field) { | 364 inline std::string& mutable_ref(StringField field) { |
| 365 return string_fields[field - STRING_FIELDS_BEGIN]; | 365 return string_fields[field - STRING_FIELDS_BEGIN]; |
| 366 } | 366 } |
| 367 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) { | 367 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) { |
| 368 return specifics_fields[field - PROTO_FIELDS_BEGIN]; | 368 return specifics_fields[field - PROTO_FIELDS_BEGIN]; |
| 369 } | 369 } |
| 370 inline Id& mutable_ref(IdField field) { | 370 inline Id& mutable_ref(IdField field) { |
| 371 return id_fields[field - ID_FIELDS_BEGIN]; | 371 return id_fields[field - ID_FIELDS_BEGIN]; |
| 372 } | 372 } |
| 373 | 373 |
| 374 syncable::ModelType GetServerModelType() const; | |
| 375 | |
| 376 // Does a case in-sensitive search for a given string, which must be | 374 // Does a case in-sensitive search for a given string, which must be |
| 377 // lower case. | 375 // lower case. |
| 378 bool ContainsString(const std::string& lowercase_query) const; | 376 bool ContainsString(const std::string& lowercase_query) const; |
| 379 | 377 |
| 380 // Dumps all kernel info into a DictionaryValue and returns it. | 378 // Dumps all kernel info into a DictionaryValue and returns it. |
| 381 // Transfers ownership of the DictionaryValue to the caller. | 379 // Transfers ownership of the DictionaryValue to the caller. |
| 382 base::DictionaryValue* ToValue() const; | 380 base::DictionaryValue* ToValue() const; |
| 383 | 381 |
| 384 private: | 382 private: |
| 385 // Tracks whether this entry needs to be saved to the database. | 383 // Tracks whether this entry needs to be saved to the database. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 inline explicit Entry(BaseTransaction* trans) | 480 inline explicit Entry(BaseTransaction* trans) |
| 483 : basetrans_(trans), | 481 : basetrans_(trans), |
| 484 kernel_(NULL) { } | 482 kernel_(NULL) { } |
| 485 | 483 |
| 486 protected: | 484 protected: |
| 487 BaseTransaction* const basetrans_; | 485 BaseTransaction* const basetrans_; |
| 488 | 486 |
| 489 EntryKernel* kernel_; | 487 EntryKernel* kernel_; |
| 490 | 488 |
| 491 private: | 489 private: |
| 490 // Like GetServerModelType() but without the DCHECKs. |
| 491 ModelType GetServerModelTypeHelper() const; |
| 492 |
| 492 DISALLOW_COPY_AND_ASSIGN(Entry); | 493 DISALLOW_COPY_AND_ASSIGN(Entry); |
| 493 }; | 494 }; |
| 494 | 495 |
| 495 // A mutable meta entry. Changes get committed to the database when the | 496 // A mutable meta entry. Changes get committed to the database when the |
| 496 // WriteTransaction is destroyed. | 497 // WriteTransaction is destroyed. |
| 497 class MutableEntry : public Entry { | 498 class MutableEntry : public Entry { |
| 498 friend class WriteTransaction; | 499 friend class WriteTransaction; |
| 499 friend class Directory; | 500 friend class Directory; |
| 500 void Init(WriteTransaction* trans, const Id& parent_id, | 501 void Init(WriteTransaction* trans, const Id& parent_id, |
| 501 const std::string& name); | 502 const std::string& name); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 // Returns the number of entities with the unsynced bit set. | 962 // Returns the number of entities with the unsynced bit set. |
| 962 int64 unsynced_entity_count() const; | 963 int64 unsynced_entity_count() const; |
| 963 | 964 |
| 964 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and | 965 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and |
| 965 // before any new entries have been created. The intention is that the | 966 // before any new entries have been created. The intention is that the |
| 966 // syncer should call it from its PerformSyncQueries member. | 967 // syncer should call it from its PerformSyncQueries member. |
| 967 typedef std::vector<int64> UnsyncedMetaHandles; | 968 typedef std::vector<int64> UnsyncedMetaHandles; |
| 968 void GetUnsyncedMetaHandles(BaseTransaction* trans, | 969 void GetUnsyncedMetaHandles(BaseTransaction* trans, |
| 969 UnsyncedMetaHandles* result); | 970 UnsyncedMetaHandles* result); |
| 970 | 971 |
| 971 // Returns all server types with unapplied updates. A subset of | 972 // Get all the metahandles for unapplied updates |
| 972 // those types can then be passed into | |
| 973 // GetUnappliedUpdateMetaHandles() below. | |
| 974 syncable::ModelTypeBitSet GetServerTypesWithUnappliedUpdates( | |
| 975 BaseTransaction* trans) const; | |
| 976 | |
| 977 // Get all the metahandles for unapplied updates for a given set of | |
| 978 // server types. | |
| 979 typedef std::vector<int64> UnappliedUpdateMetaHandles; | 973 typedef std::vector<int64> UnappliedUpdateMetaHandles; |
| 980 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, | 974 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, |
| 981 syncable::ModelTypeBitSet server_types, | |
| 982 UnappliedUpdateMetaHandles* result); | 975 UnappliedUpdateMetaHandles* result); |
| 983 | 976 |
| 984 // Checks tree metadata consistency. | 977 // Checks tree metadata consistency. |
| 985 // If full_scan is false, the function will avoid pulling any entries from the | 978 // If full_scan is false, the function will avoid pulling any entries from the |
| 986 // db and scan entries currently in ram. | 979 // db and scan entries currently in ram. |
| 987 // If full_scan is true, all entries will be pulled from the database. | 980 // If full_scan is true, all entries will be pulled from the database. |
| 988 // No return value, CHECKs will be triggered if we're given bad | 981 // No return value, CHECKs will be triggered if we're given bad |
| 989 // information. | 982 // information. |
| 990 void CheckTreeInvariants(syncable::BaseTransaction* trans, | 983 void CheckTreeInvariants(syncable::BaseTransaction* trans, |
| 991 bool full_scan); | 984 bool full_scan); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 MetahandlesIndex* metahandles_index; | 1096 MetahandlesIndex* metahandles_index; |
| 1104 // Entries indexed by id | 1097 // Entries indexed by id |
| 1105 IdsIndex* ids_index; | 1098 IdsIndex* ids_index; |
| 1106 ParentIdChildIndex* parent_id_child_index; | 1099 ParentIdChildIndex* parent_id_child_index; |
| 1107 ClientTagIndex* client_tag_index; | 1100 ClientTagIndex* client_tag_index; |
| 1108 // So we don't have to create an EntryKernel every time we want to | 1101 // So we don't have to create an EntryKernel every time we want to |
| 1109 // look something up in an index. Needle in haystack metaphor. | 1102 // look something up in an index. Needle in haystack metaphor. |
| 1110 EntryKernel needle; | 1103 EntryKernel needle; |
| 1111 | 1104 |
| 1112 // 3 in-memory indices on bits used extremely frequently by the syncer. | 1105 // 3 in-memory indices on bits used extremely frequently by the syncer. |
| 1113 // |unapplied_update_metahandles| is keyed by the server model type. | 1106 MetahandleSet* const unapplied_update_metahandles; |
| 1114 MetahandleSet unapplied_update_metahandles[MODEL_TYPE_COUNT]; | |
| 1115 MetahandleSet* const unsynced_metahandles; | 1107 MetahandleSet* const unsynced_metahandles; |
| 1116 // Contains metahandles that are most likely dirty (though not | 1108 // Contains metahandles that are most likely dirty (though not |
| 1117 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges(). | 1109 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges(). |
| 1118 MetahandleSet* const dirty_metahandles; | 1110 MetahandleSet* const dirty_metahandles; |
| 1119 | 1111 |
| 1120 // When a purge takes place, we remove items from all our indices and stash | 1112 // When a purge takes place, we remove items from all our indices and stash |
| 1121 // them in here so that SaveChanges can persist their permanent deletion. | 1113 // them in here so that SaveChanges can persist their permanent deletion. |
| 1122 MetahandleSet* const metahandles_to_purge; | 1114 MetahandleSet* const metahandles_to_purge; |
| 1123 | 1115 |
| 1124 KernelShareInfoStatus info_status; | 1116 KernelShareInfoStatus info_status; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); | 1273 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); |
| 1282 | 1274 |
| 1283 // This function sets only the flags needed to get this entry to sync. | 1275 // This function sets only the flags needed to get this entry to sync. |
| 1284 void MarkForSyncing(syncable::MutableEntry* e); | 1276 void MarkForSyncing(syncable::MutableEntry* e); |
| 1285 | 1277 |
| 1286 } // namespace syncable | 1278 } // namespace syncable |
| 1287 | 1279 |
| 1288 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1280 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
| 1289 | 1281 |
| 1290 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1282 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
| OLD | NEW |