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/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
10 #include "remoting/host/host_status_monitor.h" | 10 #include "remoting/host/host_status_monitor.h" |
11 #include "remoting/host/server_log_entry.h" | 11 #include "remoting/host/server_log_entry_host.h" |
12 #include "remoting/jingle_glue/iq_sender.h" | 12 #include "remoting/jingle_glue/iq_sender.h" |
13 #include "remoting/jingle_glue/signal_strategy.h" | 13 #include "remoting/jingle_glue/signal_strategy.h" |
| 14 #include "remoting/protocol/server_log_entry.h" |
14 #include "remoting/protocol/transport.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; |
| 21 using remoting::protocol::ServerLogEntry; |
20 | 22 |
21 namespace remoting { | 23 namespace remoting { |
22 | 24 |
23 LogToServer::LogToServer(base::WeakPtr<HostStatusMonitor> monitor, | 25 LogToServer::LogToServer(base::WeakPtr<HostStatusMonitor> monitor, |
24 ServerLogEntry::Mode mode, | 26 ServerLogEntry::Mode mode, |
25 SignalStrategy* signal_strategy, | 27 SignalStrategy* signal_strategy, |
26 const std::string& directory_bot_jid) | 28 const std::string& directory_bot_jid) |
27 : monitor_(monitor), | 29 : monitor_(monitor), |
28 mode_(mode), | 30 mode_(mode), |
29 signal_strategy_(signal_strategy), | 31 signal_strategy_(signal_strategy), |
30 directory_bot_jid_(directory_bot_jid) { | 32 directory_bot_jid_(directory_bot_jid) { |
31 monitor_->AddStatusObserver(this); | 33 monitor_->AddStatusObserver(this); |
32 signal_strategy_->AddListener(this); | 34 signal_strategy_->AddListener(this); |
33 } | 35 } |
34 | 36 |
35 LogToServer::~LogToServer() { | 37 LogToServer::~LogToServer() { |
36 signal_strategy_->RemoveListener(this); | 38 signal_strategy_->RemoveListener(this); |
37 if (monitor_.get()) | 39 if (monitor_.get()) |
38 monitor_->RemoveStatusObserver(this); | 40 monitor_->RemoveStatusObserver(this); |
39 } | 41 } |
40 | 42 |
41 void LogToServer::LogSessionStateChange(const std::string& jid, | 43 void LogToServer::LogSessionStateChange(const std::string& jid, |
42 bool connected) { | 44 bool connected) { |
43 DCHECK(CalledOnValidThread()); | 45 DCHECK(CalledOnValidThread()); |
44 | 46 |
45 scoped_ptr<ServerLogEntry> entry( | 47 scoped_ptr<ServerLogEntry> entry( |
46 ServerLogEntry::MakeForSessionStateChange(connected)); | 48 MakeLogEntryForSessionStateChange(connected)); |
47 entry->AddHostFields(); | 49 AddHostFieldsToLogEntry(entry.get()); |
48 entry->AddModeField(mode_); | 50 entry->AddModeField(mode_); |
49 | 51 |
50 if (connected) { | 52 if (connected) { |
51 DCHECK(connection_route_type_.count(jid) == 1); | 53 DCHECK(connection_route_type_.count(jid) == 1); |
52 entry->AddConnectionTypeField(connection_route_type_[jid]); | 54 AddConnectionTypeToLogEntry(entry.get(), connection_route_type_[jid]); |
53 } | 55 } |
54 Log(*entry.get()); | 56 Log(*entry.get()); |
55 } | 57 } |
56 | 58 |
57 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { | 59 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { |
58 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
59 | 61 |
60 if (state == SignalStrategy::CONNECTED) { | 62 if (state == SignalStrategy::CONNECTED) { |
61 iq_sender_.reset(new IqSender(signal_strategy_)); | 63 iq_sender_.reset(new IqSender(signal_strategy_)); |
62 SendPendingEntries(); | 64 SendPendingEntries(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 114 } |
113 // Send the stanza to the server. | 115 // Send the stanza to the server. |
114 scoped_ptr<IqRequest> req = iq_sender_->SendIq( | 116 scoped_ptr<IqRequest> req = iq_sender_->SendIq( |
115 buzz::STR_SET, directory_bot_jid_, stanza.Pass(), | 117 buzz::STR_SET, directory_bot_jid_, stanza.Pass(), |
116 IqSender::ReplyCallback()); | 118 IqSender::ReplyCallback()); |
117 // We ignore any response, so let the IqRequest be destroyed. | 119 // We ignore any response, so let the IqRequest be destroyed. |
118 return; | 120 return; |
119 } | 121 } |
120 | 122 |
121 } // namespace remoting | 123 } // namespace remoting |
OLD | NEW |