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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_store_file.cc

Issue 404803006: Remove some very old-file-format code from safe browsing store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deprecate SB2.OldDatabaseKilobytes Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_store_file.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.cc b/chrome/browser/safe_browsing/safe_browsing_store_file.cc
index e29347e2dd49e09dce74f4277676f63656c19469..e97f0d39d61de9034d5029cfee43565893cb097a 100644
--- a/chrome/browser/safe_browsing/safe_browsing_store_file.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_store_file.cc
@@ -86,8 +86,8 @@ enum FormatEventType {
// The type of format found in the file. The expected case (new
// file format) is intentionally not covered.
- FORMAT_EVENT_FOUND_SQLITE,
- FORMAT_EVENT_FOUND_UNKNOWN,
+ FORMAT_EVENT_FOUND_SQLITE, // Obsolete
+ FORMAT_EVENT_FOUND_UNKNOWN, // magic does not match.
// The number of SQLite-format files deleted should be the same as
// FORMAT_EVENT_FOUND_SQLITE. It can differ if the delete fails,
@@ -97,8 +97,8 @@ enum FormatEventType {
// Found and deleted (or failed to delete) the ancient "Safe
// Browsing" file.
- FORMAT_EVENT_DELETED_ORIGINAL,
- FORMAT_EVENT_DELETED_ORIGINAL_FAILED,
+ FORMAT_EVENT_DELETED_ORIGINAL, // Obsolete
+ FORMAT_EVENT_DELETED_ORIGINAL_FAILED, // Obsolete
// The checksum did not check out in CheckValidity() or in
// FinishUpdate(). This most likely indicates that the machine
@@ -110,6 +110,8 @@ enum FormatEventType {
// indicates that the system crashed while writing an update.
FORMAT_EVENT_HEADER_CHECKSUM_FAILURE,
+ FORMAT_EVENT_FOUND_DEPRECATED, // version too old.
+
// Memory space for histograms is determined by the max. ALWAYS
// ADD NEW VALUES BEFORE THIS ONE.
FORMAT_EVENT_MAX
@@ -630,32 +632,6 @@ bool ReadDbStateHelper(const base::FilePath& filename,
} // namespace
-// static
-void SafeBrowsingStoreFile::CheckForOriginalAndDelete(
- const base::FilePath& current_filename) {
- const base::FilePath original_filename(
- current_filename.DirName().AppendASCII("Safe Browsing"));
- if (base::PathExists(original_filename)) {
- int64 size = 0;
- if (base::GetFileSize(original_filename, &size)) {
- UMA_HISTOGRAM_COUNTS("SB2.OldDatabaseKilobytes",
- static_cast<int>(size / 1024));
- }
-
- if (base::DeleteFile(original_filename, false)) {
- RecordFormatEvent(FORMAT_EVENT_DELETED_ORIGINAL);
- } else {
- RecordFormatEvent(FORMAT_EVENT_DELETED_ORIGINAL_FAILED);
- }
-
- // Just best-effort on the journal file, don't want to get lost in
- // the weeds.
- const base::FilePath journal_filename(
- current_filename.DirName().AppendASCII("Safe Browsing-journal"));
- base::DeleteFile(journal_filename, false);
- }
-}
-
SafeBrowsingStoreFile::SafeBrowsingStoreFile()
: chunks_written_(0), empty_(false), corruption_seen_(false) {}
@@ -817,11 +793,6 @@ bool SafeBrowsingStoreFile::BeginUpdate() {
DCHECK(sub_hashes_.empty());
DCHECK_EQ(chunks_written_, 0);
- // Since the following code will already hit the profile looking for
- // database files, this is a reasonable to time delete any old
- // files.
- CheckForOriginalAndDelete(filename_);
-
corruption_seen_ = false;
const base::FilePath new_filename = TemporaryFileForFilename(filename_);
@@ -849,15 +820,9 @@ bool SafeBrowsingStoreFile::BeginUpdate() {
file.get(), &context);
if (version == kInvalidVersion) {
FileHeaderV8 retry_header;
- if (FileRewind(file.get()) && ReadItem(&retry_header, file.get(), NULL) &&
- (retry_header.magic != kFileMagic ||
- (retry_header.version != 8 && retry_header.version != 7))) {
- // TODO(shess): Think on whether these histograms are generating any
- // actionable data. I kid you not, SQLITE happens many thousands of times
- // per day, UNKNOWN about 3x higher than that.
- if (!strcmp(reinterpret_cast<char*>(&retry_header.magic),
- "SQLite format 3")) {
- RecordFormatEvent(FORMAT_EVENT_FOUND_SQLITE);
+ if (FileRewind(file.get()) && ReadItem(&retry_header, file.get(), NULL)) {
+ if (retry_header.magic == kFileMagic && retry_header.version < 7) {
+ RecordFormatEvent(FORMAT_EVENT_FOUND_DEPRECATED);
} else {
RecordFormatEvent(FORMAT_EVENT_FOUND_UNKNOWN);
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698