Chromium Code Reviews| 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/log_to_server_host.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/message_loop/message_loop_proxy.h" | |
| 9 #include "remoting/base/constants.h" | |
| 10 #include "remoting/host/host_status_monitor.h" | |
| 11 #include "remoting/host/server_log_entry_host.h" | |
| 12 #include "remoting/jingle_glue/server_log_entry.h" | |
| 13 #include "remoting/protocol/transport.h" | |
| 14 | |
| 15 namespace remoting { | |
| 16 | |
| 17 LogToServerHost::LogToServerHost(base::WeakPtr<HostStatusMonitor> monitor, | |
| 18 ServerLogEntry::Mode mode, | |
| 19 SignalStrategy* signal_strategy, | |
| 20 const std::string& directory_bot_jid) | |
| 21 : LogToServer(mode, signal_strategy, directory_bot_jid), | |
| 22 monitor_(monitor) { | |
| 23 monitor_->AddStatusObserver(this); | |
| 24 } | |
| 25 | |
| 26 LogToServerHost::~LogToServerHost() { | |
| 27 if (monitor_.get()) | |
| 28 monitor_->RemoveStatusObserver(this); | |
| 29 } | |
| 30 | |
| 31 void LogToServerHost::LogSessionStateChange(const std::string& jid, | |
| 32 bool connected) { | |
|
Sergey Ulanov
2014/06/27 20:50:10
nit: indentation
Lambros
2014/07/01 22:56:17
Done.
| |
| 33 DCHECK(CalledOnValidThread()); | |
| 34 | |
| 35 scoped_ptr<ServerLogEntry> entry( | |
| 36 MakeLogEntryForSessionStateChange(connected)); | |
| 37 AddHostFieldsToLogEntry(entry.get()); | |
| 38 entry->AddModeField(mode()); | |
| 39 | |
| 40 if (connected) { | |
| 41 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.
| |
| 42 AddConnectionTypeToLogEntry(entry.get(), connection_route_type_[jid]); | |
| 43 } | |
| 44 Log(*entry.get()); | |
| 45 } | |
| 46 | |
| 47 void LogToServerHost::OnClientConnected(const std::string& jid) { | |
| 48 DCHECK(CalledOnValidThread()); | |
| 49 LogSessionStateChange(jid, true); | |
| 50 } | |
| 51 | |
| 52 void LogToServerHost::OnClientDisconnected(const std::string& jid) { | |
| 53 DCHECK(CalledOnValidThread()); | |
| 54 LogSessionStateChange(jid, false); | |
| 55 connection_route_type_.erase(jid); | |
| 56 } | |
| 57 | |
| 58 void LogToServerHost::OnClientRouteChange( | |
| 59 const std::string& jid, | |
| 60 const std::string& channel_name, | |
| 61 const protocol::TransportRoute& route) { | |
| 62 // Store connection type for the video channel. It is logged later | |
| 63 // when client authentication is finished. | |
| 64 if (channel_name == kVideoChannelName) { | |
| 65 connection_route_type_[jid] = route.type; | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 } // namespace remoting | |
| OLD | NEW |