summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgarykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-07 23:05:01 +0000
committergarykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-07 23:05:01 +0000
commit9a37fdf2a4314bf49c003a8f126f06751ba1ba55 (patch)
tree4659ba663a7c6eeaf125b63db2311f0787a78a34
parent02712128820af52b4ed31830fe950d64102cf954 (diff)
downloadchromium_src-9a37fdf2a4314bf49c003a8f126f06751ba1ba55.zip
chromium_src-9a37fdf2a4314bf49c003a8f126f06751ba1ba55.tar.gz
chromium_src-9a37fdf2a4314bf49c003a8f126f06751ba1ba55.tar.bz2
Conenct Chromoting plugin debug log to JS UI.
BUG=none TEST=none Review URL: http://codereview.chromium.org/7262015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91779 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/base/logger.cc (renamed from remoting/client/client_logger.cc)18
-rw-r--r--remoting/base/logger.h (renamed from remoting/client/client_logger.h)17
-rw-r--r--remoting/client/chromoting_client.cc4
-rw-r--r--remoting/client/chromoting_client.h6
-rw-r--r--remoting/client/plugin/pepper_client_logger.cc4
-rw-r--r--remoting/client/plugin/pepper_client_logger.h6
-rw-r--r--remoting/host/chromoting_host.cc39
-rw-r--r--remoting/host/chromoting_host.h15
-rw-r--r--remoting/host/chromoting_host_unittest.cc8
-rw-r--r--remoting/host/plugin/host_plugin_logger.cc70
-rw-r--r--remoting/host/plugin/host_plugin_logger.h40
-rw-r--r--remoting/host/plugin/host_script_object.cc26
-rw-r--r--remoting/host/plugin/host_script_object.h9
-rw-r--r--remoting/host/simple_host_process.cc8
-rw-r--r--remoting/remoting.gyp6
-rw-r--r--remoting/webapp/me2mom/remoting.js2
16 files changed, 212 insertions, 66 deletions
diff --git a/remoting/client/client_logger.cc b/remoting/base/logger.cc
index b970697..f4def7b 100644
--- a/remoting/client/client_logger.cc
+++ b/remoting/base/logger.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/client/client_logger.h"
+#include "remoting/base/logger.h"
#include <stdarg.h> // va_list
@@ -10,34 +10,38 @@
namespace remoting {
-ClientLogger::ClientLogger() {
+// Copied from base/logging.cc.
+const char* const Logger::log_severity_names[logging::LOG_NUM_SEVERITIES] = {
+ "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" };
+
+Logger::Logger() {
}
-ClientLogger::~ClientLogger() {
+Logger::~Logger() {
}
-void ClientLogger::Log(logging::LogSeverity severity, const char* format, ...) {
+void Logger::Log(logging::LogSeverity severity, const char* format, ...) {
va_list ap;
va_start(ap, format);
va_Log(severity, format, ap);
va_end(ap);
}
-void ClientLogger::VLog(int verboselevel, const char* format, ...) {
+void Logger::VLog(int verboselevel, const char* format, ...) {
va_list ap;
va_start(ap, format);
va_VLog(verboselevel, format, ap);
va_end(ap);
}
-void ClientLogger::va_Log(logging::LogSeverity severity,
+void Logger::va_Log(logging::LogSeverity severity,
const char* format, va_list ap) {
std::string message;
base::StringAppendV(&message, format, ap);
logging::LogMessage(__FILE__, __LINE__, severity).stream() << message;
}
-void ClientLogger::va_VLog(int verboselevel, const char* format, va_list ap) {
+void Logger::va_VLog(int verboselevel, const char* format, va_list ap) {
std::string message;
base::StringAppendV(&message, format, ap);
VLOG(verboselevel) << message;
diff --git a/remoting/client/client_logger.h b/remoting/base/logger.h
index f481c51..1022e4f 100644
--- a/remoting/client/client_logger.h
+++ b/remoting/base/logger.h
@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_CLIENT_CLIENT_LOGGER_H_
-#define REMOTING_CLIENT_CLIENT_LOGGER_H_
+#ifndef REMOTING_BASE_LOGGER_H_
+#define REMOTING_BASE_LOGGER_H_
#include "base/basictypes.h"
#include "base/logging.h"
namespace remoting {
-class ClientLogger {
+class Logger {
public:
- ClientLogger();
- virtual ~ClientLogger();
+ Logger();
+ virtual ~Logger();
void Log(logging::LogSeverity severity, const char* format, ...);
void VLog(int verboselevel, const char* format, ...);
@@ -22,10 +22,13 @@ class ClientLogger {
const char* format, va_list ap);
virtual void va_VLog(int verboselevel, const char* format, va_list ap);
+ protected:
+ static const char* const log_severity_names[];
+
private:
- DISALLOW_COPY_AND_ASSIGN(ClientLogger);
+ DISALLOW_COPY_AND_ASSIGN(Logger);
};
} // namespace remoting
-#endif // REMOTING_CLIENT_CLIENT_LOGGER_H_
+#endif // REMOTING_BASE_LOGGER_H_
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index d7eee8e..ff926a2 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -6,10 +6,10 @@
#include "base/bind.h"
#include "base/message_loop.h"
+#include "remoting/base/logger.h"
#include "remoting/base/tracer.h"
#include "remoting/client/chromoting_view.h"
#include "remoting/client/client_context.h"
-#include "remoting/client/client_logger.h"
#include "remoting/client/input_handler.h"
#include "remoting/client/rectangle_update_decoder.h"
#include "remoting/protocol/connection_to_host.h"
@@ -23,7 +23,7 @@ ChromotingClient::ChromotingClient(const ClientConfig& config,
ChromotingView* view,
RectangleUpdateDecoder* rectangle_decoder,
InputHandler* input_handler,
- ClientLogger* logger,
+ Logger* logger,
Task* client_done)
: config_(config),
context_(context),
diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h
index 67bda81..94091f1 100644
--- a/remoting/client/chromoting_client.h
+++ b/remoting/client/chromoting_client.h
@@ -30,8 +30,8 @@ class NotifyResolutionRequest;
} // namespace protocol
class ClientContext;
-class ClientLogger;
class InputHandler;
+class Logger;
class RectangleUpdateDecoder;
// TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder.
@@ -46,7 +46,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
ChromotingView* view,
RectangleUpdateDecoder* rectangle_decoder,
InputHandler* input_handler,
- ClientLogger* logger,
+ Logger* logger,
Task* client_done);
virtual ~ChromotingClient();
@@ -118,7 +118,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
ChromotingView* view_;
RectangleUpdateDecoder* rectangle_decoder_;
InputHandler* input_handler_;
- ClientLogger* logger_;
+ Logger* logger_;
// If non-NULL, this is called when the client is done.
Task* client_done_;
diff --git a/remoting/client/plugin/pepper_client_logger.cc b/remoting/client/plugin/pepper_client_logger.cc
index c2fab45..6862e63 100644
--- a/remoting/client/plugin/pepper_client_logger.cc
+++ b/remoting/client/plugin/pepper_client_logger.cc
@@ -21,10 +21,6 @@ PepperClientLogger::PepperClientLogger(ChromotingInstance* instance)
PepperClientLogger::~PepperClientLogger() {
}
-// Copied from base/logging.cc.
-const char* const log_severity_names[logging::LOG_NUM_SEVERITIES] = {
- "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" };
-
void PepperClientLogger::va_Log(logging::LogSeverity severity,
const char* format, va_list ap) {
DCHECK(severity >= 0 && severity <= logging::LOG_NUM_SEVERITIES);
diff --git a/remoting/client/plugin/pepper_client_logger.h b/remoting/client/plugin/pepper_client_logger.h
index c953e71..98a3b42 100644
--- a/remoting/client/plugin/pepper_client_logger.h
+++ b/remoting/client/plugin/pepper_client_logger.h
@@ -5,7 +5,7 @@
#ifndef REMOTING_CLIENT_PLUGIN_PEPPER_CLIENT_LOGGER_H_
#define REMOTING_CLIENT_PLUGIN_PEPPER_CLIENT_LOGGER_H_
-#include "remoting/client/client_logger.h"
+#include "remoting/base/logger.h"
#include "base/task.h"
@@ -15,9 +15,9 @@ namespace remoting {
class ChromotingInstance;
-class PepperClientLogger : public ClientLogger {
+class PepperClientLogger : public Logger {
public:
- PepperClientLogger(ChromotingInstance* instance);
+ explicit PepperClientLogger(ChromotingInstance* instance);
virtual ~PepperClientLogger();
virtual void va_Log(logging::LogSeverity severity, const char* format,
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 8790272..49c315b 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -6,11 +6,13 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/logging.h"
#include "build/build_config.h"
#include "remoting/base/constants.h"
#include "remoting/base/encoder.h"
#include "remoting/base/encoder_row_based.h"
#include "remoting/base/encoder_vp8.h"
+#include "remoting/base/logger.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/curtain.h"
#include "remoting/host/desktop_environment.h"
@@ -36,27 +38,32 @@ namespace remoting {
// static
ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context,
MutableHostConfig* config,
- AccessVerifier* access_verifier) {
+ AccessVerifier* access_verifier,
+ Logger* logger) {
DesktopEnvironment* desktop_env = DesktopEnvironment::Create(context);
- return Create(context, config, desktop_env, access_verifier);
+ return Create(context, config, desktop_env, access_verifier, logger);
}
// static
ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
- AccessVerifier* access_verifier) {
- return new ChromotingHost(context, config, environment, access_verifier);
+ AccessVerifier* access_verifier,
+ Logger* logger) {
+ return new ChromotingHost(context, config, environment, access_verifier,
+ logger);
}
ChromotingHost::ChromotingHost(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
- AccessVerifier* access_verifier)
+ AccessVerifier* access_verifier,
+ Logger* logger)
: context_(context),
config_(config),
desktop_environment_(environment),
access_verifier_(access_verifier),
+ logger_(logger),
state_(kInitial),
protocol_config_(protocol::CandidateSessionConfig::CreateDefault()),
is_curtained_(false),
@@ -75,6 +82,7 @@ void ChromotingHost::Start() {
return;
}
+ logger_->Log(logging::LOG_INFO, "Starting host");
DCHECK(!signal_strategy_.get());
DCHECK(access_verifier_.get());
@@ -92,7 +100,8 @@ void ChromotingHost::Start() {
if (!config_->GetString(kXmppLoginConfigPath, &xmpp_login) ||
!config_->GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token) ||
!config_->GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service)) {
- LOG(ERROR) << "XMPP credentials are not defined in the config.";
+ logger_->Log(logging::LOG_ERROR,
+ "XMPP credentials are not defined in the config.");
return;
}
@@ -155,7 +164,7 @@ void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) {
// protocol::ConnectionToClient::EventHandler implementations
void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) {
DCHECK_EQ(context_->network_message_loop(), MessageLoop::current());
- VLOG(1) << "Connection to client established.";
+ logger_->VLog(1, "Connection to client established.");
// TODO(wez): ChromotingHost shouldn't need to know about Me2Mom.
if (is_it2me_) {
context_->main_message_loop()->PostTask(
@@ -167,7 +176,7 @@ void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) {
void ChromotingHost::OnConnectionClosed(ConnectionToClient* connection) {
DCHECK_EQ(context_->network_message_loop(), MessageLoop::current());
- VLOG(1) << "Connection to client closed.";
+ logger_->VLog(1, "Connection to client closed.");
context_->main_message_loop()->PostTask(
FROM_HERE, base::Bind(&ChromotingHost::OnClientDisconnected, this,
make_scoped_refptr(connection)));
@@ -176,7 +185,7 @@ void ChromotingHost::OnConnectionClosed(ConnectionToClient* connection) {
void ChromotingHost::OnConnectionFailed(ConnectionToClient* connection) {
DCHECK_EQ(context_->network_message_loop(), MessageLoop::current());
- LOG(ERROR) << "Connection failed unexpectedly.";
+ logger_->Log(logging::LOG_ERROR, "Connection failed unexpectedly.");
context_->main_message_loop()->PostTask(
FROM_HERE, base::Bind(&ChromotingHost::OnClientDisconnected, this,
make_scoped_refptr(connection)));
@@ -203,7 +212,7 @@ void ChromotingHost::OnStateChange(
DCHECK_EQ(MessageLoop::current(), context_->network_message_loop());
if (state == SignalStrategy::StatusObserver::CONNECTED) {
- VLOG(1) << "Host connected as " << local_jid_;
+ logger_->Log(logging::LOG_INFO, "Host connected as %s", local_jid_.c_str());
// Create and start session manager.
protocol::JingleSessionManager* server =
@@ -227,7 +236,7 @@ void ChromotingHost::OnStateChange(
(*it)->OnSignallingConnected(signal_strategy_.get(), local_jid_);
}
} else if (state == SignalStrategy::StatusObserver::CLOSED) {
- VLOG(1) << "Host disconnected from talk network.";
+ logger_->Log(logging::LOG_INFO, "Host disconnected from talk network.");
for (StatusObserverList::iterator it = status_observers_.begin();
it != status_observers_.end(); ++it) {
(*it)->OnSignallingDisconnected();
@@ -282,8 +291,9 @@ void ChromotingHost::OnNewClientSession(
session->candidate_config(), true /* force_host_resolution */);
if (!config) {
- LOG(WARNING) << "Rejecting connection from " << session->jid()
- << " because no compatible configuration has been found.";
+ logger_->Log(logging::LOG_WARNING,
+ "Rejecting connection from %s because no compatible"
+ " configuration has been found.", session->jid().c_str());
*response = protocol::SessionManager::INCOMPATIBLE;
return;
}
@@ -294,7 +304,8 @@ void ChromotingHost::OnNewClientSession(
*response = protocol::SessionManager::ACCEPT;
- VLOG(1) << "Client connected: " << session->jid();
+ logger_->Log(logging::LOG_INFO, "Client connected: %s",
+ session->jid().c_str());
// We accept the connection, so create a connection object.
ConnectionToClient* connection = new ConnectionToClient(
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 709a2ac..0bbfe7f 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -36,6 +36,7 @@ class Capturer;
class ChromotingHostContext;
class DesktopEnvironment;
class Encoder;
+class Logger;
class MutableHostConfig;
class ScreenRecorder;
@@ -73,11 +74,13 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// and adds a reference to |config|. It does NOT take ownership of |context|.
static ChromotingHost* Create(ChromotingHostContext* context,
MutableHostConfig* config,
- AccessVerifier* access_verifier);
+ AccessVerifier* access_verifier,
+ Logger* logger);
static ChromotingHost* Create(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
- AccessVerifier* access_verifier);
+ AccessVerifier* access_verifier,
+ Logger* logger);
// Asynchronously start the host process.
//
@@ -118,6 +121,8 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
virtual void LocalLoginFailed(
scoped_refptr<protocol::ConnectionToClient> client);
+ Logger* logger() { return logger_; }
+
// Callback for ChromotingServer.
void OnNewClientSession(
protocol::Session* session,
@@ -152,7 +157,8 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
ChromotingHost(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
- AccessVerifier* access_verifier);
+ AccessVerifier* access_verifier,
+ Logger* logger);
virtual ~ChromotingHost();
enum State {
@@ -199,6 +205,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
scoped_ptr<AccessVerifier> access_verifier_;
+ // Logger (owned by the HostNPScriptObject).
+ Logger* logger_;
+
// The connections to remote clients.
ClientList clients_;
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index be6565a..9d238fa 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -5,6 +5,7 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
+#include "remoting/base/logger.h"
#include "remoting/host/capturer_fake.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
@@ -86,6 +87,8 @@ class ChromotingHostTest : public testing::Test {
EXPECT_CALL(context_, ui_message_loop())
.Times(AnyNumber());
+ logger_.reset(new Logger());
+
context_.SetUITaskPostFunction(base::Bind(
static_cast<void(MessageLoop::*)(
const tracked_objects::Location&, Task*)>(&MessageLoop::PostTask),
@@ -104,7 +107,7 @@ class ChromotingHostTest : public testing::Test {
MockAccessVerifier* access_verifier = new MockAccessVerifier();
host_ = ChromotingHost::Create(&context_, config_,
- desktop, access_verifier);
+ desktop, access_verifier, logger_.get());
credentials_.set_type(protocol::PASSWORD);
credentials_.set_username("user");
credentials_.set_credential("password");
@@ -205,6 +208,7 @@ class ChromotingHostTest : public testing::Test {
}
protected:
+ scoped_ptr<Logger> logger_;
MessageLoop message_loop_;
MockConnectionToClientEventHandler handler_;
scoped_refptr<ChromotingHost> host_;
@@ -229,7 +233,7 @@ class ChromotingHostTest : public testing::Test {
MockEventExecutor* event_executor_;
MockCurtain* curtain_;
MockDisconnectWindow* disconnect_window_;
- ContinueWindow* continue_window_;
+ MockContinueWindow* continue_window_;
MockLocalInputMonitor* local_input_monitor_;
};
diff --git a/remoting/host/plugin/host_plugin_logger.cc b/remoting/host/plugin/host_plugin_logger.cc
new file mode 100644
index 0000000..c2172f2
--- /dev/null
+++ b/remoting/host/plugin/host_plugin_logger.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#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()) {
+}
+
+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) {
+ if (message_loop_ != MessageLoop::current()) {
+ message_loop_->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &HostPluginLogger::LogToHostUI, message));
+ return;
+ }
+
+ scriptable_object_->LogDebugInfo(message);
+}
+
+} // namespace remoting
diff --git a/remoting/host/plugin/host_plugin_logger.h b/remoting/host/plugin/host_plugin_logger.h
new file mode 100644
index 0000000..7d216eb
--- /dev/null
+++ b/remoting/host/plugin/host_plugin_logger.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_PLUGIN_HOST_PLUGIN_LOGGER_H_
+#define REMOTING_HOST_PLUGIN_HOST_PLUGIN_LOGGER_H_
+
+#include "remoting/base/logger.h"
+
+#include "base/task.h"
+
+class MessageLoop;
+
+namespace remoting {
+
+class HostNPScriptObject;
+
+class HostPluginLogger : public Logger {
+ public:
+ 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);
+
+ 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_
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index fdeb568..226df03 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -71,7 +71,8 @@ HostNPScriptObject::HostNPScriptObject(NPP plugin, NPObject* parent)
np_thread_id_(base::PlatformThread::CurrentId()),
failed_login_attempts_(0),
disconnected_event_(true, false) {
- VLOG(2) << "HostNPScriptObject";
+ logger_.reset(new HostPluginLogger(this));
+ logger_->VLog(2, "HostNPScriptObject");
host_context_.SetUITaskPostFunction(base::Bind(
&HostNPScriptObject::PostTaskToNPThread, base::Unretained(this)));
}
@@ -98,14 +99,14 @@ HostNPScriptObject::~HostNPScriptObject() {
}
bool HostNPScriptObject::Init() {
- VLOG(2) << "Init";
+ logger_->VLog(2, "Init");
// TODO(wez): This starts a bunch of threads, which might fail.
host_context_.Start();
return true;
}
bool HostNPScriptObject::HasMethod(const std::string& method_name) {
- VLOG(2) << "HasMethod " << method_name;
+ logger_->VLog(2, "HasMethod %s", method_name.c_str());
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
return (method_name == kFuncNameConnect ||
method_name == kFuncNameDisconnect);
@@ -114,7 +115,7 @@ bool HostNPScriptObject::HasMethod(const std::string& method_name) {
bool HostNPScriptObject::InvokeDefault(const NPVariant* args,
uint32_t argCount,
NPVariant* result) {
- VLOG(2) << "InvokeDefault";
+ logger_->VLog(2, "InvokeDefault");
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
SetException("exception during default invocation");
return false;
@@ -124,7 +125,7 @@ bool HostNPScriptObject::Invoke(const std::string& method_name,
const NPVariant* args,
uint32_t argCount,
NPVariant* result) {
- VLOG(2) << "Invoke " << method_name;
+ logger_->VLog(2, "Invoke %s", method_name.c_str());
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
if (method_name == kFuncNameConnect) {
return Connect(args, argCount, result);
@@ -137,7 +138,7 @@ bool HostNPScriptObject::Invoke(const std::string& method_name,
}
bool HostNPScriptObject::HasProperty(const std::string& property_name) {
- VLOG(2) << "HasProperty " << property_name;
+ logger_->VLog(2, "HasProperty %s", property_name.c_str());
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
return (property_name == kAttrNameAccessCode ||
property_name == kAttrNameState ||
@@ -153,7 +154,7 @@ bool HostNPScriptObject::HasProperty(const std::string& property_name) {
bool HostNPScriptObject::GetProperty(const std::string& property_name,
NPVariant* result) {
- VLOG(2) << "GetProperty " << property_name;
+ logger_->VLog(2, "GetProperty %s", property_name.c_str());
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
if (!result) {
SetException("GetProperty: NULL result");
@@ -198,7 +199,7 @@ bool HostNPScriptObject::GetProperty(const std::string& property_name,
bool HostNPScriptObject::SetProperty(const std::string& property_name,
const NPVariant* value) {
- VLOG(2) << "SetProperty " << property_name;
+ logger_->VLog(2, "SetProperty %s", property_name.c_str());
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
if (property_name == kAttrNameOnStateChanged) {
@@ -239,13 +240,13 @@ bool HostNPScriptObject::SetProperty(const std::string& property_name,
}
bool HostNPScriptObject::RemoveProperty(const std::string& property_name) {
- VLOG(2) << "RemoveProperty " << property_name;
+ logger_->VLog(2, "RemoveProperty %s", property_name.c_str());
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
return false;
}
bool HostNPScriptObject::Enumerate(std::vector<std::string>* values) {
- VLOG(2) << "Enumerate";
+ logger_->VLog(2, "Enumerate");
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
const char* entries[] = {
kAttrNameAccessCode,
@@ -369,7 +370,7 @@ void HostNPScriptObject::ConnectInternal(
// Create the Host.
scoped_refptr<ChromotingHost> host =
ChromotingHost::Create(&host_context_, host_config,
- access_verifier.release());
+ access_verifier.release(), logger_.get());
host->AddStatusObserver(this);
host->AddStatusObserver(register_request.get());
host->set_it2me(true);
@@ -462,7 +463,7 @@ void HostNPScriptObject::OnStateChanged(State state) {
}
state_ = state;
if (on_state_changed_func_) {
- VLOG(2) << "Calling state changed " << state;
+ logger_->VLog(2, "Calling state changed %s", state);
bool is_good = InvokeAndIgnoreResult(on_state_changed_func_, NULL, 0);
LOG_IF(ERROR, !is_good) << "OnStateChanged failed";
}
@@ -477,7 +478,6 @@ void HostNPScriptObject::LogDebugInfo(const std::string& message) {
}
if (log_debug_info_func_) {
NPVariant* arg = new NPVariant();
- LOG(INFO) << "Logging: " << message;
STRINGZ_TO_NPVARIANT(message.c_str(), *arg);
bool is_good = InvokeAndIgnoreResult(log_debug_info_func_, arg, 1);
LOG_IF(ERROR, !is_good) << "LogDebugInfo failed";
diff --git a/remoting/host/plugin/host_script_object.h b/remoting/host/plugin/host_script_object.h
index 4ffeac3d..d623c32 100644
--- a/remoting/host/plugin/host_script_object.h
+++ b/remoting/host/plugin/host_script_object.h
@@ -16,6 +16,7 @@
#include "base/threading/platform_thread.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/host_status_observer.h"
+#include "remoting/host/plugin/host_plugin_logger.h"
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npfunctions.h"
#include "third_party/npapi/bindings/npruntime.h"
@@ -59,6 +60,9 @@ class HostNPScriptObject : public HostStatusObserver {
bool RemoveProperty(const std::string& property_name);
bool Enumerate(std::vector<std::string>* values);
+ // Call LogDebugInfo handler if there is one.
+ void LogDebugInfo(const std::string& message);
+
// remoting::HostStatusObserver implementation.
virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy,
const std::string& full_jid) OVERRIDE;
@@ -85,9 +89,6 @@ class HostNPScriptObject : public HostStatusObserver {
// Disconnect. No arguments or result.
bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result);
- // Call LogDebugInfo handler if there is one.
- void LogDebugInfo(const std::string& message);
-
// Call OnStateChanged handler if there is one.
void OnStateChanged(State state);
@@ -130,6 +131,8 @@ class HostNPScriptObject : public HostStatusObserver {
NPObject* on_state_changed_func_;
base::PlatformThreadId np_thread_id_;
+ scoped_ptr<HostPluginLogger> logger_;
+
scoped_ptr<RegisterSupportHostRequest> register_request_;
scoped_refptr<ChromotingHost> host_;
scoped_refptr<MutableHostConfig> host_config_;
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 9ecb523..e8c1f32 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -34,6 +34,7 @@
#include "crypto/nss_util.h"
#include "media/base/media.h"
#include "remoting/base/constants.h"
+#include "remoting/base/logger.h"
#include "remoting/base/tracer.h"
#include "remoting/host/capturer_fake.h"
#include "remoting/host/chromoting_host.h"
@@ -175,6 +176,7 @@ class SimpleHost {
// Construct a chromoting host.
scoped_refptr<ChromotingHost> host;
+ logger_.reset(new remoting::Logger());
if (fake_) {
remoting::Capturer* capturer =
new remoting::CapturerFake();
@@ -193,10 +195,10 @@ class SimpleHost {
new DesktopEnvironment(&context, capturer, event_executor, curtain,
disconnect_window, continue_window,
local_input_monitor),
- access_verifier.release());
+ access_verifier.release(), logger_.get());
} else {
host = ChromotingHost::Create(&context, config,
- access_verifier.release());
+ access_verifier.release(), logger_.get());
}
host->set_it2me(is_it2me_);
@@ -250,6 +252,8 @@ class SimpleHost {
return FilePath(home_path).Append(kDefaultConfigPath);
}
+ scoped_ptr<remoting::Logger> logger_;
+
FilePath config_path_;
bool fake_;
bool is_it2me_;
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 66d23fc..659d8f7 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -136,6 +136,8 @@
'host/plugin/host_plugin.cc',
'host/plugin/host_plugin.def',
'host/plugin/host_plugin.rc',
+ 'host/plugin/host_plugin_logger.cc',
+ 'host/plugin/host_plugin_logger.h',
'host/plugin/host_plugin_resource.h',
'host/plugin/host_plugin_utils.cc',
'host/plugin/host_plugin_utils.h',
@@ -279,6 +281,8 @@
'base/encoder_vp8.h',
'base/encoder_row_based.cc',
'base/encoder_row_based.h',
+ 'base/logger.cc',
+ 'base/logger.h',
'base/rate_counter.cc',
'base/rate_counter.h',
'base/running_average.cc',
@@ -426,8 +430,6 @@
'client/client_config.h',
'client/client_context.cc',
'client/client_context.h',
- 'client/client_logger.cc',
- 'client/client_logger.h',
'client/frame_consumer.h',
'client/input_handler.cc',
'client/input_handler.h',
diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js
index 83e8ec2..9a73dfb 100644
--- a/remoting/webapp/me2mom/remoting.js
+++ b/remoting/webapp/me2mom/remoting.js
@@ -269,7 +269,7 @@ function tryShare() {
plugin.setAttribute('id', remoting.HOST_PLUGIN_ID);
div.appendChild(plugin);
plugin.onStateChanged = onStateChanged_;
- plugin.logDebugInfoCallback = debugInfoCallback_;
+ plugin.logDebugInfo = debugInfoCallback_;
plugin.connect(getEmail(),
'oauth2:' + remoting.oauth2.getAccessToken());
}