OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/client/plugin/delegating_signal_strategy.h" | 5 #include "remoting/client/plugin/delegating_signal_strategy.h" |
6 | 6 |
| 7 #include "base/rand_util.h" |
7 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
8 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 9 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
9 | 10 |
10 namespace remoting { | 11 namespace remoting { |
11 | 12 |
12 DelegatingSignalStrategy::DelegatingSignalStrategy( | 13 DelegatingSignalStrategy::DelegatingSignalStrategy( |
13 std::string local_jid, | 14 std::string local_jid, |
14 const SendIqCallback& send_iq_callback) | 15 const SendIqCallback& send_iq_callback) |
15 : local_jid_(local_jid), | 16 : local_jid_(local_jid), |
16 send_iq_callback_(send_iq_callback), | 17 send_iq_callback_(send_iq_callback) { |
17 last_id_(0) { | |
18 } | 18 } |
19 | 19 |
20 DelegatingSignalStrategy::~DelegatingSignalStrategy() { | 20 DelegatingSignalStrategy::~DelegatingSignalStrategy() { |
21 } | 21 } |
22 | 22 |
23 void DelegatingSignalStrategy::OnIncomingMessage(const std::string& message) { | 23 void DelegatingSignalStrategy::OnIncomingMessage(const std::string& message) { |
24 scoped_ptr<buzz::XmlElement> stanza(buzz::XmlElement::ForStr(message)); | 24 scoped_ptr<buzz::XmlElement> stanza(buzz::XmlElement::ForStr(message)); |
25 if (!stanza.get()) { | 25 if (!stanza.get()) { |
26 LOG(WARNING) << "Malformed XMPP stanza received: " << message; | 26 LOG(WARNING) << "Malformed XMPP stanza received: " << message; |
27 return; | 27 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 void DelegatingSignalStrategy::RemoveListener(Listener* listener) { | 60 void DelegatingSignalStrategy::RemoveListener(Listener* listener) { |
61 listeners_.RemoveObserver(listener); | 61 listeners_.RemoveObserver(listener); |
62 } | 62 } |
63 | 63 |
64 bool DelegatingSignalStrategy::SendStanza(scoped_ptr<buzz::XmlElement> stanza) { | 64 bool DelegatingSignalStrategy::SendStanza(scoped_ptr<buzz::XmlElement> stanza) { |
65 send_iq_callback_.Run(stanza->Str()); | 65 send_iq_callback_.Run(stanza->Str()); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 std::string DelegatingSignalStrategy::GetNextId() { | 69 std::string DelegatingSignalStrategy::GetNextId() { |
70 ++last_id_; | 70 return base::Uint64ToString(base::RandUint64()); |
71 return base::IntToString(last_id_); | |
72 } | 71 } |
73 | 72 |
74 } // namespace remoting | 73 } // namespace remoting |
OLD | NEW |