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

Unified Diff: remoting/client/plugin/chromoting_instance.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/host/it2me/it2me_native_messaging_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/plugin/chromoting_instance.cc
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 1fa13ebd3a45516d7e2f7fc4beb7bff89830d8a3..e0396a85ceeef8b15cd7afe24a3eaed95fdbe974 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -170,8 +170,8 @@ ChromotingInstance::ChromotingInstance(PP_Instance pp_instance)
thread_wrapper_ =
jingle_glue::JingleThreadWrapper::WrapTaskRunner(plugin_task_runner_);
- // Register a global log handler.
- ChromotingInstance::RegisterLogMessageHandler();
+ // Register a log listener.
+ log_to_ui_ = base::MakeUnique<LogToUI>();
nacl_io_init_ppapi(pp_instance, pp::Module::Get()->get_browser_interface());
mount("", "/etc", "memfs", 0, "");
@@ -1037,15 +1037,6 @@ void ChromotingInstance::UpdatePerfStatsInUI() {
PostLegacyJsonMessage("onPerfStats", std::move(data));
}
-// static
-void ChromotingInstance::RegisterLogMessageHandler() {
- base::AutoLock lock(g_logging_lock.Get());
-
- // Set up log message handler.
- // This is not thread-safe so we need it within our lock.
- logging::SetLogMessageHandler(&LogToUI);
-}
-
void ChromotingInstance::RegisterLoggingInstance() {
base::AutoLock lock(g_logging_lock.Get());
g_logging_instance = pp_instance();
@@ -1062,10 +1053,20 @@ void ChromotingInstance::UnregisterLoggingInstance() {
g_logging_instance = 0;
}
-// static
-bool ChromotingInstance::LogToUI(int severity, const char* file, int line,
- size_t message_start,
- const std::string& str) {
+class LogToUI : logging::LogMessageListener {
+ public:
+ void OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) override;
+};
+
+void LogToUI::OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
PP_LogLevel log_level = PP_LOGLEVEL_ERROR;
switch (severity) {
case logging::LOG_INFO:
@@ -1098,8 +1099,6 @@ bool ChromotingInstance::LogToUI(int severity, const char* file, int line,
// may crash before the message is delivered to the console.
if (severity == logging::LOG_FATAL)
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
-
- return false;
}
bool ChromotingInstance::IsConnected() {
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/host/it2me/it2me_native_messaging_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698