| 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 13 matching lines...) Expand all Loading... |
| 24 #include "base/synchronization/lock.h" | 24 #include "base/synchronization/lock.h" |
| 25 #include "base/time.h" | 25 #include "base/time.h" |
| 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" | |
| 35 | 34 |
| 36 struct PurgeInfo; | 35 struct PurgeInfo; |
| 37 | 36 |
| 38 namespace base { | 37 namespace base { |
| 39 class DictionaryValue; | 38 class DictionaryValue; |
| 40 class ListValue; | 39 class ListValue; |
| 41 } | 40 } |
| 42 | 41 |
| 43 namespace sync_api { | 42 namespace sync_api { |
| 44 class ReadTransaction; | 43 class ReadTransaction; |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 private: | 843 private: |
| 845 // These private versions expect the kernel lock to already be held | 844 // These private versions expect the kernel lock to already be held |
| 846 // before calling. | 845 // before calling. |
| 847 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); | 846 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); |
| 848 | 847 |
| 849 DirOpenResult OpenImpl(const FilePath& file_path, const std::string& name, | 848 DirOpenResult OpenImpl(const FilePath& file_path, const std::string& name, |
| 850 DirectoryChangeDelegate* delegate); | 849 DirectoryChangeDelegate* delegate); |
| 851 | 850 |
| 852 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); | 851 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); |
| 853 | 852 |
| 854 struct DirectoryEventTraits { | |
| 855 typedef DirectoryEvent EventType; | |
| 856 static inline bool IsChannelShutdownEvent(const DirectoryEvent& event) { | |
| 857 return DIRECTORY_DESTROYED == event; | |
| 858 } | |
| 859 }; | |
| 860 public: | 853 public: |
| 861 typedef EventChannel<DirectoryEventTraits, base::Lock> Channel; | |
| 862 typedef std::vector<int64> ChildHandles; | 854 typedef std::vector<int64> ChildHandles; |
| 863 | 855 |
| 864 // Returns the child meta handles for given parent id. Clears | 856 // Returns the child meta handles for given parent id. Clears |
| 865 // |result| if there are no children. | 857 // |result| if there are no children. |
| 866 void GetChildHandlesById(BaseTransaction*, const Id& parent_id, | 858 void GetChildHandlesById(BaseTransaction*, const Id& parent_id, |
| 867 ChildHandles* result); | 859 ChildHandles* result); |
| 868 | 860 |
| 869 // Returns the child meta handles for given meta handle. Clears | 861 // Returns the child meta handles for given meta handle. Clears |
| 870 // |result| if there are no children. | 862 // |result| if there are no children. |
| 871 void GetChildHandlesByHandle(BaseTransaction*, int64 handle, | 863 void GetChildHandlesByHandle(BaseTransaction*, int64 handle, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 // syncer should call it from its PerformSyncQueries member. | 898 // syncer should call it from its PerformSyncQueries member. |
| 907 typedef std::vector<int64> UnsyncedMetaHandles; | 899 typedef std::vector<int64> UnsyncedMetaHandles; |
| 908 void GetUnsyncedMetaHandles(BaseTransaction* trans, | 900 void GetUnsyncedMetaHandles(BaseTransaction* trans, |
| 909 UnsyncedMetaHandles* result); | 901 UnsyncedMetaHandles* result); |
| 910 | 902 |
| 911 // Get all the metahandles for unapplied updates | 903 // Get all the metahandles for unapplied updates |
| 912 typedef std::vector<int64> UnappliedUpdateMetaHandles; | 904 typedef std::vector<int64> UnappliedUpdateMetaHandles; |
| 913 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, | 905 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, |
| 914 UnappliedUpdateMetaHandles* result); | 906 UnappliedUpdateMetaHandles* result); |
| 915 | 907 |
| 916 // Get the channel for post save notification, used by the syncer. | |
| 917 inline Channel* channel() const { | |
| 918 return kernel_->channel; | |
| 919 } | |
| 920 | |
| 921 // Checks tree metadata consistency. | 908 // Checks tree metadata consistency. |
| 922 // If full_scan is false, the function will avoid pulling any entries from the | 909 // If full_scan is false, the function will avoid pulling any entries from the |
| 923 // db and scan entries currently in ram. | 910 // db and scan entries currently in ram. |
| 924 // If full_scan is true, all entries will be pulled from the database. | 911 // If full_scan is true, all entries will be pulled from the database. |
| 925 // No return value, CHECKs will be triggered if we're given bad | 912 // No return value, CHECKs will be triggered if we're given bad |
| 926 // information. | 913 // information. |
| 927 void CheckTreeInvariants(syncable::BaseTransaction* trans, | 914 void CheckTreeInvariants(syncable::BaseTransaction* trans, |
| 928 bool full_scan); | 915 bool full_scan); |
| 929 | 916 |
| 930 void CheckTreeInvariants(syncable::BaseTransaction* trans, | 917 void CheckTreeInvariants(syncable::BaseTransaction* trans, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 MetahandleSet* const unapplied_update_metahandles; | 1027 MetahandleSet* const unapplied_update_metahandles; |
| 1041 MetahandleSet* const unsynced_metahandles; | 1028 MetahandleSet* const unsynced_metahandles; |
| 1042 // Contains metahandles that are most likely dirty (though not | 1029 // Contains metahandles that are most likely dirty (though not |
| 1043 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges(). | 1030 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges(). |
| 1044 MetahandleSet* const dirty_metahandles; | 1031 MetahandleSet* const dirty_metahandles; |
| 1045 | 1032 |
| 1046 // When a purge takes place, we remove items from all our indices and stash | 1033 // When a purge takes place, we remove items from all our indices and stash |
| 1047 // them in here so that SaveChanges can persist their permanent deletion. | 1034 // them in here so that SaveChanges can persist their permanent deletion. |
| 1048 MetahandleSet* const metahandles_to_purge; | 1035 MetahandleSet* const metahandles_to_purge; |
| 1049 | 1036 |
| 1050 // TODO(ncarter): Figure out what the hell this is, and comment it. | |
| 1051 Channel* const channel; | |
| 1052 | |
| 1053 KernelShareInfoStatus info_status; | 1037 KernelShareInfoStatus info_status; |
| 1054 | 1038 |
| 1055 // These 3 members are backed in the share_info table, and | 1039 // These 3 members are backed in the share_info table, and |
| 1056 // their state is marked by the flag above. | 1040 // their state is marked by the flag above. |
| 1057 | 1041 |
| 1058 // A structure containing the Directory state that is written back into the | 1042 // A structure containing the Directory state that is written back into the |
| 1059 // database on SaveChanges. | 1043 // database on SaveChanges. |
| 1060 PersistedKernelInfo persisted_info; | 1044 PersistedKernelInfo persisted_info; |
| 1061 | 1045 |
| 1062 // A unique identifier for this account's cache db, used to generate | 1046 // A unique identifier for this account's cache db, used to generate |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 | 1190 |
| 1207 // This is not a reset. It just sets the numeric fields which are not | 1191 // This is not a reset. It just sets the numeric fields which are not |
| 1208 // initialized by the constructor to zero. | 1192 // initialized by the constructor to zero. |
| 1209 void ZeroFields(EntryKernel* entry, int first_field); | 1193 void ZeroFields(EntryKernel* entry, int first_field); |
| 1210 | 1194 |
| 1211 } // namespace syncable | 1195 } // namespace syncable |
| 1212 | 1196 |
| 1213 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1197 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
| 1214 | 1198 |
| 1215 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1199 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
| OLD | NEW |