diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-13 00:34:50 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-13 00:34:50 +0000 |
commit | f51eef8d464072880a308bb4c4fa03fc7a29cbfa (patch) | |
tree | 2fe15457fdd8fe6f740df0af572045a66aa99932 /remoting/host | |
parent | 083917c81339b1349c300b191f3ddc9c333c16d7 (diff) | |
download | chromium_src-f51eef8d464072880a308bb4c4fa03fc7a29cbfa.zip chromium_src-f51eef8d464072880a308bb4c4fa03fc7a29cbfa.tar.gz chromium_src-f51eef8d464072880a308bb4c4fa03fc7a29cbfa.tar.bz2 |
Fixup threading for Chromoting's logging code.
Move va_Log and va_VLog into base remoting::Logger class to remove duplicate code and simplify the host/client loggers.
BUG=88792
TEST=none
Review URL: http://codereview.chromium.org/7285047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/chromoting_host.cc | 1 | ||||
-rw-r--r-- | remoting/host/plugin/host_plugin_logger.cc | 54 | ||||
-rw-r--r-- | remoting/host/plugin/host_plugin_logger.h | 13 |
3 files changed, 4 insertions, 64 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 49c315b..0b9c3aa 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -70,6 +70,7 @@ ChromotingHost::ChromotingHost(ChromotingHostContext* context, is_it2me_(false) { DCHECK(desktop_environment_.get()); desktop_environment_->set_host(this); + logger_->SetThread(MessageLoop::current()); } ChromotingHost::~ChromotingHost() { diff --git a/remoting/host/plugin/host_plugin_logger.cc b/remoting/host/plugin/host_plugin_logger.cc index 06865a6..bf33f66 100644 --- a/remoting/host/plugin/host_plugin_logger.cc +++ b/remoting/host/plugin/host_plugin_logger.cc @@ -4,68 +4,18 @@ #include "remoting/host/plugin/host_plugin_logger.h" -#include <stdarg.h> // va_list - -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/stringprintf.h" #include "remoting/host/plugin/host_script_object.h" namespace remoting { HostPluginLogger::HostPluginLogger(HostNPScriptObject* scriptable) - : scriptable_object_(scriptable), - message_loop_(MessageLoop::current()) { + : scriptable_object_(scriptable) { } HostPluginLogger::~HostPluginLogger() { } -void HostPluginLogger::va_Log(logging::LogSeverity severity, - const char* format, va_list ap) { - DCHECK(severity >= 0 && severity <= logging::LOG_NUM_SEVERITIES); - - // Based in LOG_IS_ON macro in base/logging.h. - if (severity >= ::logging::GetMinLogLevel()) { - std::string message; - base::StringAppendV(&message, format, ap); - - // Standard logging. - logging::LogMessage(__FILE__, __LINE__, severity).stream() << message; - - // Send log message to the host UI. - LogToHostUI(StringPrintf("LOG(%s) %s", - log_severity_names[severity], message.c_str())); - } - - va_end(ap); -} - -void HostPluginLogger::va_VLog(int verboselevel, - const char* format, - va_list ap) { - if (VLOG_IS_ON(verboselevel)) { - std::string message; - base::StringAppendV(&message, format, ap); - - // Standard verbose logging. - VLOG(verboselevel) << message; - - // Send log message to the host UI. - LogToHostUI(StringPrintf("VLOG(%d) %s", verboselevel, message.c_str())); - } -} - -void HostPluginLogger::LogToHostUI(const std::string& message) { - // TODO(garykac): Fix crbug.com/88792 - return; - if (message_loop_ != MessageLoop::current()) { - message_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &HostPluginLogger::LogToHostUI, message)); - return; - } - +void HostPluginLogger::LogToUI(const std::string& message) { scriptable_object_->LogDebugInfo(message); } diff --git a/remoting/host/plugin/host_plugin_logger.h b/remoting/host/plugin/host_plugin_logger.h index 7d216eb..69abea5 100644 --- a/remoting/host/plugin/host_plugin_logger.h +++ b/remoting/host/plugin/host_plugin_logger.h @@ -7,10 +7,6 @@ #include "remoting/base/logger.h" -#include "base/task.h" - -class MessageLoop; - namespace remoting { class HostNPScriptObject; @@ -20,21 +16,14 @@ class HostPluginLogger : public Logger { explicit HostPluginLogger(HostNPScriptObject* scriptable); virtual ~HostPluginLogger(); - virtual void va_Log(logging::LogSeverity severity, const char* format, - va_list ap); - virtual void va_VLog(int verboselevel, const char* format, va_list ap); + virtual void LogToUI(const std::string& message); private: - void LogToHostUI(const std::string& message); - HostNPScriptObject* scriptable_object_; - MessageLoop* message_loop_; DISALLOW_COPY_AND_ASSIGN(HostPluginLogger); }; } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostPluginLogger); - #endif // REMOTING_HOST_PLUGIN_HOST_PLUGIN_LOGGER_H_ |