diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 22:38:24 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 22:38:24 +0000 |
commit | 5fef89241fe5e0ddaa7bf7b6a5f7e48727fde553 (patch) | |
tree | 3bfa4a4c87fe53640707e2c195c203ad73d6a876 /remoting | |
parent | 8acc7759e858bb8bcc9110e566cdf76afa27c4de (diff) | |
download | chromium_src-5fef89241fe5e0ddaa7bf7b6a5f7e48727fde553.zip chromium_src-5fef89241fe5e0ddaa7bf7b6a5f7e48727fde553.tar.gz chromium_src-5fef89241fe5e0ddaa7bf7b6a5f7e48727fde553.tar.bz2 |
Event logging for Me2Me host.
BUG=109682
TEST=Manual
Review URL: http://codereview.chromium.org/9181015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/host_event_logger.cc | 50 | ||||
-rw-r--r-- | remoting/host/host_event_logger.h | 30 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 5 | ||||
-rw-r--r-- | remoting/remoting.gyp | 2 |
4 files changed, 87 insertions, 0 deletions
diff --git a/remoting/host/host_event_logger.cc b/remoting/host/host_event_logger.cc new file mode 100644 index 0000000..9284cff --- /dev/null +++ b/remoting/host/host_event_logger.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2012 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/host_event_logger.h" + +#if defined(OS_LINUX) +#include <syslog.h> +#endif + +namespace { + +void Log(const std::string& message) { + // TODO(lambroslambrou): Refactor this part into platform-specific classes. +#if defined(OS_LINUX) + syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str()); +#endif +} + +} // namespace + +namespace remoting { + +HostEventLogger::HostEventLogger() { +#if defined(OS_LINUX) + openlog("chromoting_host", 0, LOG_USER); +#endif +} + +HostEventLogger::~HostEventLogger() { +} + +void HostEventLogger::OnClientAuthenticated(const std::string& jid) { + std::string username = jid.substr(0, jid.find('/')); + Log("Client connected: " + username); +} + +void HostEventLogger::OnClientDisconnected(const std::string& jid) { + std::string username = jid.substr(0, jid.find('/')); + Log("Client disconnected: " + username); +} + +void HostEventLogger::OnAccessDenied() { + Log("Access denied"); +} + +void HostEventLogger::OnShutdown() { +} + +} // namespace remoting diff --git a/remoting/host/host_event_logger.h b/remoting/host/host_event_logger.h new file mode 100644 index 0000000..27d43ff --- /dev/null +++ b/remoting/host/host_event_logger.h @@ -0,0 +1,30 @@ +// Copyright (c) 2012 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_HOST_EVENT_LOGGER_H_ +#define REMOTING_HOST_HOST_EVENT_LOGGER_H_ + +#include <string> + +#include "base/compiler_specific.h" +#include "remoting/host/host_status_observer.h" + +namespace remoting { + +class HostEventLogger : public HostStatusObserver { + public: + HostEventLogger(); + virtual ~HostEventLogger(); + + // HostStatusObserver implementation. These methods will be called from the + // network thread. + virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; + virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; + virtual void OnAccessDenied() OVERRIDE; + virtual void OnShutdown() OVERRIDE; +}; + +} + +#endif // REMOTING_HOST_HOST_EVENT_LOGGER_H_ diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 33c5728..bd397a7 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -27,6 +27,7 @@ #include "remoting/host/event_executor.h" #include "remoting/host/heartbeat_sender.h" #include "remoting/host/host_config.h" +#include "remoting/host/host_event_logger.h" #include "remoting/host/json_host_config.h" #include "remoting/host/log_to_server.h" #include "remoting/host/signaling_connector.h" @@ -175,6 +176,9 @@ class HostProcess { log_to_server_.reset(new LogToServer(signal_strategy_.get())); host_->AddStatusObserver(log_to_server_.get()); + host_event_logger_.reset(new HostEventLogger()); + host_->AddStatusObserver(host_event_logger_.get()); + host_->Start(); // Create authenticator factory. @@ -207,6 +211,7 @@ class HostProcess { scoped_ptr<DesktopEnvironment> desktop_environment_; scoped_ptr<remoting::HeartbeatSender> heartbeat_sender_; scoped_ptr<LogToServer> log_to_server_; + scoped_ptr<HostEventLogger> host_event_logger_; scoped_refptr<ChromotingHost> host_; }; diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 6722407..7a94915 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -222,6 +222,8 @@ 'host/continue_window.h', 'host/continue_window_linux.cc', 'host/disconnect_window_linux.cc', + 'host/host_event_logger.cc', + 'host/host_event_logger.h', 'host/remoting_me2me_host.cc', ], }, # end of target 'remoting_me2me_host' |