| 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/fake_signal_strategy.h" | 5 #include "remoting/signaling/fake_signal_strategy.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "remoting/signaling/jid_util.h" |
| 16 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 17 #include "third_party/webrtc/libjingle/xmpp/constants.h" | 18 #include "third_party/webrtc/libjingle/xmpp/constants.h" |
| 18 | 19 |
| 19 namespace remoting { | 20 namespace remoting { |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 void FakeSignalStrategy::Connect(FakeSignalStrategy* peer1, | 23 void FakeSignalStrategy::Connect(FakeSignalStrategy* peer1, |
| 23 FakeSignalStrategy* peer2) { | 24 FakeSignalStrategy* peer2) { |
| 24 DCHECK(peer1->main_thread_->BelongsToCurrentThread()); | 25 DCHECK(peer1->main_thread_->BelongsToCurrentThread()); |
| 25 DCHECK(peer2->main_thread_->BelongsToCurrentThread()); | 26 DCHECK(peer2->main_thread_->BelongsToCurrentThread()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 158 } |
| 158 | 159 |
| 159 void FakeSignalStrategy::NotifyListeners( | 160 void FakeSignalStrategy::NotifyListeners( |
| 160 std::unique_ptr<buzz::XmlElement> stanza) { | 161 std::unique_ptr<buzz::XmlElement> stanza) { |
| 161 DCHECK(CalledOnValidThread()); | 162 DCHECK(CalledOnValidThread()); |
| 162 | 163 |
| 163 buzz::XmlElement* stanza_ptr = stanza.get(); | 164 buzz::XmlElement* stanza_ptr = stanza.get(); |
| 164 received_messages_.push_back(stanza.release()); | 165 received_messages_.push_back(stanza.release()); |
| 165 | 166 |
| 166 const std::string& to_field = stanza_ptr->Attr(buzz::QN_TO); | 167 const std::string& to_field = stanza_ptr->Attr(buzz::QN_TO); |
| 167 if (to_field != jid_) { | 168 if (NormalizeJid(to_field) != NormalizeJid(jid_)) { |
| 168 LOG(WARNING) << "Dropping stanza that is addressed to " << to_field | 169 LOG(WARNING) << "Dropping stanza that is addressed to " << to_field |
| 169 << ". Local jid: " << jid_ | 170 << ". Local jid: " << jid_ |
| 170 << ". Message content: " << stanza_ptr->Str(); | 171 << ". Message content: " << stanza_ptr->Str(); |
| 171 return; | 172 return; |
| 172 } | 173 } |
| 173 | 174 |
| 174 for (auto& listener : listeners_) { | 175 for (auto& listener : listeners_) { |
| 175 if (listener.OnSignalStrategyIncomingStanza(stanza_ptr)) | 176 if (listener.OnSignalStrategyIncomingStanza(stanza_ptr)) |
| 176 break; | 177 break; |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 | 180 |
| 180 void FakeSignalStrategy::SetPeerCallback(const PeerCallback& peer_callback) { | 181 void FakeSignalStrategy::SetPeerCallback(const PeerCallback& peer_callback) { |
| 181 peer_callback_ = peer_callback; | 182 peer_callback_ = peer_callback; |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace remoting | 185 } // namespace remoting |
| OLD | NEW |