OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "jingle/glue/fake_socket_factory.h" | 5 #include "jingle/glue/fake_socket_factory.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "jingle/glue/utils.h" | 9 #include "jingle/glue/utils.h" |
9 #include "third_party/libjingle/source/talk/base/asyncsocket.h" | 10 #include "third_party/libjingle/source/talk/base/asyncsocket.h" |
10 | 11 |
11 namespace jingle_glue { | 12 namespace jingle_glue { |
12 | 13 |
13 FakeUDPPacketSocket::FakeUDPPacketSocket(FakeSocketManager* fake_socket_manager, | 14 FakeUDPPacketSocket::FakeUDPPacketSocket(FakeSocketManager* fake_socket_manager, |
14 const net::IPEndPoint& address) | 15 const net::IPEndPoint& address) |
15 : fake_socket_manager_(fake_socket_manager), | 16 : fake_socket_manager_(fake_socket_manager), |
16 endpoint_(address), state_(IS_OPEN), error_(0) { | 17 endpoint_(address), state_(IS_OPEN), error_(0) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 119 } |
119 | 120 |
120 FakeSocketManager::~FakeSocketManager() { } | 121 FakeSocketManager::~FakeSocketManager() { } |
121 | 122 |
122 void FakeSocketManager::SendPacket(const net::IPEndPoint& from, | 123 void FakeSocketManager::SendPacket(const net::IPEndPoint& from, |
123 const net::IPEndPoint& to, | 124 const net::IPEndPoint& to, |
124 const std::vector<char>& data) { | 125 const std::vector<char>& data) { |
125 DCHECK_EQ(MessageLoop::current(), message_loop_); | 126 DCHECK_EQ(MessageLoop::current(), message_loop_); |
126 | 127 |
127 message_loop_->PostTask( | 128 message_loop_->PostTask( |
128 FROM_HERE, NewRunnableMethod(this, &FakeSocketManager::DeliverPacket, | 129 FROM_HERE, |
129 from, to, data)); | 130 base::Bind(&FakeSocketManager::DeliverPacket, this, from, to, data)); |
130 } | 131 } |
131 | 132 |
132 void FakeSocketManager::DeliverPacket(const net::IPEndPoint& from, | 133 void FakeSocketManager::DeliverPacket(const net::IPEndPoint& from, |
133 const net::IPEndPoint& to, | 134 const net::IPEndPoint& to, |
134 const std::vector<char>& data) { | 135 const std::vector<char>& data) { |
135 DCHECK_EQ(MessageLoop::current(), message_loop_); | 136 DCHECK_EQ(MessageLoop::current(), message_loop_); |
136 | 137 |
137 std::map<net::IPEndPoint, FakeUDPPacketSocket*>::iterator it = | 138 std::map<net::IPEndPoint, FakeUDPPacketSocket*>::iterator it = |
138 endpoints_.find(to); | 139 endpoints_.find(to); |
139 if (it == endpoints_.end()) { | 140 if (it == endpoints_.end()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const talk_base::SocketAddress& local_address, | 187 const talk_base::SocketAddress& local_address, |
187 const talk_base::SocketAddress& remote_address, | 188 const talk_base::SocketAddress& remote_address, |
188 const talk_base::ProxyInfo& proxy_info, const std::string& user_agent, | 189 const talk_base::ProxyInfo& proxy_info, const std::string& user_agent, |
189 bool ssl) { | 190 bool ssl) { |
190 // TODO(sergeyu): Implement fake TCP sockets. | 191 // TODO(sergeyu): Implement fake TCP sockets. |
191 NOTIMPLEMENTED(); | 192 NOTIMPLEMENTED(); |
192 return NULL; | 193 return NULL; |
193 } | 194 } |
194 | 195 |
195 } // namespace jingle_glue | 196 } // namespace jingle_glue |
OLD | NEW |