Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 void Delete(EntryKernel* const entry); | 784 void Delete(EntryKernel* const entry); |
| 785 void UnlinkEntryFromOrder(EntryKernel* entry, | 785 void UnlinkEntryFromOrder(EntryKernel* entry, |
| 786 WriteTransaction* trans, | 786 WriteTransaction* trans, |
| 787 ScopedKernelLock* lock); | 787 ScopedKernelLock* lock); |
| 788 | 788 |
| 789 // Overridden by tests. | 789 // Overridden by tests. |
| 790 virtual DirectoryBackingStore* CreateBackingStore( | 790 virtual DirectoryBackingStore* CreateBackingStore( |
| 791 const std::string& dir_name, | 791 const std::string& dir_name, |
| 792 const FilePath& backing_filepath); | 792 const FilePath& backing_filepath); |
| 793 | 793 |
| 794 // Update this directory's set of encrypted datatypes. | |
| 795 // Note: |types| should be a complete set of all datatypes that require | |
| 796 // encryption, not just a subset. This does not actually perform any | |
| 797 // encryption or modify the Nigori node. | |
| 798 void SetEncryptedDataTypes(const ModelTypeSet& encrypted_types); | |
| 799 | |
| 794 private: | 800 private: |
| 795 // These private versions expect the kernel lock to already be held | 801 // These private versions expect the kernel lock to already be held |
| 796 // before calling. | 802 // before calling. |
| 797 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); | 803 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); |
| 798 | 804 |
| 799 DirOpenResult OpenImpl(const FilePath& file_path, const std::string& name); | 805 DirOpenResult OpenImpl(const FilePath& file_path, const std::string& name); |
| 800 | 806 |
| 801 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); | 807 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); |
| 802 | 808 |
| 803 struct DirectoryEventTraits { | 809 struct DirectoryEventTraits { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 // unique server IDs. No need to lock, only written at init time. | 1020 // unique server IDs. No need to lock, only written at init time. |
| 1015 std::string cache_guid; | 1021 std::string cache_guid; |
| 1016 | 1022 |
| 1017 // It doesn't make sense for two threads to run SaveChanges at the same | 1023 // It doesn't make sense for two threads to run SaveChanges at the same |
| 1018 // time; this mutex protects that activity. | 1024 // time; this mutex protects that activity. |
| 1019 base::Lock save_changes_mutex; | 1025 base::Lock save_changes_mutex; |
| 1020 | 1026 |
| 1021 // The next metahandle is protected by kernel mutex. | 1027 // The next metahandle is protected by kernel mutex. |
| 1022 int64 next_metahandle; | 1028 int64 next_metahandle; |
| 1023 | 1029 |
| 1030 // The set of all datatypes that currently require encryption. This is | |
| 1031 // set when we load the nigori node and modified anytime we either receive | |
| 1032 // a change to the nigori node or through the local user changing the | |
| 1033 // encryption status. | |
| 1034 ModelTypeSet encrypted_datatypes; | |
|
tim (not reviewing)
2011/02/11 06:52:31
Why do we store this in 3 places again? The fact
Nicolas Zea
2011/02/14 21:18:41
Done.
| |
| 1035 | |
| 1024 // Keep a history of recently flushed metahandles for debugging | 1036 // Keep a history of recently flushed metahandles for debugging |
| 1025 // purposes. Protected by the save_changes_mutex. | 1037 // purposes. Protected by the save_changes_mutex. |
| 1026 DebugQueue<int64, 1000> flushed_metahandles; | 1038 DebugQueue<int64, 1000> flushed_metahandles; |
| 1027 }; | 1039 }; |
| 1028 | 1040 |
| 1029 Kernel* kernel_; | 1041 Kernel* kernel_; |
| 1030 | 1042 |
| 1031 DirectoryBackingStore* store_; | 1043 DirectoryBackingStore* store_; |
| 1032 }; | 1044 }; |
| 1033 | 1045 |
| 1034 class ScopedKernelLock { | 1046 class ScopedKernelLock { |
| 1035 public: | 1047 public: |
| 1036 explicit ScopedKernelLock(const Directory*); | 1048 explicit ScopedKernelLock(const Directory*); |
| 1037 ~ScopedKernelLock() {} | 1049 ~ScopedKernelLock() {} |
| 1038 | 1050 |
| 1039 base::AutoLock scoped_lock_; | 1051 base::AutoLock scoped_lock_; |
| 1040 Directory* const dir_; | 1052 Directory* const dir_; |
| 1041 DISALLOW_COPY_AND_ASSIGN(ScopedKernelLock); | 1053 DISALLOW_COPY_AND_ASSIGN(ScopedKernelLock); |
| 1042 }; | 1054 }; |
| 1043 | 1055 |
| 1044 // Transactions are now processed FIFO with a straight lock | 1056 // Transactions are now processed FIFO with a straight lock |
| 1045 class BaseTransaction { | 1057 class BaseTransaction { |
| 1046 friend class Entry; | 1058 friend class Entry; |
| 1047 public: | 1059 public: |
| 1048 inline Directory* directory() const { return directory_; } | 1060 inline Directory* directory() const { return directory_; } |
| 1049 inline Id root_id() const { return Id(); } | 1061 inline Id root_id() const { return Id(); } |
| 1050 | 1062 |
| 1063 inline const ModelTypeSet& GetEncryptedDatatypes() { | |
| 1064 return dirkernel_->encrypted_datatypes; | |
| 1065 } | |
| 1066 | |
| 1051 virtual ~BaseTransaction(); | 1067 virtual ~BaseTransaction(); |
| 1052 | 1068 |
| 1069 // Update this transaction's directory's set of encrypted datatypes. | |
| 1070 // Note: |encrypted_types| should be a complete set of all datatypes that | |
| 1071 // require encryption, not just a subset. This does not actually perform any | |
| 1072 // encryption or modify the Nigori node. | |
| 1073 void SetEncryptedDataTypes(const ModelTypeSet& encrypted_types); | |
|
tim (not reviewing)
2011/02/11 06:52:31
Why have get/set operations on the transaction whe
Nicolas Zea
2011/02/14 21:18:41
Done.
| |
| 1074 | |
| 1053 protected: | 1075 protected: |
| 1054 BaseTransaction(Directory* directory, const char* name, | 1076 BaseTransaction(Directory* directory, const char* name, |
| 1055 const char* source_file, int line, WriterTag writer); | 1077 const char* source_file, int line, WriterTag writer); |
| 1056 | 1078 |
| 1057 // For unit testing. Everything will be mocked out no point initializing. | 1079 // For unit testing. Everything will be mocked out no point initializing. |
| 1058 explicit BaseTransaction(Directory* directory); | 1080 explicit BaseTransaction(Directory* directory); |
| 1059 | 1081 |
| 1060 void UnlockAndLog(OriginalEntries* entries); | 1082 void UnlockAndLog(OriginalEntries* entries); |
| 1061 bool NotifyTransactionChangingAndEnding(OriginalEntries* entries); | 1083 bool NotifyTransactionChangingAndEnding(OriginalEntries* entries); |
| 1062 virtual void NotifyTransactionComplete(); | 1084 virtual void NotifyTransactionComplete(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 | 1152 |
| 1131 // This is not a reset. It just sets the numeric fields which are not | 1153 // This is not a reset. It just sets the numeric fields which are not |
| 1132 // initialized by the constructor to zero. | 1154 // initialized by the constructor to zero. |
| 1133 void ZeroFields(EntryKernel* entry, int first_field); | 1155 void ZeroFields(EntryKernel* entry, int first_field); |
| 1134 | 1156 |
| 1135 } // namespace syncable | 1157 } // namespace syncable |
| 1136 | 1158 |
| 1137 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1159 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
| 1138 | 1160 |
| 1139 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1161 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
| OLD | NEW |