summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authordgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 10:58:16 +0000
committerdgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 10:58:16 +0000
commitf12abfa411c1887b412ea5dc64b0aafe09fb7c86 (patch)
treed5715935c43a5552857766b723bb9884fe08d3ef /third_party
parent7f9f6180b8ccd0bd6cdb81572037ca3e0baba988 (diff)
downloadchromium_src-f12abfa411c1887b412ea5dc64b0aafe09fb7c86.zip
chromium_src-f12abfa411c1887b412ea5dc64b0aafe09fb7c86.tar.gz
chromium_src-f12abfa411c1887b412ea5dc64b0aafe09fb7c86.tar.bz2
Histogram location/error when open or write fails
We currently have to infer which methods are probably causing failures but can't know for sure. This will allow us to know. It was unblocked by the blink->chromium code move; leveldatabase needs to include env_chromium.h. BUG=239880 Review URL: https://chromiumcodereview.appspot.com/16703013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/leveldatabase/env_chromium.cc123
-rw-r--r--third_party/leveldatabase/env_chromium.h14
-rw-r--r--third_party/leveldatabase/env_chromium_unittest.cc21
3 files changed, 90 insertions, 68 deletions
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc
index 71a5c88..8d74569 100644
--- a/third_party/leveldatabase/env_chromium.cc
+++ b/third_party/leveldatabase/env_chromium.cc
@@ -129,56 +129,6 @@ base::FilePath CreateFilePath(const std::string& file_path) {
#endif
}
-const char* MethodIDToString(MethodID method) {
- switch (method) {
- case kSequentialFileRead:
- return "SequentialFileRead";
- case kSequentialFileSkip:
- return "SequentialFileSkip";
- case kRandomAccessFileRead:
- return "RandomAccessFileRead";
- case kWritableFileAppend:
- return "WritableFileAppend";
- case kWritableFileClose:
- return "WritableFileClose";
- case kWritableFileFlush:
- return "WritableFileFlush";
- case kWritableFileSync:
- return "WritableFileSync";
- case kNewSequentialFile:
- return "NewSequentialFile";
- case kNewRandomAccessFile:
- return "NewRandomAccessFile";
- case kNewWritableFile:
- return "NewWritableFile";
- case kDeleteFile:
- return "DeleteFile";
- case kCreateDir:
- return "CreateDir";
- case kDeleteDir:
- return "DeleteDir";
- case kGetFileSize:
- return "GetFileSize";
- case kRenameFile:
- return "RenameFile";
- case kLockFile:
- return "LockFile";
- case kUnlockFile:
- return "UnlockFile";
- case kGetTestDirectory:
- return "GetTestDirectory";
- case kNewLogger:
- return "NewLogger";
- case kSyncParent:
- return "SyncParent";
- case kNumEntries:
- NOTREACHED();
- return "kNumEntries";
- }
- NOTREACHED();
- return "Unknown";
-}
-
static const base::FilePath::CharType kLevelDBTestDirectoryPrefix[]
= FILE_PATH_LITERAL("leveldb-test-");
@@ -351,6 +301,56 @@ class IDBEnv : public ChromiumEnv {
} // unnamed namespace
+const char* MethodIDToString(MethodID method) {
+ switch (method) {
+ case kSequentialFileRead:
+ return "SequentialFileRead";
+ case kSequentialFileSkip:
+ return "SequentialFileSkip";
+ case kRandomAccessFileRead:
+ return "RandomAccessFileRead";
+ case kWritableFileAppend:
+ return "WritableFileAppend";
+ case kWritableFileClose:
+ return "WritableFileClose";
+ case kWritableFileFlush:
+ return "WritableFileFlush";
+ case kWritableFileSync:
+ return "WritableFileSync";
+ case kNewSequentialFile:
+ return "NewSequentialFile";
+ case kNewRandomAccessFile:
+ return "NewRandomAccessFile";
+ case kNewWritableFile:
+ return "NewWritableFile";
+ case kDeleteFile:
+ return "DeleteFile";
+ case kCreateDir:
+ return "CreateDir";
+ case kDeleteDir:
+ return "DeleteDir";
+ case kGetFileSize:
+ return "GetFileSize";
+ case kRenameFile:
+ return "RenameFile";
+ case kLockFile:
+ return "LockFile";
+ case kUnlockFile:
+ return "UnlockFile";
+ case kGetTestDirectory:
+ return "GetTestDirectory";
+ case kNewLogger:
+ return "NewLogger";
+ case kSyncParent:
+ return "SyncParent";
+ case kNumEntries:
+ NOTREACHED();
+ return "kNumEntries";
+ }
+ NOTREACHED();
+ return "Unknown";
+}
+
Status MakeIOError(Slice filename,
const char* message,
MethodID method,
@@ -393,19 +393,26 @@ Status MakeIOError(Slice filename, const char* message, MethodID method) {
return Status::IOError(filename, buf);
}
-bool ParseMethodAndError(const char* string, int* method, int* error) {
- if (RE2::PartialMatch(string, "ChromeMethodOnly: (\\d+)", method))
- return true;
+ErrorParsingResult ParseMethodAndError(const char* string,
+ MethodID* method_param,
+ int* error) {
+ int method;
+ if (RE2::PartialMatch(string, "ChromeMethodOnly: (\\d+)", &method)) {
+ *method_param = static_cast<MethodID>(method);
+ return METHOD_ONLY;
+ }
if (RE2::PartialMatch(
- string, "ChromeMethodPFE: (\\d+)::.*::(\\d+)", method, error)) {
+ string, "ChromeMethodPFE: (\\d+)::.*::(\\d+)", &method, error)) {
*error = -*error;
- return true;
+ *method_param = static_cast<MethodID>(method);
+ return METHOD_AND_PFE;
}
if (RE2::PartialMatch(
- string, "ChromeMethodErrno: (\\d+)::.*::(\\d+)", method, error)) {
- return true;
+ string, "ChromeMethodErrno: (\\d+)::.*::(\\d+)", &method, error)) {
+ *method_param = static_cast<MethodID>(method);
+ return METHOD_AND_ERRNO;
}
- return false;
+ return NONE;
}
std::string FilePathToString(const base::FilePath& file_path) {
diff --git a/third_party/leveldatabase/env_chromium.h b/third_party/leveldatabase/env_chromium.h
index 38a3759..168d180 100644
--- a/third_party/leveldatabase/env_chromium.h
+++ b/third_party/leveldatabase/env_chromium.h
@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_
#define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_
+#include <deque>
#include <map>
#include "base/metrics/histogram.h"
@@ -40,6 +41,8 @@ enum MethodID {
kNumEntries
};
+const char* MethodIDToString(MethodID method);
+
leveldb::Status MakeIOError(leveldb::Slice filename,
const char* message,
MethodID method,
@@ -52,7 +55,16 @@ leveldb::Status MakeIOError(leveldb::Slice filename,
const char* message,
MethodID method);
-bool ParseMethodAndError(const char* string, int* method, int* error);
+enum ErrorParsingResult {
+ METHOD_ONLY,
+ METHOD_AND_PFE,
+ METHOD_AND_ERRNO,
+ NONE,
+};
+
+ErrorParsingResult ParseMethodAndError(const char* string,
+ MethodID* method,
+ int* error);
std::string FilePathToString(const base::FilePath& file_path);
class UMALogger {
diff --git a/third_party/leveldatabase/env_chromium_unittest.cc b/third_party/leveldatabase/env_chromium_unittest.cc
index eae2d6a..e7b0bba 100644
--- a/third_party/leveldatabase/env_chromium_unittest.cc
+++ b/third_party/leveldatabase/env_chromium_unittest.cc
@@ -14,9 +14,10 @@ using namespace leveldb;
TEST(ErrorEncoding, OnlyAMethod) {
const MethodID in_method = kSequentialFileRead;
const Status s = MakeIOError("Somefile.txt", "message", in_method);
- int method = -50;
+ MethodID method;
int error = -75;
- EXPECT_TRUE(ParseMethodAndError(s.ToString().c_str(), &method, &error));
+ EXPECT_EQ(METHOD_ONLY,
+ ParseMethodAndError(s.ToString().c_str(), &method, &error));
EXPECT_EQ(in_method, method);
EXPECT_EQ(-75, error);
}
@@ -26,9 +27,10 @@ TEST(ErrorEncoding, PlatformFileError) {
const base::PlatformFileError pfe =
base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
const Status s = MakeIOError("Somefile.txt", "message", in_method, pfe);
- int method;
+ MethodID method;
int error;
- EXPECT_TRUE(ParseMethodAndError(s.ToString().c_str(), &method, &error));
+ EXPECT_EQ(METHOD_AND_PFE,
+ ParseMethodAndError(s.ToString().c_str(), &method, &error));
EXPECT_EQ(in_method, method);
EXPECT_EQ(pfe, error);
}
@@ -38,19 +40,20 @@ TEST(ErrorEncoding, Errno) {
const int some_errno = ENOENT;
const Status s =
MakeIOError("Somefile.txt", "message", in_method, some_errno);
- int method;
+ MethodID method;
int error;
- EXPECT_TRUE(ParseMethodAndError(s.ToString().c_str(), &method, &error));
+ EXPECT_EQ(METHOD_AND_ERRNO,
+ ParseMethodAndError(s.ToString().c_str(), &method, &error));
EXPECT_EQ(in_method, method);
EXPECT_EQ(some_errno, error);
}
TEST(ErrorEncoding, NoEncodedMessage) {
Status s = Status::IOError("Some message", "from leveldb itself");
- int method = 3;
+ MethodID method = kRandomAccessFileRead;
int error = 4;
- EXPECT_FALSE(ParseMethodAndError(s.ToString().c_str(), &method, &error));
- EXPECT_EQ(3, method);
+ EXPECT_EQ(NONE, ParseMethodAndError(s.ToString().c_str(), &method, &error));
+ EXPECT_EQ(kRandomAccessFileRead, method);
EXPECT_EQ(4, error);
}