Index: chrome/installer/util/installation_validation_helper.cc |
diff --git a/chrome/installer/util/installation_validation_helper.cc b/chrome/installer/util/installation_validation_helper.cc |
index e0252e975b26380a34985e42d0343b4d41c1c0eb..b586070d9966bf8daf06ae4b5dfb15283eea80e0 100644 |
--- a/chrome/installer/util/installation_validation_helper.cc |
+++ b/chrome/installer/util/installation_validation_helper.cc |
@@ -21,20 +21,19 @@ namespace { |
// A helper class that installs a log message handler to add a test failure for |
// each ERROR message. Only one instance of this class may be live at a time. |
-class FailureLogHelper { |
+class FailureLogHelper : logging::LogMessageHandler { |
public: |
FailureLogHelper(); |
- ~FailureLogHelper(); |
+ ~FailureLogHelper() override; |
- private: |
- static bool AddFailureForLogMessage(int severity, |
- const char* file, |
- int line, |
- size_t message_start, |
- const std::string& str); |
+ bool OnMessage(int severity, |
+ const char* file, |
+ int line, |
+ size_t message_start, |
+ const std::string& str) override; |
+ private: |
static const logging::LogSeverity kViolationSeverity_; |
- static logging::LogMessageHandlerFunction old_message_handler_; |
static int old_min_log_level_; |
}; |
@@ -44,44 +43,32 @@ const logging::LogSeverity |
FailureLogHelper::kViolationSeverity_ = logging::LOG_ERROR; |
// static |
-logging::LogMessageHandlerFunction |
- FailureLogHelper::old_message_handler_ = NULL; |
- |
-// static |
int FailureLogHelper::old_min_log_level_ = |
FailureLogHelper::kViolationSeverity_; |
FailureLogHelper::FailureLogHelper() { |
- LOG_ASSERT(old_message_handler_ == NULL); |
- |
// The validator logs at ERROR level. Ensure that it generates messages so we |
// can transform them into test failures. |
old_min_log_level_ = logging::GetMinLogLevel(); |
if (old_min_log_level_ > kViolationSeverity_) |
logging::SetMinLogLevel(kViolationSeverity_); |
- |
- old_message_handler_ = logging::GetLogMessageHandler(); |
- logging::SetLogMessageHandler(&AddFailureForLogMessage); |
} |
FailureLogHelper::~FailureLogHelper() { |
- logging::SetLogMessageHandler(old_message_handler_); |
- old_message_handler_ = NULL; |
- |
if (old_min_log_level_ > kViolationSeverity_) |
logging::SetMinLogLevel(old_min_log_level_); |
} |
-// A logging::LogMessageHandlerFunction that adds a non-fatal test failure |
+// A logging::LogMessageHandler that adds a non-fatal test failure |
// (i.e., similar to an unmet EXPECT_FOO) for each non-empty message logged at |
// the severity of validation violations. All other messages are sent through |
// the default logging pipeline. |
// static |
-bool FailureLogHelper::AddFailureForLogMessage(int severity, |
- const char* file, |
- int line, |
- size_t message_start, |
- const std::string& str) { |
+bool FailureLogHelper::OnMessage(int severity, |
+ const char* file, |
+ int line, |
+ size_t message_start, |
+ const std::string& str) { |
if (severity == kViolationSeverity_ && !str.empty()) { |
// Remove the trailing newline, if present. |
size_t message_length = str.size() - message_start; |
@@ -92,9 +79,6 @@ bool FailureLogHelper::AddFailureForLogMessage(int severity, |
return true; |
} |
- if (old_message_handler_ != NULL) |
- return (old_message_handler_)(severity, file, line, message_start, str); |
- |
return false; |
} |