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 "remoting/protocol/transport.h" |
16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
17 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 17 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
18 | 18 |
19 using buzz::QName; | 19 using buzz::QName; |
20 using buzz::XmlElement; | 20 using buzz::XmlElement; |
21 | 21 |
22 namespace remoting { | 22 namespace remoting { |
23 | 23 |
24 namespace { | |
25 const char kLogCommand[] = "log"; | |
26 } // namespace | |
27 | |
28 LogToServer::LogToServer(ChromotingHost* host, | 24 LogToServer::LogToServer(ChromotingHost* host, |
29 ServerLogEntry::Mode mode, | 25 ServerLogEntry::Mode mode, |
30 SignalStrategy* signal_strategy) | 26 SignalStrategy* signal_strategy) |
31 : host_(host), | 27 : host_(host), |
32 mode_(mode), | 28 mode_(mode), |
33 signal_strategy_(signal_strategy), | 29 signal_strategy_(signal_strategy), |
34 connection_type_set_(false) { | 30 connection_type_set_(false) { |
35 signal_strategy_->AddListener(this); | 31 signal_strategy_->AddListener(this); |
36 | 32 |
37 // |host| may be NULL in tests. | 33 // |host| may be NULL in tests. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 101 } |
106 | 102 |
107 void LogToServer::SendPendingEntries() { | 103 void LogToServer::SendPendingEntries() { |
108 if (iq_sender_ == NULL) { | 104 if (iq_sender_ == NULL) { |
109 return; | 105 return; |
110 } | 106 } |
111 if (pending_entries_.empty()) { | 107 if (pending_entries_.empty()) { |
112 return; | 108 return; |
113 } | 109 } |
114 // Make one stanza containing all the pending entries. | 110 // Make one stanza containing all the pending entries. |
115 scoped_ptr<XmlElement> stanza(new XmlElement(QName( | 111 scoped_ptr<XmlElement> stanza(ServerLogEntry::MakeStanza()); |
116 kChromotingXmlNamespace, kLogCommand))); | |
117 while (!pending_entries_.empty()) { | 112 while (!pending_entries_.empty()) { |
118 ServerLogEntry& entry = pending_entries_.front(); | 113 ServerLogEntry& entry = pending_entries_.front(); |
119 stanza->AddElement(entry.ToStanza().release()); | 114 stanza->AddElement(entry.ToStanza().release()); |
120 pending_entries_.pop_front(); | 115 pending_entries_.pop_front(); |
121 } | 116 } |
122 // Send the stanza to the server. | 117 // Send the stanza to the server. |
123 scoped_ptr<IqRequest> req = iq_sender_->SendIq( | 118 scoped_ptr<IqRequest> req = iq_sender_->SendIq( |
124 buzz::STR_SET, kChromotingBotJid, stanza.Pass(), | 119 buzz::STR_SET, kChromotingBotJid, stanza.Pass(), |
125 IqSender::ReplyCallback()); | 120 IqSender::ReplyCallback()); |
126 // We ignore any response, so let the IqRequest be destroyed. | 121 // We ignore any response, so let the IqRequest be destroyed. |
127 return; | 122 return; |
128 } | 123 } |
129 | 124 |
130 } // namespace remoting | 125 } // namespace remoting |
OLD | NEW |