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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DCHECK(CalledOnValidThread()); | 90 DCHECK(CalledOnValidThread()); |
91 listeners_.RemoveObserver(listener); | 91 listeners_.RemoveObserver(listener); |
92 } | 92 } |
93 | 93 |
94 bool FakeSignalStrategy::SendStanza(scoped_ptr<buzz::XmlElement> stanza) { | 94 bool FakeSignalStrategy::SendStanza(scoped_ptr<buzz::XmlElement> stanza) { |
95 DCHECK(CalledOnValidThread()); | 95 DCHECK(CalledOnValidThread()); |
96 | 96 |
97 stanza->SetAttr(buzz::QN_FROM, jid_); | 97 stanza->SetAttr(buzz::QN_FROM, jid_); |
98 | 98 |
99 if (!peer_callback_.is_null()) { | 99 if (!peer_callback_.is_null()) { |
100 peer_callback_.Run(stanza.Pass()); | 100 if (send_delay_ != base::TimeDelta()) { |
| 101 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 102 FROM_HERE, base::Bind(peer_callback_, base::Passed(&stanza)), |
| 103 send_delay_); |
| 104 } else { |
| 105 peer_callback_.Run(stanza.Pass()); |
| 106 } |
101 return true; | 107 return true; |
102 } else { | 108 } else { |
103 return false; | 109 return false; |
104 } | 110 } |
105 } | 111 } |
106 | 112 |
107 std::string FakeSignalStrategy::GetNextId() { | 113 std::string FakeSignalStrategy::GetNextId() { |
108 ++last_id_; | 114 ++last_id_; |
109 return base::IntToString(last_id_); | 115 return base::IntToString(last_id_); |
110 } | 116 } |
(...skipping 29 matching lines...) Expand all Loading... |
140 if (listener->OnSignalStrategyIncomingStanza(stanza_ptr)) | 146 if (listener->OnSignalStrategyIncomingStanza(stanza_ptr)) |
141 break; | 147 break; |
142 } | 148 } |
143 } | 149 } |
144 | 150 |
145 void FakeSignalStrategy::SetPeerCallback(const PeerCallback& peer_callback) { | 151 void FakeSignalStrategy::SetPeerCallback(const PeerCallback& peer_callback) { |
146 peer_callback_ = peer_callback; | 152 peer_callback_ = peer_callback; |
147 } | 153 } |
148 | 154 |
149 } // namespace remoting | 155 } // namespace remoting |
OLD | NEW |