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

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

Issue 10211013: Do not validity check safe-browsing store if not opened. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h"
6 6
7 #include "base/md5.h" 7 #include "base/md5.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 9
10 namespace { 10 namespace {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // also removed. 237 // also removed.
238 const FilePath journal_filename( 238 const FilePath journal_filename(
239 filename_.value() + FILE_PATH_LITERAL("-journal")); 239 filename_.value() + FILE_PATH_LITERAL("-journal"));
240 if (file_util::PathExists(journal_filename)) 240 if (file_util::PathExists(journal_filename))
241 file_util::Delete(journal_filename, false); 241 file_util::Delete(journal_filename, false);
242 242
243 return true; 243 return true;
244 } 244 }
245 245
246 bool SafeBrowsingStoreFile::CheckValidity() { 246 bool SafeBrowsingStoreFile::CheckValidity() {
247 if (empty_) 247 // The file was either empty or never opened. The empty case is
248 // presumed not to be invalid. The never-opened case can happen if
249 // BeginUpdate() fails for any databases, and should already have
250 // caused the corruption callback to fire.
251 if (!file_.get())
248 return true; 252 return true;
249 253
250 // If the file was not empty, it should be open.
251 DCHECK(file_.get());
252
253 if (!FileRewind(file_.get())) 254 if (!FileRewind(file_.get()))
254 return OnCorruptDatabase(); 255 return OnCorruptDatabase();
255 256
256 int64 size = 0; 257 int64 size = 0;
257 if (!file_util::GetFileSize(filename_, &size)) 258 if (!file_util::GetFileSize(filename_, &size))
258 return OnCorruptDatabase(); 259 return OnCorruptDatabase();
259 260
260 base::MD5Context context; 261 base::MD5Context context;
261 base::MD5Init(&context); 262 base::MD5Init(&context);
262 263
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 out->insert(out->end(), sub_chunks_cache_.begin(), sub_chunks_cache_.end()); 750 out->insert(out->end(), sub_chunks_cache_.begin(), sub_chunks_cache_.end());
750 } 751 }
751 752
752 void SafeBrowsingStoreFile::DeleteAddChunk(int32 chunk_id) { 753 void SafeBrowsingStoreFile::DeleteAddChunk(int32 chunk_id) {
753 add_del_cache_.insert(chunk_id); 754 add_del_cache_.insert(chunk_id);
754 } 755 }
755 756
756 void SafeBrowsingStoreFile::DeleteSubChunk(int32 chunk_id) { 757 void SafeBrowsingStoreFile::DeleteSubChunk(int32 chunk_id) {
757 sub_del_cache_.insert(chunk_id); 758 sub_del_cache_.insert(chunk_id);
758 } 759 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698