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/host_status_monitor.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/signal_strategy.h" | 13 #include "remoting/jingle_glue/signal_strategy.h" |
14 #include "remoting/protocol/transport.h" | 14 #include "remoting/protocol/transport.h" |
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
16 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 16 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
17 | 17 |
18 using buzz::QName; | 18 using buzz::QName; |
19 using buzz::XmlElement; | 19 using buzz::XmlElement; |
20 | 20 |
21 namespace remoting { | 21 namespace remoting { |
22 | 22 |
23 LogToServer::LogToServer(ChromotingHost* host, | 23 LogToServer::LogToServer(base::WeakPtr<HostStatusMonitor> monitor, |
24 ServerLogEntry::Mode mode, | 24 ServerLogEntry::Mode mode, |
25 SignalStrategy* signal_strategy, | 25 SignalStrategy* signal_strategy, |
26 const std::string& directory_bot_jid) | 26 const std::string& directory_bot_jid) |
27 : host_(host), | 27 : monitor_(monitor), |
28 mode_(mode), | 28 mode_(mode), |
29 signal_strategy_(signal_strategy), | 29 signal_strategy_(signal_strategy), |
30 directory_bot_jid_(directory_bot_jid) { | 30 directory_bot_jid_(directory_bot_jid) { |
| 31 monitor_->AddStatusObserver(this); |
31 signal_strategy_->AddListener(this); | 32 signal_strategy_->AddListener(this); |
32 | |
33 // |host| may be NULL in tests. | |
34 if (host_) | |
35 host_->AddStatusObserver(this); | |
36 } | 33 } |
37 | 34 |
38 LogToServer::~LogToServer() { | 35 LogToServer::~LogToServer() { |
39 signal_strategy_->RemoveListener(this); | 36 signal_strategy_->RemoveListener(this); |
40 if (host_) | 37 if (monitor_) |
41 host_->RemoveStatusObserver(this); | 38 monitor_->RemoveStatusObserver(this); |
42 } | 39 } |
43 | 40 |
44 void LogToServer::LogSessionStateChange(const std::string& jid, | 41 void LogToServer::LogSessionStateChange(const std::string& jid, |
45 bool connected) { | 42 bool connected) { |
46 DCHECK(CalledOnValidThread()); | 43 DCHECK(CalledOnValidThread()); |
47 | 44 |
48 scoped_ptr<ServerLogEntry> entry( | 45 scoped_ptr<ServerLogEntry> entry( |
49 ServerLogEntry::MakeForSessionStateChange(connected)); | 46 ServerLogEntry::MakeForSessionStateChange(connected)); |
50 entry->AddHostFields(); | 47 entry->AddHostFields(); |
51 entry->AddModeField(mode_); | 48 entry->AddModeField(mode_); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 112 } |
116 // Send the stanza to the server. | 113 // Send the stanza to the server. |
117 scoped_ptr<IqRequest> req = iq_sender_->SendIq( | 114 scoped_ptr<IqRequest> req = iq_sender_->SendIq( |
118 buzz::STR_SET, directory_bot_jid_, stanza.Pass(), | 115 buzz::STR_SET, directory_bot_jid_, stanza.Pass(), |
119 IqSender::ReplyCallback()); | 116 IqSender::ReplyCallback()); |
120 // We ignore any response, so let the IqRequest be destroyed. | 117 // We ignore any response, so let the IqRequest be destroyed. |
121 return; | 118 return; |
122 } | 119 } |
123 | 120 |
124 } // namespace remoting | 121 } // namespace remoting |
OLD | NEW |