summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/host/host_event_logger.cc54
-rw-r--r--remoting/host/host_event_logger.h31
-rw-r--r--remoting/host/host_event_logger_linux.cc96
-rw-r--r--remoting/host/host_event_logger_win.cc148
-rw-r--r--remoting/host/remoting_host_messages.mc53
-rw-r--r--remoting/host/remoting_me2me_host.cc44
-rw-r--r--remoting/remoting.gyp54
7 files changed, 394 insertions, 86 deletions
diff --git a/remoting/host/host_event_logger.cc b/remoting/host/host_event_logger.cc
deleted file mode 100644
index 9cd6258..0000000
--- a/remoting/host/host_event_logger.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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"
-
-#include "net/base/ip_endpoint.h"
-#include "remoting/host/chromoting_host.h"
-#include "remoting/host/system_event_logger.h"
-
-namespace remoting {
-
-HostEventLogger::HostEventLogger(ChromotingHost* host,
- const std::string& application_name)
- : host_(host),
- system_event_logger_(SystemEventLogger::Create(application_name)) {
- host_->AddStatusObserver(this);
-}
-
-HostEventLogger::~HostEventLogger() {
- host_->RemoveStatusObserver(this);
-}
-
-void HostEventLogger::OnClientAuthenticated(const std::string& jid) {
- Log("Client connected: " + jid);
-}
-
-void HostEventLogger::OnClientDisconnected(const std::string& jid) {
- Log("Client disconnected: " + jid);
-}
-
-void HostEventLogger::OnAccessDenied(const std::string& jid) {
- Log("Access denied for client: " + jid);
-}
-
-void HostEventLogger::OnClientRouteChange(
- const std::string& jid,
- const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) {
- Log("Channel IP for client: " + jid +
- " ip='" + remote_end_point.ToString() +
- "' host_ip='" + local_end_point.ToString() +
- "' channel='" + channel_name + "'");
-}
-
-void HostEventLogger::OnShutdown() {
-}
-
-void HostEventLogger::Log(const std::string& message) {
- system_event_logger_->Log(message);
-}
-
-} // namespace remoting
diff --git a/remoting/host/host_event_logger.h b/remoting/host/host_event_logger.h
index 3c92bd6..b039b3b 100644
--- a/remoting/host/host_event_logger.h
+++ b/remoting/host/host_event_logger.h
@@ -9,38 +9,25 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "remoting/host/host_status_observer.h"
namespace remoting {
class ChromotingHost;
-class SystemEventLogger;
-class HostEventLogger : public HostStatusObserver {
+class HostEventLogger {
public:
- HostEventLogger(ChromotingHost* host, const std::string& application_name);
- 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(const std::string& jid) OVERRIDE;
- virtual void OnClientRouteChange(
- const std::string& jid,
- const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) OVERRIDE;
- virtual void OnShutdown() OVERRIDE;
+ virtual ~HostEventLogger() {}
- private:
- void Log(const std::string& message);
+ // Creates an event-logger that monitors host status changes and logs
+ // corresponding events to the OS-specific log (syslog/EventLog).
+ static scoped_ptr<HostEventLogger> Create(
+ ChromotingHost* host, const std::string& application_name);
- scoped_refptr<ChromotingHost> host_;
- scoped_ptr<SystemEventLogger> system_event_logger_;
+ protected:
+ HostEventLogger() {}
+ private:
DISALLOW_COPY_AND_ASSIGN(HostEventLogger);
};
diff --git a/remoting/host/host_event_logger_linux.cc b/remoting/host/host_event_logger_linux.cc
new file mode 100644
index 0000000..caf1a60
--- /dev/null
+++ b/remoting/host/host_event_logger_linux.cc
@@ -0,0 +1,96 @@
+// 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"
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/base/ip_endpoint.h"
+#include "remoting/host/chromoting_host.h"
+#include "remoting/host/host_status_observer.h"
+#include "remoting/host/system_event_logger.h"
+
+namespace remoting {
+
+namespace {
+
+class HostEventLoggerLinux : public HostEventLogger, public HostStatusObserver {
+ public:
+ HostEventLoggerLinux(ChromotingHost* host,
+ const std::string& application_name);
+
+ virtual ~HostEventLoggerLinux();
+
+ // 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(const std::string& jid) OVERRIDE;
+ virtual void OnClientRouteChange(
+ const std::string& jid,
+ const std::string& channel_name,
+ const net::IPEndPoint& remote_end_point,
+ const net::IPEndPoint& local_end_point) OVERRIDE;
+ virtual void OnShutdown() OVERRIDE;
+
+ private:
+ void Log(const std::string& message);
+
+ scoped_refptr<ChromotingHost> host_;
+ scoped_ptr<SystemEventLogger> system_event_logger_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostEventLoggerLinux);
+};
+
+} //namespace
+
+HostEventLoggerLinux::HostEventLoggerLinux(ChromotingHost* host,
+ const std::string& application_name)
+ : host_(host),
+ system_event_logger_(SystemEventLogger::Create(application_name)) {
+ host_->AddStatusObserver(this);
+}
+
+HostEventLoggerLinux::~HostEventLoggerLinux() {
+ host_->RemoveStatusObserver(this);
+}
+
+void HostEventLoggerLinux::OnClientAuthenticated(const std::string& jid) {
+ Log("Client connected: " + jid);
+}
+
+void HostEventLoggerLinux::OnClientDisconnected(const std::string& jid) {
+ Log("Client disconnected: " + jid);
+}
+
+void HostEventLoggerLinux::OnAccessDenied(const std::string& jid) {
+ Log("Access denied for client: " + jid);
+}
+
+void HostEventLoggerLinux::OnClientRouteChange(
+ const std::string& jid,
+ const std::string& channel_name,
+ const net::IPEndPoint& remote_end_point,
+ const net::IPEndPoint& local_end_point) {
+ Log("Channel IP for client: " + jid +
+ " ip='" + remote_end_point.ToString() +
+ "' host_ip='" + local_end_point.ToString() +
+ "' channel='" + channel_name + "'");
+}
+
+void HostEventLoggerLinux::OnShutdown() {
+}
+
+void HostEventLoggerLinux::Log(const std::string& message) {
+ system_event_logger_->Log(message);
+}
+
+// static
+scoped_ptr<HostEventLogger> HostEventLogger::Create(
+ ChromotingHost* host, const std::string& application_name) {
+ return scoped_ptr<HostEventLogger>(
+ new HostEventLoggerLinux(host, application_name));
+}
+
+} // namespace remoting
diff --git a/remoting/host/host_event_logger_win.cc b/remoting/host/host_event_logger_win.cc
new file mode 100644
index 0000000..b0dd3c0
--- /dev/null
+++ b/remoting/host/host_event_logger_win.cc
@@ -0,0 +1,148 @@
+// 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"
+
+#include <windows.h>
+#include <string>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/string16.h"
+#include "base/utf_string_conversions.h"
+#include "net/base/ip_endpoint.h"
+#include "remoting/host/chromoting_host.h"
+#include "remoting/host/host_status_observer.h"
+
+#include "remoting_host_messages.h"
+
+namespace remoting {
+
+namespace {
+
+class HostEventLoggerWin : public HostEventLogger, public HostStatusObserver {
+ public:
+ HostEventLoggerWin(ChromotingHost* host,
+ const std::string& application_name);
+
+ virtual ~HostEventLoggerWin();
+
+ // 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(const std::string& jid) OVERRIDE;
+ virtual void OnClientRouteChange(
+ const std::string& jid,
+ const std::string& channel_name,
+ const net::IPEndPoint& remote_end_point,
+ const net::IPEndPoint& local_end_point) OVERRIDE;
+ virtual void OnShutdown() OVERRIDE;
+
+ private:
+ void LogString(WORD type, DWORD event_id, const std::string& string);
+ void Log(WORD type, DWORD event_id, const std::vector<string16>& strings);
+
+ scoped_refptr<ChromotingHost> host_;
+
+ // The handle of the application event log.
+ HANDLE event_log_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostEventLoggerWin);
+};
+
+} //namespace
+
+HostEventLoggerWin::HostEventLoggerWin(ChromotingHost* host,
+ const std::string& application_name)
+ : host_(host),
+ event_log_(NULL) {
+ event_log_ = RegisterEventSourceW(NULL,
+ ASCIIToUTF16(application_name).c_str());
+ if (event_log_ != NULL) {
+ host_->AddStatusObserver(this);
+ } else {
+ LOG_GETLASTERROR(ERROR) << "Failed to register the event source: "
+ << application_name;
+ }
+}
+
+HostEventLoggerWin::~HostEventLoggerWin() {
+ if (event_log_ != NULL) {
+ host_->RemoveStatusObserver(this);
+ DeregisterEventSource(event_log_);
+ }
+}
+
+void HostEventLoggerWin::OnClientAuthenticated(const std::string& jid) {
+ LogString(EVENTLOG_INFORMATION_TYPE, MSG_HOST_CLIENT_CONNECTED, jid);
+}
+
+void HostEventLoggerWin::OnClientDisconnected(const std::string& jid) {
+ LogString(EVENTLOG_INFORMATION_TYPE, MSG_HOST_CLIENT_DISCONNECTED, jid);
+}
+
+void HostEventLoggerWin::OnAccessDenied(const std::string& jid) {
+ LogString(EVENTLOG_ERROR_TYPE, MSG_HOST_CLIENT_ACCESS_DENIED, jid);
+}
+
+void HostEventLoggerWin::OnClientRouteChange(
+ const std::string& jid,
+ const std::string& channel_name,
+ const net::IPEndPoint& remote_end_point,
+ const net::IPEndPoint& local_end_point) {
+ std::vector<string16> strings(4);
+ strings[0] = ASCIIToUTF16(jid);
+ strings[1] = ASCIIToUTF16(remote_end_point.ToString());
+ strings[2] = ASCIIToUTF16(local_end_point.ToString());
+ strings[3] = ASCIIToUTF16(channel_name);
+ Log(EVENTLOG_INFORMATION_TYPE, MSG_HOST_CLIENT_ROUTING_CHANGED, strings);
+}
+
+void HostEventLoggerWin::OnShutdown() {
+}
+
+void HostEventLoggerWin::Log(WORD type,
+ DWORD event_id,
+ const std::vector<string16>& strings) {
+ if (event_log_ == NULL)
+ return;
+
+ // ReportEventW() takes an array of raw string pointers. They should stay
+ // valid for the duration of the call.
+ std::vector<const WCHAR*> raw_strings(strings.size());
+ for (size_t i = 0; i < strings.size(); ++i) {
+ raw_strings[i] = strings[i].c_str();
+ }
+
+ if (!ReportEventW(event_log_,
+ type,
+ HOST_CATEGORY,
+ event_id,
+ NULL,
+ static_cast<WORD>(raw_strings.size()),
+ 0,
+ &raw_strings[0],
+ NULL)) {
+ LOG_GETLASTERROR(ERROR) << "Failed to write an event to the event log";
+ }
+}
+
+void HostEventLoggerWin::LogString(WORD type,
+ DWORD event_id,
+ const std::string& string) {
+ std::vector<string16> strings;
+ strings.push_back(ASCIIToUTF16(string));
+ Log(type, event_id, strings);
+}
+
+// static
+scoped_ptr<HostEventLogger> HostEventLogger::Create(
+ ChromotingHost* host, const std::string& application_name) {
+ return scoped_ptr<HostEventLogger>(
+ new HostEventLoggerWin(host, application_name));
+}
+
+} // namespace remoting
diff --git a/remoting/host/remoting_host_messages.mc b/remoting/host/remoting_host_messages.mc
new file mode 100644
index 0000000..95d9b9e
--- /dev/null
+++ b/remoting/host/remoting_host_messages.mc
@@ -0,0 +1,53 @@
+SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
+ Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
+ Warning=0x2:STATUS_SEVERITY_WARNING
+ Error=0x3:STATUS_SEVERITY_ERROR)
+
+FacilityNames=(Host=0x0:FACILITY_HOST)
+
+LanguageNames=(English=0x409:MSG00409)
+
+; // The categories of events.
+MessageIdTypedef=WORD
+
+MessageId=0x1
+SymbolicName=HOST_CATEGORY
+Language=English
+Host
+.
+
+
+; // The message definitions.
+MessageIdTypedef=DWORD
+
+MessageId=1
+Severity=Informational
+Facility=Host
+SymbolicName=MSG_HOST_CLIENT_CONNECTED
+Language=English
+Client connected: %1.
+.
+
+MessageId=2
+Severity=Informational
+Facility=Host
+SymbolicName=MSG_HOST_CLIENT_DISCONNECTED
+Language=English
+Client disconnected: %1.
+.
+
+MessageId=3
+Severity=Error
+Facility=Host
+SymbolicName=MSG_HOST_CLIENT_ACCESS_DENIED
+Language=English
+Access denied for client: %1.
+.
+
+MessageId=4
+Severity=Informational
+Facility=Host
+SymbolicName=MSG_HOST_CLIENT_ROUTING_CHANGED
+Language=English
+Channel IP for client: %1 ip='%2' host_ip='%3' channel='%4'.
+.
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index ad34869..d0479c7 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -5,6 +5,10 @@
// This file implements a standalone host process for Me2Me, which is currently
// used for the Linux-only Virtual Me2Me build.
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
#include <string>
#include "base/at_exit.h"
@@ -15,6 +19,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/path_service.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "crypto/nss_util.h"
@@ -59,6 +64,18 @@ const FilePath::CharType kDefaultHostConfigFile[] =
const int kMinPortNumber = 12400;
const int kMaxPortNumber = 12409;
+FilePath GetDefaultConfigDir() {
+ FilePath default_config_dir;
+
+#if defined(OS_WIN)
+ PathService::Get(base::DIR_PROFILE, &default_config_dir);
+#else
+ default_config_dir = file_util::GetHomeDir();
+#endif
+
+ return default_config_dir.Append(kDefaultConfigDir);
+}
+
} // namespace
namespace remoting {
@@ -78,9 +95,7 @@ class HostProcess {
}
void InitWithCommandLine(const CommandLine* cmd_line) {
- FilePath default_config_dir =
- file_util::GetHomeDir().Append(kDefaultConfigDir);
-
+ FilePath default_config_dir = GetDefaultConfigDir();
if (cmd_line->HasSwitch(kAuthConfigSwitchName)) {
auth_config_path_ = cmd_line->GetSwitchValuePath(kAuthConfigSwitchName);
} else {
@@ -121,14 +136,14 @@ class HostProcess {
scoped_refptr<JsonHostConfig> auth_config =
new JsonHostConfig(auth_config_path_, io_message_loop);
- std::string failed_path;
+ FilePath failed_path;
if (!host_config->Read()) {
- failed_path = host_config_path_.value();
+ failed_path = host_config_path_;
} else if (!auth_config->Read()) {
- failed_path = auth_config_path_.value();
+ failed_path = auth_config_path_;
}
if (!failed_path.empty()) {
- LOG(ERROR) << "Failed to read configuration file " << failed_path;
+ LOG(ERROR) << "Failed to read configuration file " << failed_path.value();
return false;
}
@@ -223,7 +238,7 @@ class HostProcess {
log_to_server_.reset(
new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get()));
- host_event_logger_.reset(new HostEventLogger(host_, kApplicationName));
+ host_event_logger_ = HostEventLogger::Create(host_, kApplicationName);
host_->Start();
@@ -311,3 +326,16 @@ int main(int argc, char** argv) {
return me2me_host.Run();
}
+
+#if defined(OS_WIN)
+
+int CALLBACK WinMain(HINSTANCE instance,
+ HINSTANCE previous_instance,
+ LPSTR command_line,
+ int show_command) {
+ // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
+ // the command line from GetCommandLineW(), so we can safely pass NULL here.
+ return main(0, NULL);
+}
+
+#endif
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 1061dfb..57658dd 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -212,7 +212,7 @@
'../media/media.gyp:media',
],
'sources': [
- 'host/host_event_logger.cc',
+ 'host/host_event_logger_linux.cc',
'host/host_event_logger.h',
'host/remoting_me2me_host.cc',
'host/system_event_logger_linux.cc',
@@ -222,9 +222,58 @@
], # end of 'targets'
}], # 'OS=="linux"'
+
['OS=="win"', {
'targets': [
{
+ 'target_name': 'remoting_me2me_host',
+ 'type': 'executable',
+ 'dependencies': [
+ 'remoting_base',
+ 'remoting_host',
+ 'remoting_jingle_glue',
+ '../base/base.gyp:base',
+ '../base/base.gyp:base_i18n',
+ '../media/media.gyp:media',
+ ],
+ 'sources': [
+ 'host/host_event_logger_win.cc',
+ 'host/host_event_logger.h',
+ 'host/remoting_host_messages.mc',
+ 'host/remoting_me2me_host.cc',
+ 'host/system_event_logger.h',
+ ],
+ 'include_dirs': [
+ '<(INTERMEDIATE_DIR)',
+ ],
+ # Rule to run the message compiler.
+ 'rules': [
+ {
+ 'rule_name': 'message_compiler',
+ 'extension': 'mc',
+ 'inputs': [ ],
+ 'outputs': [
+ '<(INTERMEDIATE_DIR)/remoting_host_messages.h',
+ '<(INTERMEDIATE_DIR)/remoting_host_messages.rc',
+ ],
+ 'msvs_cygwin_shell': 0,
+ 'msvs_quote_cmd': 0,
+ 'action': [
+ 'mc.exe -h <(INTERMEDIATE_DIR) -r <(INTERMEDIATE_DIR) <(RULE_INPUT_PATH)',
+ ],
+ 'process_outputs_as_sources': 1,
+ 'message': 'Running message compiler on <(RULE_INPUT_PATH).',
+ },
+ ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ # 2 == /SUBSYSTEM:WINDOWS
+ 'SubSystem': '2',
+ },
+ },
+ }, # end of target 'remoting_me2me_host'
+
+ {
'target_name': 'remoting_service',
'type': 'executable',
'variables': { 'enable_wexit_time_destructors': 1, },
@@ -252,8 +301,9 @@
},
},
}, # end of target 'remoting_service'
- ],
+ ], # end of 'targets'
}], # 'OS=="win"'
+
], # end of 'conditions'
'targets': [