Index: remoting/host/log_to_server_host.cc |
diff --git a/remoting/host/log_to_server_host.cc b/remoting/host/log_to_server_host.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..270b9f5201e971a0cdf07b74046d8998327ca1e0 |
--- /dev/null |
+++ b/remoting/host/log_to_server_host.cc |
@@ -0,0 +1,69 @@ |
+// 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/log_to_server_host.h" |
+ |
+#include "base/bind.h" |
+#include "base/message_loop/message_loop_proxy.h" |
+#include "remoting/base/constants.h" |
+#include "remoting/host/host_status_monitor.h" |
+#include "remoting/host/server_log_entry_host.h" |
+#include "remoting/jingle_glue/server_log_entry.h" |
+#include "remoting/protocol/transport.h" |
+ |
+namespace remoting { |
+ |
+LogToServerHost::LogToServerHost(base::WeakPtr<HostStatusMonitor> monitor, |
+ ServerLogEntry::Mode mode, |
+ SignalStrategy* signal_strategy, |
+ const std::string& directory_bot_jid) |
+ : LogToServer(mode, signal_strategy, directory_bot_jid), |
+ monitor_(monitor) { |
+ monitor_->AddStatusObserver(this); |
+} |
+ |
+LogToServerHost::~LogToServerHost() { |
+ if (monitor_.get()) |
+ monitor_->RemoveStatusObserver(this); |
+} |
+ |
+void LogToServerHost::LogSessionStateChange(const std::string& jid, |
+ bool connected) { |
Sergey Ulanov
2014/06/27 20:50:10
nit: indentation
Lambros
2014/07/01 22:56:17
Done.
|
+ DCHECK(CalledOnValidThread()); |
+ |
+ scoped_ptr<ServerLogEntry> entry( |
+ MakeLogEntryForSessionStateChange(connected)); |
+ AddHostFieldsToLogEntry(entry.get()); |
+ entry->AddModeField(mode()); |
+ |
+ if (connected) { |
+ DCHECK(connection_route_type_.count(jid) == 1); |
Sergey Ulanov
2014/06/27 20:50:10
DCHECK_EQ, or just remove '== 1'
Lambros
2014/07/01 22:56:17
Done.
|
+ AddConnectionTypeToLogEntry(entry.get(), connection_route_type_[jid]); |
+ } |
+ Log(*entry.get()); |
+} |
+ |
+void LogToServerHost::OnClientConnected(const std::string& jid) { |
+ DCHECK(CalledOnValidThread()); |
+ LogSessionStateChange(jid, true); |
+} |
+ |
+void LogToServerHost::OnClientDisconnected(const std::string& jid) { |
+ DCHECK(CalledOnValidThread()); |
+ LogSessionStateChange(jid, false); |
+ connection_route_type_.erase(jid); |
+} |
+ |
+void LogToServerHost::OnClientRouteChange( |
+ const std::string& jid, |
+ const std::string& channel_name, |
+ const protocol::TransportRoute& route) { |
+ // Store connection type for the video channel. It is logged later |
+ // when client authentication is finished. |
+ if (channel_name == kVideoChannelName) { |
+ connection_route_type_[jid] = route.type; |
+ } |
+} |
+ |
+} // namespace remoting |