OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/p2p/ipc_socket_factory.h" | 5 #include "content/renderer/p2p/ipc_socket_factory.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 virtual ~IpcPacketSocket(); | 41 virtual ~IpcPacketSocket(); |
42 | 42 |
43 // Always takes ownership of client even if initialization fails. | 43 // Always takes ownership of client even if initialization fails. |
44 bool Init(P2PSocketType type, P2PSocketClient* client, | 44 bool Init(P2PSocketType type, P2PSocketClient* client, |
45 const talk_base::SocketAddress& local_address, | 45 const talk_base::SocketAddress& local_address, |
46 const talk_base::SocketAddress& remote_address); | 46 const talk_base::SocketAddress& remote_address); |
47 | 47 |
48 // talk_base::AsyncPacketSocket interface. | 48 // talk_base::AsyncPacketSocket interface. |
49 virtual talk_base::SocketAddress GetLocalAddress() const OVERRIDE; | 49 virtual talk_base::SocketAddress GetLocalAddress() const OVERRIDE; |
50 virtual talk_base::SocketAddress GetRemoteAddress() const OVERRIDE; | 50 virtual talk_base::SocketAddress GetRemoteAddress() const OVERRIDE; |
51 virtual int Send(const void *pv, size_t cb) OVERRIDE; | 51 virtual int Send(const void *pv, size_t cb, |
52 talk_base::DiffServCodePoint dscp) OVERRIDE; | |
52 virtual int SendTo(const void *pv, size_t cb, | 53 virtual int SendTo(const void *pv, size_t cb, |
53 const talk_base::SocketAddress& addr) OVERRIDE; | 54 const talk_base::SocketAddress& addr, |
55 talk_base::DiffServCodePoint dscp) OVERRIDE; | |
54 virtual int Close() OVERRIDE; | 56 virtual int Close() OVERRIDE; |
55 virtual State GetState() const OVERRIDE; | 57 virtual State GetState() const OVERRIDE; |
56 virtual int GetOption(talk_base::Socket::Option opt, int* value) OVERRIDE; | 58 virtual int GetOption(talk_base::Socket::Option opt, int* value) OVERRIDE; |
57 virtual int SetOption(talk_base::Socket::Option opt, int value) OVERRIDE; | 59 virtual int SetOption(talk_base::Socket::Option opt, int value) OVERRIDE; |
58 virtual int GetError() const OVERRIDE; | 60 virtual int GetError() const OVERRIDE; |
59 virtual void SetError(int error) OVERRIDE; | 61 virtual void SetError(int error) OVERRIDE; |
60 | 62 |
61 // P2PSocketClient::Delegate implementation. | 63 // P2PSocketClient::Delegate implementation. |
62 virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE; | 64 virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE; |
63 virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, | 65 virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 talk_base::SocketAddress IpcPacketSocket::GetLocalAddress() const { | 197 talk_base::SocketAddress IpcPacketSocket::GetLocalAddress() const { |
196 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 198 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
197 return local_address_; | 199 return local_address_; |
198 } | 200 } |
199 | 201 |
200 talk_base::SocketAddress IpcPacketSocket::GetRemoteAddress() const { | 202 talk_base::SocketAddress IpcPacketSocket::GetRemoteAddress() const { |
201 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 203 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
202 return remote_address_; | 204 return remote_address_; |
203 } | 205 } |
204 | 206 |
205 int IpcPacketSocket::Send(const void *data, size_t data_size) { | 207 int IpcPacketSocket::Send(const void *data, size_t data_size, |
208 talk_base::DiffServCodePoint dscp) { | |
206 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 209 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
207 return SendTo(data, data_size, remote_address_); | 210 return SendTo(data, data_size, remote_address_, dscp); |
208 } | 211 } |
209 | 212 |
210 int IpcPacketSocket::SendTo(const void *data, size_t data_size, | 213 int IpcPacketSocket::SendTo(const void *data, size_t data_size, |
211 const talk_base::SocketAddress& address) { | 214 const talk_base::SocketAddress& address, |
215 talk_base::DiffServCodePoint /*dscp*/) { | |
Sergey Ulanov
2013/09/23 22:32:36
Does the name need to be commented?
Mallinath (Gone from Chromium)
2013/09/23 22:38:14
Isn't the style where you will not use the variabl
Sergey Ulanov
2013/09/23 23:16:08
It may be necessary for compilers that warn about
| |
212 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 216 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
213 | 217 |
214 switch (state_) { | 218 switch (state_) { |
215 case IS_UNINITIALIZED: | 219 case IS_UNINITIALIZED: |
216 NOTREACHED(); | 220 NOTREACHED(); |
217 return EWOULDBLOCK; | 221 return EWOULDBLOCK; |
218 case IS_OPENING: | 222 case IS_OPENING: |
219 return EWOULDBLOCK; | 223 return EWOULDBLOCK; |
220 case IS_CLOSED: | 224 case IS_CLOSED: |
221 return ENOTCONN; | 225 return ENOTCONN; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 } | 448 } |
445 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); | 449 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); |
446 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 450 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
447 if (!socket->Init(type, socket_client, local_address, | 451 if (!socket->Init(type, socket_client, local_address, |
448 remote_address)) | 452 remote_address)) |
449 return NULL; | 453 return NULL; |
450 return socket.release(); | 454 return socket.release(); |
451 } | 455 } |
452 | 456 |
453 } // namespace content | 457 } // namespace content |
OLD | NEW |