OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/host_event_logger.h" |
| 6 |
| 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/base/ip_endpoint.h" |
| 10 #include "remoting/host/chromoting_host.h" |
| 11 #include "remoting/host/host_status_observer.h" |
| 12 #include "remoting/host/system_event_logger.h" |
| 13 |
| 14 namespace remoting { |
| 15 |
| 16 namespace { |
| 17 |
| 18 class HostEventLoggerLinux : public HostEventLogger, public HostStatusObserver { |
| 19 public: |
| 20 HostEventLoggerLinux(ChromotingHost* host, |
| 21 const std::string& application_name); |
| 22 |
| 23 virtual ~HostEventLoggerLinux(); |
| 24 |
| 25 // HostStatusObserver implementation. These methods will be called from the |
| 26 // network thread. |
| 27 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
| 28 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; |
| 29 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; |
| 30 virtual void OnClientRouteChange( |
| 31 const std::string& jid, |
| 32 const std::string& channel_name, |
| 33 const net::IPEndPoint& remote_end_point, |
| 34 const net::IPEndPoint& local_end_point) OVERRIDE; |
| 35 virtual void OnShutdown() OVERRIDE; |
| 36 |
| 37 private: |
| 38 void Log(const std::string& message); |
| 39 |
| 40 scoped_refptr<ChromotingHost> host_; |
| 41 scoped_ptr<SystemEventLogger> system_event_logger_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(HostEventLoggerLinux); |
| 44 }; |
| 45 |
| 46 } //namespace |
| 47 |
| 48 HostEventLoggerLinux::HostEventLoggerLinux(ChromotingHost* host, |
| 49 const std::string& application_name) |
| 50 : host_(host), |
| 51 system_event_logger_(SystemEventLogger::Create(application_name)) { |
| 52 host_->AddStatusObserver(this); |
| 53 } |
| 54 |
| 55 HostEventLoggerLinux::~HostEventLoggerLinux() { |
| 56 host_->RemoveStatusObserver(this); |
| 57 } |
| 58 |
| 59 void HostEventLoggerLinux::OnClientAuthenticated(const std::string& jid) { |
| 60 Log("Client connected: " + jid); |
| 61 } |
| 62 |
| 63 void HostEventLoggerLinux::OnClientDisconnected(const std::string& jid) { |
| 64 Log("Client disconnected: " + jid); |
| 65 } |
| 66 |
| 67 void HostEventLoggerLinux::OnAccessDenied(const std::string& jid) { |
| 68 Log("Access denied for client: " + jid); |
| 69 } |
| 70 |
| 71 void HostEventLoggerLinux::OnClientRouteChange( |
| 72 const std::string& jid, |
| 73 const std::string& channel_name, |
| 74 const net::IPEndPoint& remote_end_point, |
| 75 const net::IPEndPoint& local_end_point) { |
| 76 Log("Channel IP for client: " + jid + |
| 77 " ip='" + remote_end_point.ToString() + |
| 78 "' host_ip='" + local_end_point.ToString() + |
| 79 "' channel='" + channel_name + "'"); |
| 80 } |
| 81 |
| 82 void HostEventLoggerLinux::OnShutdown() { |
| 83 } |
| 84 |
| 85 void HostEventLoggerLinux::Log(const std::string& message) { |
| 86 system_event_logger_->Log(message); |
| 87 } |
| 88 |
| 89 // static |
| 90 scoped_ptr<HostEventLogger> HostEventLogger::Create( |
| 91 ChromotingHost* host, const std::string& application_name) { |
| 92 return scoped_ptr<HostEventLogger>( |
| 93 new HostEventLoggerLinux(host, application_name)); |
| 94 } |
| 95 |
| 96 } // namespace remoting |
OLD | NEW |