Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/log_to_server.h" | 5 #include "remoting/host/log_to_server.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/host/chromoting_host.h" | 10 #include "remoting/host/chromoting_host.h" |
| 11 #include "remoting/host/server_log_entry.h" | 11 #include "remoting/host/server_log_entry.h" |
| 12 #include "remoting/jingle_glue/iq_sender.h" | 12 #include "remoting/jingle_glue/iq_sender.h" |
| 13 #include "remoting/jingle_glue/jingle_thread.h" | 13 #include "remoting/jingle_glue/jingle_thread.h" |
| 14 #include "remoting/jingle_glue/signal_strategy.h" | 14 #include "remoting/jingle_glue/signal_strategy.h" |
| 15 #include "remoting/protocol/transport.h" | |
| 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 16 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 17 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
| 17 | 18 |
| 18 using buzz::QName; | 19 using buzz::QName; |
| 19 using buzz::XmlElement; | 20 using buzz::XmlElement; |
| 20 | 21 |
| 21 namespace remoting { | 22 namespace remoting { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 const char kLogCommand[] = "log"; | 25 const char kLogCommand[] = "log"; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 43 host_->RemoveStatusObserver(this); | 44 host_->RemoveStatusObserver(this); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void LogToServer::LogSessionStateChange(bool connected) { | 47 void LogToServer::LogSessionStateChange(bool connected) { |
| 47 DCHECK(CalledOnValidThread()); | 48 DCHECK(CalledOnValidThread()); |
| 48 | 49 |
| 49 scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeSessionStateChange( | 50 scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeSessionStateChange( |
| 50 connected)); | 51 connected)); |
| 51 entry->AddHostFields(); | 52 entry->AddHostFields(); |
| 52 entry->AddModeField(mode_); | 53 entry->AddModeField(mode_); |
| 54 | |
| 55 if (connected) | |
| 56 entry->AddConnectionTypeField(current_connection_type_); | |
| 53 Log(*entry.get()); | 57 Log(*entry.get()); |
| 54 } | 58 } |
| 55 | 59 |
| 56 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { | 60 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { |
| 57 DCHECK(CalledOnValidThread()); | 61 DCHECK(CalledOnValidThread()); |
| 58 | 62 |
| 59 if (state == SignalStrategy::CONNECTED) { | 63 if (state == SignalStrategy::CONNECTED) { |
| 60 iq_sender_.reset(new IqSender(signal_strategy_)); | 64 iq_sender_.reset(new IqSender(signal_strategy_)); |
| 61 SendPendingEntries(); | 65 SendPendingEntries(); |
| 62 } else if (state == SignalStrategy::DISCONNECTED) { | 66 } else if (state == SignalStrategy::DISCONNECTED) { |
| 63 iq_sender_.reset(); | 67 iq_sender_.reset(); |
| 64 } | 68 } |
| 65 } | 69 } |
| 66 | 70 |
| 67 void LogToServer::OnClientAuthenticated(const std::string& jid) { | 71 void LogToServer::OnClientAuthenticated(const std::string& jid) { |
| 68 DCHECK(CalledOnValidThread()); | 72 DCHECK(CalledOnValidThread()); |
| 69 LogSessionStateChange(true); | 73 LogSessionStateChange(true); |
| 70 } | 74 } |
| 71 | 75 |
| 72 void LogToServer::OnClientDisconnected(const std::string& jid) { | 76 void LogToServer::OnClientDisconnected(const std::string& jid) { |
| 73 DCHECK(CalledOnValidThread()); | 77 DCHECK(CalledOnValidThread()); |
| 74 LogSessionStateChange(false); | 78 LogSessionStateChange(false); |
|
simonmorris
2012/03/19 22:17:05
Maybe clear current_connection_type_ here, to prot
Sergey Ulanov
2012/03/19 23:21:03
Added a separate flag that indicates that the type
| |
| 75 } | 79 } |
| 76 | 80 |
| 77 void LogToServer::OnAccessDenied(const std::string& jid) { | 81 void LogToServer::OnAccessDenied(const std::string& jid) { |
| 78 } | 82 } |
| 79 | 83 |
| 84 void LogToServer::OnClientRouteChange(const std::string& jid, | |
| 85 const std::string& channel_name, | |
| 86 const protocol::TransportRoute& route) { | |
| 87 // Store connection type for the video channel. It is logged later | |
| 88 // when client authentication is finished. | |
| 89 if (channel_name == kVideoChannelName) { | |
| 90 current_connection_type_ = route.GetTypeString(); | |
| 91 } | |
| 92 } | |
| 93 | |
| 80 void LogToServer::OnShutdown() { | 94 void LogToServer::OnShutdown() { |
| 81 } | 95 } |
| 82 | 96 |
| 83 void LogToServer::Log(const ServerLogEntry& entry) { | 97 void LogToServer::Log(const ServerLogEntry& entry) { |
| 84 pending_entries_.push_back(entry); | 98 pending_entries_.push_back(entry); |
| 85 SendPendingEntries(); | 99 SendPendingEntries(); |
| 86 } | 100 } |
| 87 | 101 |
| 88 void LogToServer::SendPendingEntries() { | 102 void LogToServer::SendPendingEntries() { |
| 89 if (iq_sender_ == NULL) { | 103 if (iq_sender_ == NULL) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 102 } | 116 } |
| 103 // Send the stanza to the server. | 117 // Send the stanza to the server. |
| 104 scoped_ptr<IqRequest> req = iq_sender_->SendIq( | 118 scoped_ptr<IqRequest> req = iq_sender_->SendIq( |
| 105 buzz::STR_SET, kChromotingBotJid, stanza.Pass(), | 119 buzz::STR_SET, kChromotingBotJid, stanza.Pass(), |
| 106 IqSender::ReplyCallback()); | 120 IqSender::ReplyCallback()); |
| 107 // We ignore any response, so let the IqRequest be destroyed. | 121 // We ignore any response, so let the IqRequest be destroyed. |
| 108 return; | 122 return; |
| 109 } | 123 } |
| 110 | 124 |
| 111 } // namespace remoting | 125 } // namespace remoting |
| OLD | NEW |