Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 // Get all add hash prefixes and full-length hashes, respectively, from | 136 // Get all add hash prefixes and full-length hashes, respectively, from |
| 137 // the store. | 137 // the store. |
| 138 virtual bool GetAddPrefixes(SBAddPrefixes* add_prefixes) OVERRIDE; | 138 virtual bool GetAddPrefixes(SBAddPrefixes* add_prefixes) OVERRIDE; |
| 139 virtual bool GetAddFullHashes( | 139 virtual bool GetAddFullHashes( |
| 140 std::vector<SBAddFullHash>* add_full_hashes) OVERRIDE; | 140 std::vector<SBAddFullHash>* add_full_hashes) OVERRIDE; |
| 141 | 141 |
| 142 virtual bool BeginChunk() OVERRIDE; | 142 virtual bool BeginChunk() OVERRIDE; |
| 143 | 143 |
| 144 virtual bool WriteAddPrefix(int32 chunk_id, SBPrefix prefix) OVERRIDE; | 144 virtual bool WriteAddPrefix(int32 chunk_id, SBPrefix prefix) OVERRIDE; |
| 145 virtual bool WriteAddHash(int32 chunk_id, | 145 virtual bool WriteAddHash(int32 chunk_id, |
| 146 base::Time receive_time, | |
| 147 const SBFullHash& full_hash) OVERRIDE; | 146 const SBFullHash& full_hash) OVERRIDE; |
| 148 virtual bool WriteSubPrefix(int32 chunk_id, | 147 virtual bool WriteSubPrefix(int32 chunk_id, |
| 149 int32 add_chunk_id, SBPrefix prefix) OVERRIDE; | 148 int32 add_chunk_id, SBPrefix prefix) OVERRIDE; |
| 150 virtual bool WriteSubHash(int32 chunk_id, int32 add_chunk_id, | 149 virtual bool WriteSubHash(int32 chunk_id, int32 add_chunk_id, |
| 151 const SBFullHash& full_hash) OVERRIDE; | 150 const SBFullHash& full_hash) OVERRIDE; |
| 152 virtual bool FinishChunk() OVERRIDE; | 151 virtual bool FinishChunk() OVERRIDE; |
| 153 | 152 |
| 154 virtual bool BeginUpdate() OVERRIDE; | 153 virtual bool BeginUpdate() OVERRIDE; |
| 155 // Store updates with pending add full hashes in file store and | 154 // Store updates in file store and return |add_full_hashes_result|. |
|
Scott Hess - ex-Googler
2014/04/01 22:08:36
I see I didn't update the comment - should mention
mattm
2014/04/03 01:38:12
Done.
| |
| 156 // return |add_prefixes_result| and |add_full_hashes_result|. | |
| 157 virtual bool FinishUpdate( | 155 virtual bool FinishUpdate( |
| 158 const std::vector<SBAddFullHash>& pending_adds, | |
| 159 safe_browsing::PrefixSetBuilder* builder, | 156 safe_browsing::PrefixSetBuilder* builder, |
| 160 std::vector<SBAddFullHash>* add_full_hashes_result) OVERRIDE; | 157 std::vector<SBAddFullHash>* add_full_hashes_result) OVERRIDE; |
| 161 virtual bool CancelUpdate() OVERRIDE; | 158 virtual bool CancelUpdate() OVERRIDE; |
| 162 | 159 |
| 163 virtual void SetAddChunk(int32 chunk_id) OVERRIDE; | 160 virtual void SetAddChunk(int32 chunk_id) OVERRIDE; |
| 164 virtual bool CheckAddChunk(int32 chunk_id) OVERRIDE; | 161 virtual bool CheckAddChunk(int32 chunk_id) OVERRIDE; |
| 165 virtual void GetAddChunks(std::vector<int32>* out) OVERRIDE; | 162 virtual void GetAddChunks(std::vector<int32>* out) OVERRIDE; |
| 166 virtual void SetSubChunk(int32 chunk_id) OVERRIDE; | 163 virtual void SetSubChunk(int32 chunk_id) OVERRIDE; |
| 167 virtual bool CheckSubChunk(int32 chunk_id) OVERRIDE; | 164 virtual bool CheckSubChunk(int32 chunk_id) OVERRIDE; |
| 168 virtual void GetSubChunks(std::vector<int32>* out) OVERRIDE; | 165 virtual void GetSubChunks(std::vector<int32>* out) OVERRIDE; |
| 169 | 166 |
| 170 virtual void DeleteAddChunk(int32 chunk_id) OVERRIDE; | 167 virtual void DeleteAddChunk(int32 chunk_id) OVERRIDE; |
| 171 virtual void DeleteSubChunk(int32 chunk_id) OVERRIDE; | 168 virtual void DeleteSubChunk(int32 chunk_id) OVERRIDE; |
| 172 | 169 |
| 173 // Verify |file_|'s checksum, calling the corruption callback if it | 170 // Verify |file_|'s checksum, calling the corruption callback if it |
| 174 // does not check out. Empty input is considered valid. | 171 // does not check out. Empty input is considered valid. |
| 175 virtual bool CheckValidity() OVERRIDE; | 172 virtual bool CheckValidity() OVERRIDE; |
| 176 | 173 |
| 177 // Returns the name of the temporary file used to buffer data for | 174 // Returns the name of the temporary file used to buffer data for |
| 178 // |filename|. Exported for unit tests. | 175 // |filename|. Exported for unit tests. |
| 179 static const base::FilePath TemporaryFileForFilename( | 176 static const base::FilePath TemporaryFileForFilename( |
| 180 const base::FilePath& filename) { | 177 const base::FilePath& filename) { |
| 181 return base::FilePath(filename.value() + FILE_PATH_LITERAL("_new")); | 178 return base::FilePath(filename.value() + FILE_PATH_LITERAL("_new")); |
| 182 } | 179 } |
| 183 | 180 |
| 184 // Delete any on-disk files, including the permanent storage. | 181 // Delete any on-disk files, including the permanent storage. |
| 185 static bool DeleteStore(const base::FilePath& basename); | 182 static bool DeleteStore(const base::FilePath& basename); |
| 186 | 183 |
| 187 private: | 184 private: |
| 188 // Update store file with pending full hashes. | 185 // Update store file and return |add_full_hashes_result|. |
| 189 virtual bool DoUpdate(const std::vector<SBAddFullHash>& pending_adds, | 186 virtual bool DoUpdate(safe_browsing::PrefixSetBuilder* builder, |
| 190 safe_browsing::PrefixSetBuilder* builder, | |
| 191 std::vector<SBAddFullHash>* add_full_hashes_result); | 187 std::vector<SBAddFullHash>* add_full_hashes_result); |
| 192 | 188 |
| 193 // Enumerate different format-change events for histogramming | 189 // Enumerate different format-change events for histogramming |
| 194 // purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES. | 190 // purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES. |
| 195 // TODO(shess): Remove this once the format change is complete. | 191 // TODO(shess): Remove this once the format change is complete. |
| 196 enum FormatEventType { | 192 enum FormatEventType { |
| 197 // Corruption detected, broken down by file format. | 193 // Corruption detected, broken down by file format. |
| 198 FORMAT_EVENT_FILE_CORRUPT, | 194 FORMAT_EVENT_FILE_CORRUPT, |
| 199 FORMAT_EVENT_SQLITE_CORRUPT, // Obsolete | 195 FORMAT_EVENT_SQLITE_CORRUPT, // Obsolete |
| 200 | 196 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 | 302 |
| 307 // Tracks whether corruption has already been seen in the current | 303 // Tracks whether corruption has already been seen in the current |
| 308 // update, so that only one instance is recorded in the stats. | 304 // update, so that only one instance is recorded in the stats. |
| 309 // TODO(shess): Remove with format-migration support. | 305 // TODO(shess): Remove with format-migration support. |
| 310 bool corruption_seen_; | 306 bool corruption_seen_; |
| 311 | 307 |
| 312 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); | 308 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); |
| 313 }; | 309 }; |
| 314 | 310 |
| 315 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 311 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
| OLD | NEW |