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

Unified Diff: chrome/browser/media/webrtc_browsertest_base.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments, format Created 4 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
Index: chrome/browser/media/webrtc_browsertest_base.cc
diff --git a/chrome/browser/media/webrtc_browsertest_base.cc b/chrome/browser/media/webrtc_browsertest_base.cc
index 9a40c5b80c4497e6362c276edf227dd8e715f7b8..c67b28dc1380edd3f850db69c7a2b387a6243c92 100644
--- a/chrome/browser/media/webrtc_browsertest_base.cc
+++ b/chrome/browser/media/webrtc_browsertest_base.cc
@@ -64,24 +64,20 @@ base::LazyInstance<bool> hit_javascript_errors_ =
LAZY_INSTANCE_INITIALIZER;
// Intercepts all log messages. We always attach this handler but only look at
-// the results if the test requests so. Note that this will only work if the
-// WebrtcTestBase-inheriting test cases do not run in parallel (if they did they
-// would race to look at the log, which is global to all tests).
-bool JavascriptErrorDetectingLogHandler(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& str) {
+// the results if the test requests so.
+void JavascriptErrorDetectingLogListener(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
if (file == NULL || std::string("CONSOLE") != file)
- return false;
+ return;
bool contains_uncaught = str.find("\"Uncaught ") != std::string::npos;
if (severity == logging::LOG_ERROR ||
(severity == logging::LOG_INFO && contains_uncaught)) {
hit_javascript_errors_.Get() = true;
}
-
- return false;
}
// PermissionRequestObserver ---------------------------------------------------
@@ -121,10 +117,9 @@ class PermissionRequestObserver : public PermissionBubbleManager::Observer {
} // namespace
-WebRtcTestBase::WebRtcTestBase(): detect_errors_in_javascript_(false) {
- // The handler gets set for each test method, but that's fine since this
- // set operation is idempotent.
- logging::SetLogMessageHandler(&JavascriptErrorDetectingLogHandler);
+WebRtcTestBase::WebRtcTestBase()
+ : log_listener_(JavascriptErrorDetectingLogListener),
+ detect_errors_in_javascript_(false) {
hit_javascript_errors_.Get() = false;
EnablePixelOutput();

Powered by Google App Engine
This is Rietveld 408576698