diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 18:35:33 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 18:35:33 +0000 |
commit | ad640d646b4a2aa5f5426d75b89f6ca13044d3a5 (patch) | |
tree | 555436822e1bd48b85d16a0325d17184396846d3 /base | |
parent | 27e05c13c72fa4f026dff1e515ee74136b076990 (diff) | |
download | chromium_src-ad640d646b4a2aa5f5426d75b89f6ca13044d3a5.zip chromium_src-ad640d646b4a2aa5f5426d75b89f6ca13044d3a5.tar.gz chromium_src-ad640d646b4a2aa5f5426d75b89f6ca13044d3a5.tar.bz2 |
Add histograms to see if we can find out why we're failing
to load resources.pak on Windows.
BUG=58056
Review URL: http://codereview.chromium.org/3616007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/data_pack.cc | 21 | ||||
-rw-r--r-- | base/file_util_win.cc | 16 |
2 files changed, 36 insertions, 1 deletions
diff --git a/base/data_pack.cc b/base/data_pack.cc index c130031..29ecf98 100644 --- a/base/data_pack.cc +++ b/base/data_pack.cc @@ -7,6 +7,7 @@ #include <errno.h> #include "base/file_util.h" +#include "base/histogram.h" #include "base/logging.h" #include "base/ref_counted_memory.h" #include "base/string_piece.h" @@ -44,6 +45,18 @@ struct DataPackEntry { COMPILE_ASSERT(sizeof(DataPackEntry) == 12, size_of_header_must_be_twelve); +// We're crashing when trying to load a pak file on Windows. Add some error +// codes for logging. +// http://crbug.com/58056 +enum LoadErrors { + INIT_FAILED = 1, + BAD_VERSION, + INDEX_TRUNCATED, + ENTRY_NOT_FOUND, + + LOAD_ERRORS_COUNT, +}; + } // anonymous namespace namespace base { @@ -58,6 +71,8 @@ bool DataPack::Load(const FilePath& path) { mmap_.reset(new file_util::MemoryMappedFile); if (!mmap_->Initialize(path)) { DLOG(ERROR) << "Failed to mmap datapack"; + UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED, + LOAD_ERRORS_COUNT); return false; } @@ -68,6 +83,8 @@ bool DataPack::Load(const FilePath& path) { if (version != kFileFormatVersion) { LOG(ERROR) << "Bad data pack version: got " << version << ", expected " << kFileFormatVersion; + UMA_HISTOGRAM_ENUMERATION("DataPack.Load", BAD_VERSION, + LOAD_ERRORS_COUNT); mmap_.reset(); return false; } @@ -79,6 +96,8 @@ bool DataPack::Load(const FilePath& path) { mmap_->length()) { LOG(ERROR) << "Data pack file corruption: too short for number of " "entries specified."; + UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INDEX_TRUNCATED, + LOAD_ERRORS_COUNT); mmap_.reset(); return false; } @@ -89,6 +108,8 @@ bool DataPack::Load(const FilePath& path) { if (entry->file_offset + entry->length > mmap_->length()) { LOG(ERROR) << "Entry #" << i << " in data pack points off end of file. " << "Was the file corrupted?"; + UMA_HISTOGRAM_ENUMERATION("DataPack.Load", ENTRY_NOT_FOUND, + LOAD_ERRORS_COUNT); mmap_.reset(); return false; } diff --git a/base/file_util_win.cc b/base/file_util_win.cc index a376d0d..876b89d 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -13,6 +13,7 @@ #include <string> #include "base/file_path.h" +#include "base/histogram.h" #include "base/logging.h" #include "base/pe_image.h" #include "base/scoped_comptr_win.h" @@ -897,11 +898,24 @@ bool MemoryMappedFile::MapFileToMemoryInternal() { // therefore the cast here is safe. file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY, 0, static_cast<DWORD>(length_), NULL); - if (file_mapping_ == INVALID_HANDLE_VALUE) + if (file_mapping_ == INVALID_HANDLE_VALUE) { + // According to msdn, system error codes are only reserved up to 15999. + // http://msdn.microsoft.com/en-us/library/ms681381(v=VS.85).aspx. + UMA_HISTOGRAM_ENUMERATION("MemoryMappedFile.CreateFileMapping", + std::min(logging::GetLastSystemErrorCode(), + static_cast<logging::SystemErrorCode>(15999)), + 16000); return false; + } data_ = static_cast<uint8*>( ::MapViewOfFile(file_mapping_, FILE_MAP_READ, 0, 0, length_)); + if (!data_) { + UMA_HISTOGRAM_ENUMERATION("MemoryMappedFile.MapViewOfFile", + std::min(logging::GetLastSystemErrorCode(), + static_cast<logging::SystemErrorCode>(15999)), + 16000); + } return data_ != NULL; } |