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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 ~PersistedKernelInfo(); | 766 ~PersistedKernelInfo(); |
767 | 767 |
768 // Set the |download_progress| entry for the given model to a | 768 // Set the |download_progress| entry for the given model to a |
769 // "first sync" start point. When such a value is sent to the server, | 769 // "first sync" start point. When such a value is sent to the server, |
770 // a full download of all objects of the model will be initiated. | 770 // a full download of all objects of the model will be initiated. |
771 void reset_download_progress(ModelType model_type); | 771 void reset_download_progress(ModelType model_type); |
772 | 772 |
773 // Last sync timestamp fetched from the server. | 773 // Last sync timestamp fetched from the server. |
774 sync_pb::DataTypeProgressMarker download_progress[MODEL_TYPE_COUNT]; | 774 sync_pb::DataTypeProgressMarker download_progress[MODEL_TYPE_COUNT]; |
775 // true iff we ever reached the end of the changelog. | 775 // true iff we ever reached the end of the changelog. |
776 ModelEnumSet initial_sync_ended; | 776 ModelTypeSet initial_sync_ended; |
777 // The store birthday we were given by the server. Contents are opaque to | 777 // The store birthday we were given by the server. Contents are opaque to |
778 // the client. | 778 // the client. |
779 std::string store_birthday; | 779 std::string store_birthday; |
780 // The next local ID that has not been used with this cache-GUID. | 780 // The next local ID that has not been used with this cache-GUID. |
781 int64 next_id; | 781 int64 next_id; |
782 // The persisted notification state. | 782 // The persisted notification state. |
783 std::string notification_state; | 783 std::string notification_state; |
784 }; | 784 }; |
785 | 785 |
786 // What the Directory needs on initialization to create itself and its Kernel. | 786 // What the Directory needs on initialization to create itself and its Kernel. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and | 964 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and |
965 // before any new entries have been created. The intention is that the | 965 // before any new entries have been created. The intention is that the |
966 // syncer should call it from its PerformSyncQueries member. | 966 // syncer should call it from its PerformSyncQueries member. |
967 typedef std::vector<int64> UnsyncedMetaHandles; | 967 typedef std::vector<int64> UnsyncedMetaHandles; |
968 void GetUnsyncedMetaHandles(BaseTransaction* trans, | 968 void GetUnsyncedMetaHandles(BaseTransaction* trans, |
969 UnsyncedMetaHandles* result); | 969 UnsyncedMetaHandles* result); |
970 | 970 |
971 // Returns all server types with unapplied updates. A subset of | 971 // Returns all server types with unapplied updates. A subset of |
972 // those types can then be passed into | 972 // those types can then be passed into |
973 // GetUnappliedUpdateMetaHandles() below. | 973 // GetUnappliedUpdateMetaHandles() below. |
974 FullModelEnumSet GetServerTypesWithUnappliedUpdates( | 974 FullModelTypeSet GetServerTypesWithUnappliedUpdates( |
975 BaseTransaction* trans) const; | 975 BaseTransaction* trans) const; |
976 | 976 |
977 // Get all the metahandles for unapplied updates for a given set of | 977 // Get all the metahandles for unapplied updates for a given set of |
978 // server types. | 978 // server types. |
979 typedef std::vector<int64> UnappliedUpdateMetaHandles; | 979 typedef std::vector<int64> UnappliedUpdateMetaHandles; |
980 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, | 980 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, |
981 FullModelEnumSet server_types, | 981 FullModelTypeSet server_types, |
982 UnappliedUpdateMetaHandles* result); | 982 UnappliedUpdateMetaHandles* result); |
983 | 983 |
984 // Checks tree metadata consistency. | 984 // Checks tree metadata consistency. |
985 // If full_scan is false, the function will avoid pulling any entries from the | 985 // If full_scan is false, the function will avoid pulling any entries from the |
986 // db and scan entries currently in ram. | 986 // db and scan entries currently in ram. |
987 // If full_scan is true, all entries will be pulled from the database. | 987 // 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 | 988 // No return value, CHECKs will be triggered if we're given bad |
989 // information. | 989 // information. |
990 void CheckTreeInvariants(syncable::BaseTransaction* trans, | 990 void CheckTreeInvariants(syncable::BaseTransaction* trans, |
991 bool full_scan); | 991 bool full_scan); |
992 | 992 |
993 void CheckTreeInvariants(syncable::BaseTransaction* trans, | 993 void CheckTreeInvariants(syncable::BaseTransaction* trans, |
994 const EntryKernelMutationMap& mutations); | 994 const EntryKernelMutationMap& mutations); |
995 | 995 |
996 void CheckTreeInvariants(syncable::BaseTransaction* trans, | 996 void CheckTreeInvariants(syncable::BaseTransaction* trans, |
997 const MetahandleSet& handles, | 997 const MetahandleSet& handles, |
998 const IdFilter& idfilter); | 998 const IdFilter& idfilter); |
999 | 999 |
1000 // Purges all data associated with any entries whose ModelType or | 1000 // Purges all data associated with any entries whose ModelType or |
1001 // ServerModelType is found in |types|, from _both_ memory and disk. | 1001 // ServerModelType is found in |types|, from _both_ memory and disk. |
1002 // Only valid, "real" model types are allowed in |types| (see model_type.h | 1002 // Only valid, "real" model types are allowed in |types| (see model_type.h |
1003 // for definitions). "Purge" is just meant to distinguish from "deleting" | 1003 // for definitions). "Purge" is just meant to distinguish from "deleting" |
1004 // entries, which means something different in the syncable namespace. | 1004 // entries, which means something different in the syncable namespace. |
1005 // WARNING! This can be real slow, as it iterates over all entries. | 1005 // WARNING! This can be real slow, as it iterates over all entries. |
1006 // WARNING! Performs synchronous I/O. | 1006 // WARNING! Performs synchronous I/O. |
1007 virtual void PurgeEntriesWithTypeIn(ModelEnumSet types); | 1007 virtual void PurgeEntriesWithTypeIn(ModelTypeSet types); |
1008 | 1008 |
1009 private: | 1009 private: |
1010 // Helper to prime ids_index, parent_id_and_names_index, unsynced_metahandles | 1010 // Helper to prime ids_index, parent_id_and_names_index, unsynced_metahandles |
1011 // and unapplied_metahandles from metahandles_index. | 1011 // and unapplied_metahandles from metahandles_index. |
1012 void InitializeIndices(); | 1012 void InitializeIndices(); |
1013 | 1013 |
1014 // Constructs a consistent snapshot of the current Directory state and | 1014 // Constructs a consistent snapshot of the current Directory state and |
1015 // indices (by deep copy) under a ReadTransaction for use in |snapshot|. | 1015 // indices (by deep copy) under a ReadTransaction for use in |snapshot|. |
1016 // See SaveChanges() for more information. | 1016 // See SaveChanges() for more information. |
1017 void TakeSnapshotForSaveChanges(SaveChangesSnapshot* snapshot); | 1017 void TakeSnapshotForSaveChanges(SaveChangesSnapshot* snapshot); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 WriterTag writer, Directory* directory); | 1252 WriterTag writer, Directory* directory); |
1253 WriteTransaction(const tracked_objects::Location& from_here, | 1253 WriteTransaction(const tracked_objects::Location& from_here, |
1254 WriterTag writer, const ScopedDirLookup& directory); | 1254 WriterTag writer, const ScopedDirLookup& directory); |
1255 | 1255 |
1256 virtual ~WriteTransaction(); | 1256 virtual ~WriteTransaction(); |
1257 | 1257 |
1258 void SaveOriginal(const EntryKernel* entry); | 1258 void SaveOriginal(const EntryKernel* entry); |
1259 | 1259 |
1260 protected: | 1260 protected: |
1261 // Overridden by tests. | 1261 // Overridden by tests. |
1262 virtual void NotifyTransactionComplete(ModelEnumSet models_with_changes); | 1262 virtual void NotifyTransactionComplete(ModelTypeSet models_with_changes); |
1263 | 1263 |
1264 private: | 1264 private: |
1265 // Clears |mutations_|. | 1265 // Clears |mutations_|. |
1266 ImmutableEntryKernelMutationMap RecordMutations(); | 1266 ImmutableEntryKernelMutationMap RecordMutations(); |
1267 | 1267 |
1268 void UnlockAndNotify(const ImmutableEntryKernelMutationMap& mutations); | 1268 void UnlockAndNotify(const ImmutableEntryKernelMutationMap& mutations); |
1269 | 1269 |
1270 ModelEnumSet NotifyTransactionChangingAndEnding( | 1270 ModelTypeSet NotifyTransactionChangingAndEnding( |
1271 const ImmutableEntryKernelMutationMap& mutations); | 1271 const ImmutableEntryKernelMutationMap& mutations); |
1272 | 1272 |
1273 // Only the original fields are filled in until |RecordMutations()|. | 1273 // Only the original fields are filled in until |RecordMutations()|. |
1274 // We use a mutation map instead of a kernel set to avoid copying. | 1274 // We use a mutation map instead of a kernel set to avoid copying. |
1275 EntryKernelMutationMap mutations_; | 1275 EntryKernelMutationMap mutations_; |
1276 | 1276 |
1277 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); | 1277 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); |
1278 }; | 1278 }; |
1279 | 1279 |
1280 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); | 1280 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); |
1281 | 1281 |
1282 // This function sets only the flags needed to get this entry to sync. | 1282 // This function sets only the flags needed to get this entry to sync. |
1283 void MarkForSyncing(syncable::MutableEntry* e); | 1283 void MarkForSyncing(syncable::MutableEntry* e); |
1284 | 1284 |
1285 } // namespace syncable | 1285 } // namespace syncable |
1286 | 1286 |
1287 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1287 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
1288 | 1288 |
1289 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1289 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
OLD | NEW |