OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signaling/log_to_server.h" | 5 #include "remoting/signaling/log_to_server.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
10 #include "remoting/signaling/iq_sender.h" | 10 #include "remoting/signaling/iq_sender.h" |
11 #include "remoting/signaling/signal_strategy.h" | 11 #include "remoting/signaling/signal_strategy.h" |
12 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" | 12 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" |
13 #include "third_party/libjingle_xmpp/xmpp/constants.h" | 13 #include "third_party/libjingle_xmpp/xmpp/constants.h" |
14 | 14 |
15 using buzz::QName; | 15 using buzz::QName; |
16 using buzz::XmlElement; | 16 using buzz::XmlElement; |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 LogToServer::LogToServer(ServerLogEntry::Mode mode, | 20 LogToServer::LogToServer(ServerLogEntry::Mode mode, |
21 SignalStrategy* signal_strategy, | 21 SignalStrategy* signal_strategy, |
22 const std::string& directory_bot_jid) | 22 const std::string& directory_bot_jid) |
23 : mode_(mode), | 23 : mode_(mode), |
24 signal_strategy_(signal_strategy), | 24 signal_strategy_(signal_strategy), |
25 directory_bot_jid_(directory_bot_jid) { | 25 directory_bot_jid_(directory_bot_jid) { |
26 signal_strategy_->AddListener(this); | 26 signal_strategy_->AddListener(this); |
27 } | 27 } |
28 | 28 |
29 LogToServer::~LogToServer() { | 29 LogToServer::~LogToServer() { |
| 30 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
30 signal_strategy_->RemoveListener(this); | 31 signal_strategy_->RemoveListener(this); |
31 } | 32 } |
32 | 33 |
33 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { | 34 void LogToServer::OnSignalStrategyStateChange(SignalStrategy::State state) { |
34 DCHECK(CalledOnValidThread()); | 35 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
35 | 36 |
36 if (state == SignalStrategy::CONNECTED) { | 37 if (state == SignalStrategy::CONNECTED) { |
37 iq_sender_.reset(new IqSender(signal_strategy_)); | 38 iq_sender_.reset(new IqSender(signal_strategy_)); |
38 SendPendingEntries(); | 39 SendPendingEntries(); |
39 } else if (state == SignalStrategy::DISCONNECTED) { | 40 } else if (state == SignalStrategy::DISCONNECTED) { |
40 iq_sender_.reset(); | 41 iq_sender_.reset(); |
41 } | 42 } |
42 } | 43 } |
43 | 44 |
44 bool LogToServer::OnSignalStrategyIncomingStanza( | 45 bool LogToServer::OnSignalStrategyIncomingStanza( |
(...skipping 19 matching lines...) Expand all Loading... |
64 ServerLogEntry& entry = pending_entries_.front(); | 65 ServerLogEntry& entry = pending_entries_.front(); |
65 stanza->AddElement(entry.ToStanza().release()); | 66 stanza->AddElement(entry.ToStanza().release()); |
66 pending_entries_.pop_front(); | 67 pending_entries_.pop_front(); |
67 } | 68 } |
68 // Send the stanza to the server and ignore the response. | 69 // Send the stanza to the server and ignore the response. |
69 iq_sender_->SendIq(buzz::STR_SET, directory_bot_jid_, std::move(stanza), | 70 iq_sender_->SendIq(buzz::STR_SET, directory_bot_jid_, std::move(stanza), |
70 IqSender::ReplyCallback()); | 71 IqSender::ReplyCallback()); |
71 } | 72 } |
72 | 73 |
73 } // namespace remoting | 74 } // namespace remoting |
OLD | NEW |