Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_store_file.h

Issue 10093004: Double-check safe-browsing database validity on update failure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check size before reading. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_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 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 virtual void SetAddChunk(int32 chunk_id) OVERRIDE; 146 virtual void SetAddChunk(int32 chunk_id) OVERRIDE;
147 virtual bool CheckAddChunk(int32 chunk_id) OVERRIDE; 147 virtual bool CheckAddChunk(int32 chunk_id) OVERRIDE;
148 virtual void GetAddChunks(std::vector<int32>* out) OVERRIDE; 148 virtual void GetAddChunks(std::vector<int32>* out) OVERRIDE;
149 virtual void SetSubChunk(int32 chunk_id) OVERRIDE; 149 virtual void SetSubChunk(int32 chunk_id) OVERRIDE;
150 virtual bool CheckSubChunk(int32 chunk_id) OVERRIDE; 150 virtual bool CheckSubChunk(int32 chunk_id) OVERRIDE;
151 virtual void GetSubChunks(std::vector<int32>* out) OVERRIDE; 151 virtual void GetSubChunks(std::vector<int32>* out) OVERRIDE;
152 152
153 virtual void DeleteAddChunk(int32 chunk_id) OVERRIDE; 153 virtual void DeleteAddChunk(int32 chunk_id) OVERRIDE;
154 virtual void DeleteSubChunk(int32 chunk_id) OVERRIDE; 154 virtual void DeleteSubChunk(int32 chunk_id) OVERRIDE;
155 155
156 // Verify |file_|'s checksum, calling the corruption callback if it
157 // does not check out. Empty input is considered valid.
158 virtual bool CheckValidity() OVERRIDE;
159
156 // Returns the name of the temporary file used to buffer data for 160 // Returns the name of the temporary file used to buffer data for
157 // |filename|. Exported for unit tests. 161 // |filename|. Exported for unit tests.
158 static const FilePath TemporaryFileForFilename(const FilePath& filename) { 162 static const FilePath TemporaryFileForFilename(const FilePath& filename) {
159 return FilePath(filename.value() + FILE_PATH_LITERAL("_new")); 163 return FilePath(filename.value() + FILE_PATH_LITERAL("_new"));
160 } 164 }
161 165
162 private: 166 private:
163 // Update store file with pending full hashes. 167 // Update store file with pending full hashes.
164 virtual bool DoUpdate(const std::vector<SBAddFullHash>& pending_adds, 168 virtual bool DoUpdate(const std::vector<SBAddFullHash>& pending_adds,
165 const std::set<SBPrefix>& prefix_misses, 169 const std::set<SBPrefix>& prefix_misses,
(...skipping 17 matching lines...) Expand all
183 // FORMAT_EVENT_FOUND_SQLITE. It can differ if the delete fails, 187 // FORMAT_EVENT_FOUND_SQLITE. It can differ if the delete fails,
184 // or if a failure prevents the update from succeeding. 188 // or if a failure prevents the update from succeeding.
185 FORMAT_EVENT_SQLITE_DELETED, // Obsolete 189 FORMAT_EVENT_SQLITE_DELETED, // Obsolete
186 FORMAT_EVENT_SQLITE_DELETE_FAILED, // Obsolete 190 FORMAT_EVENT_SQLITE_DELETE_FAILED, // Obsolete
187 191
188 // Found and deleted (or failed to delete) the ancient "Safe 192 // Found and deleted (or failed to delete) the ancient "Safe
189 // Browsing" file. 193 // Browsing" file.
190 FORMAT_EVENT_DELETED_ORIGINAL, 194 FORMAT_EVENT_DELETED_ORIGINAL,
191 FORMAT_EVENT_DELETED_ORIGINAL_FAILED, 195 FORMAT_EVENT_DELETED_ORIGINAL_FAILED,
192 196
197 // The checksum did not check out in CheckValidity() or in
198 // FinishUpdate(). This most likely indicates that the machine
199 // crashed before the file was fully sync'ed to disk.
200 FORMAT_EVENT_VALIDITY_CHECKSUM_FAILURE,
201 FORMAT_EVENT_UPDATE_CHECKSUM_FAILURE,
202
193 // Memory space for histograms is determined by the max. ALWAYS 203 // Memory space for histograms is determined by the max. ALWAYS
194 // ADD NEW VALUES BEFORE THIS ONE. 204 // ADD NEW VALUES BEFORE THIS ONE.
195 FORMAT_EVENT_MAX 205 FORMAT_EVENT_MAX
196 }; 206 };
197 207
198 // Helper to record an event related to format conversion from 208 // Helper to record an event related to format conversion from
199 // SQLite to file. 209 // SQLite to file.
200 static void RecordFormatEvent(FormatEventType event_type); 210 static void RecordFormatEvent(FormatEventType event_type);
201 211
202 // Some very lucky users have an original-format file still in their 212 // Some very lucky users have an original-format file still in their
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 286
277 // Tracks whether corruption has already been seen in the current 287 // Tracks whether corruption has already been seen in the current
278 // update, so that only one instance is recorded in the stats. 288 // update, so that only one instance is recorded in the stats.
279 // TODO(shess): Remove with format-migration support. 289 // TODO(shess): Remove with format-migration support.
280 bool corruption_seen_; 290 bool corruption_seen_;
281 291
282 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); 292 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile);
283 }; 293 };
284 294
285 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ 295 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_store.h ('k') | chrome/browser/safe_browsing/safe_browsing_store_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698