diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-11 22:38:48 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-11 22:38:48 +0000 |
commit | 1e5c78c698039ab93e989f8b1e78c00e7ae5206c (patch) | |
tree | 5348cc0d6108686b42a39781f8eb2d507312dd77 /chrome/browser/safe_browsing/safe_browsing_store_file.cc | |
parent | 018cbb25b18f517870d08706cc0b367a6ae04a82 (diff) | |
download | chromium_src-1e5c78c698039ab93e989f8b1e78c00e7ae5206c.zip chromium_src-1e5c78c698039ab93e989f8b1e78c00e7ae5206c.tar.gz chromium_src-1e5c78c698039ab93e989f8b1e78c00e7ae5206c.tar.bz2 |
Instrument safe-browsing to track file-format conversion.
Also track corruption separately for old and new file formats.
BUG=58552
TEST=none
Review URL: http://codereview.chromium.org/3632004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_store_file.cc')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_store_file.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.cc b/chrome/browser/safe_browsing/safe_browsing_store_file.cc index 7402d9a..a30bf51 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file.cc @@ -171,6 +171,11 @@ bool FileHeaderSanityCheck(const FilePath& filename, } // namespace +// static +void SafeBrowsingStoreFile::RecordFormatEvent(FormatEventType event_type) { + UMA_HISTOGRAM_ENUMERATION("SB2.FormatEvent", event_type, FORMAT_EVENT_MAX); +} + SafeBrowsingStoreFile::SafeBrowsingStoreFile() : chunks_written_(0), file_(NULL), @@ -251,6 +256,10 @@ bool SafeBrowsingStoreFile::WriteSubHash(int32 chunk_id, int32 add_chunk_id, } bool SafeBrowsingStoreFile::OnCorruptDatabase() { + if (!corruption_seen_) + RecordFormatEvent(FORMAT_EVENT_FILE_CORRUPT); + corruption_seen_ = true; + if (corruption_callback_.get()) corruption_callback_->Run(); @@ -258,6 +267,15 @@ bool SafeBrowsingStoreFile::OnCorruptDatabase() { return false; } +void SafeBrowsingStoreFile::HandleCorruptDatabase() { + if (!corruption_seen_) + RecordFormatEvent(FORMAT_EVENT_SQLITE_CORRUPT); + corruption_seen_ = true; + + if (corruption_callback_.get()) + corruption_callback_->Run(); +} + bool SafeBrowsingStoreFile::Close() { ClearUpdateBuffers(); @@ -282,6 +300,8 @@ bool SafeBrowsingStoreFile::BeginUpdate() { DCHECK(sub_hashes_.empty()); DCHECK_EQ(chunks_written_, 0); + corruption_seen_ = false; + const FilePath new_filename = TemporaryFileForFilename(filename_); file_util::ScopedFILE new_file(file_util::OpenFile(new_filename, "wb+")); if (new_file.get() == NULL) @@ -304,6 +324,12 @@ bool SafeBrowsingStoreFile::BeginUpdate() { return OnCorruptDatabase(); if (header.magic != kFileMagic || header.version != kFileVersion) { + if (!strcmp(reinterpret_cast<char*>(&header.magic), "SQLite format 3")) { + RecordFormatEvent(FORMAT_EVENT_FOUND_SQLITE); + } else { + RecordFormatEvent(FORMAT_EVENT_FOUND_UNKNOWN); + } + // Something about having the file open causes a problem with // SQLite opening it. Perhaps PRAGMA locking_mode = EXCLUSIVE? file.reset(); @@ -571,8 +597,11 @@ bool SafeBrowsingStoreFile::DoUpdate( if (old_store_.get()) { const bool deleted = old_store_->Delete(); old_store_.reset(); - if (!deleted) + if (!deleted) { + RecordFormatEvent(FORMAT_EVENT_SQLITE_DELETE_FAILED); return false; + } + RecordFormatEvent(FORMAT_EVENT_SQLITE_DELETED); } else { if (!file_util::Delete(filename_, false) && file_util::PathExists(filename_)) |