Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / host / ipc_host_event_logger.cc
blobf012d410a9d83bab4d986d4836ffd81dafa9a430
1 // Copyright (c) 2013 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.
5 #include "remoting/host/ipc_host_event_logger.h"
7 #include "base/logging.h"
8 #include "ipc/ipc_sender.h"
9 #include "net/base/ip_endpoint.h"
10 #include "remoting/host/chromoting_messages.h"
11 #include "remoting/host/host_status_monitor.h"
12 #include "remoting/protocol/transport.h"
14 namespace remoting {
16 IpcHostEventLogger::IpcHostEventLogger(base::WeakPtr<HostStatusMonitor> monitor,
17 IPC::Sender* daemon_channel)
18 : daemon_channel_(daemon_channel),
19 monitor_(monitor) {
20 monitor_->AddStatusObserver(this);
23 IpcHostEventLogger::~IpcHostEventLogger() {
24 DCHECK(CalledOnValidThread());
26 if (monitor_.get())
27 monitor_->RemoveStatusObserver(this);
30 void IpcHostEventLogger::OnAccessDenied(const std::string& jid) {
31 DCHECK(CalledOnValidThread());
33 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_AccessDenied(jid));
36 void IpcHostEventLogger::OnClientAuthenticated(const std::string& jid) {
37 DCHECK(CalledOnValidThread());
39 daemon_channel_->Send(
40 new ChromotingNetworkDaemonMsg_ClientAuthenticated(jid));
43 void IpcHostEventLogger::OnClientConnected(const std::string& jid) {
44 DCHECK(CalledOnValidThread());
46 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_ClientConnected(jid));
49 void IpcHostEventLogger::OnClientDisconnected(const std::string& jid) {
50 DCHECK(CalledOnValidThread());
52 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_ClientDisconnected(jid));
55 void IpcHostEventLogger::OnClientRouteChange(
56 const std::string& jid,
57 const std::string& channel_name,
58 const protocol::TransportRoute& route) {
59 DCHECK(CalledOnValidThread());
61 SerializedTransportRoute serialized_route;
62 serialized_route.type = route.type;
63 serialized_route.remote_address = route.remote_address.address();
64 serialized_route.remote_port = route.remote_address.port();
65 serialized_route.local_address = route.local_address.address();
66 serialized_route.local_port = route.local_address.port();
68 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_ClientRouteChange(
69 jid, channel_name, serialized_route));
72 void IpcHostEventLogger::OnShutdown() {
73 DCHECK(CalledOnValidThread());
75 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_HostShutdown());
78 void IpcHostEventLogger::OnStart(const std::string& xmpp_login) {
79 DCHECK(CalledOnValidThread());
81 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_HostStarted(xmpp_login));
84 } // namespace remoting