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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/renderer/p2p/socket_client.h" | 10 #include "content/renderer/p2p/socket_client.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 IpcPacketSocket(); | 25 IpcPacketSocket(); |
26 virtual ~IpcPacketSocket(); | 26 virtual ~IpcPacketSocket(); |
27 | 27 |
28 // Always takes ownership of client even if initialization fails. | 28 // Always takes ownership of client even if initialization fails. |
29 bool Init(P2PSocketType type, P2PSocketClient* client, | 29 bool Init(P2PSocketType type, P2PSocketClient* client, |
30 const talk_base::SocketAddress& local_address, | 30 const talk_base::SocketAddress& local_address, |
31 const talk_base::SocketAddress& remote_address); | 31 const talk_base::SocketAddress& remote_address); |
32 | 32 |
33 // talk_base::AsyncPacketSocket interface. | 33 // talk_base::AsyncPacketSocket interface. |
34 virtual talk_base::SocketAddress GetLocalAddress() const; | 34 virtual talk_base::SocketAddress GetLocalAddress() const OVERRIDE; |
35 virtual talk_base::SocketAddress GetRemoteAddress() const; | 35 virtual talk_base::SocketAddress GetRemoteAddress() const OVERRIDE; |
36 virtual int Send(const void *pv, size_t cb); | 36 virtual int Send(const void *pv, size_t cb) OVERRIDE; |
37 virtual int SendTo(const void *pv, size_t cb, | 37 virtual int SendTo(const void *pv, size_t cb, |
38 const talk_base::SocketAddress& addr); | 38 const talk_base::SocketAddress& addr) OVERRIDE; |
39 virtual int Close(); | 39 virtual int Close() OVERRIDE; |
40 virtual State GetState() const; | 40 virtual State GetState() const OVERRIDE; |
41 virtual int GetOption(talk_base::Socket::Option opt, int* value); | 41 virtual int GetOption(talk_base::Socket::Option opt, int* value) OVERRIDE; |
42 virtual int SetOption(talk_base::Socket::Option opt, int value); | 42 virtual int SetOption(talk_base::Socket::Option opt, int value) OVERRIDE; |
43 virtual int GetError() const; | 43 virtual int GetError() const OVERRIDE; |
44 virtual void SetError(int error); | 44 virtual void SetError(int error) OVERRIDE; |
45 | 45 |
46 // P2PSocketClient::Delegate implementation. | 46 // P2PSocketClient::Delegate implementation. |
47 virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE; | 47 virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE; |
48 virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, | 48 virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, |
49 P2PSocketClient* client) OVERRIDE; | 49 P2PSocketClient* client) OVERRIDE; |
50 virtual void OnError(); | 50 virtual void OnError() OVERRIDE; |
51 virtual void OnDataReceived(const net::IPEndPoint& address, | 51 virtual void OnDataReceived(const net::IPEndPoint& address, |
52 const std::vector<char>& data) OVERRIDE; | 52 const std::vector<char>& data) OVERRIDE; |
53 | 53 |
54 private: | 54 private: |
55 enum InternalState { | 55 enum InternalState { |
56 IS_UNINITIALIZED, | 56 IS_UNINITIALIZED, |
57 IS_OPENING, | 57 IS_OPENING, |
58 IS_OPEN, | 58 IS_OPEN, |
59 IS_CLOSED, | 59 IS_CLOSED, |
60 IS_ERROR, | 60 IS_ERROR, |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 talk_base::SocketAddress crome_address; | 361 talk_base::SocketAddress crome_address; |
362 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); | 362 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); |
363 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 363 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
364 if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, | 364 if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, |
365 remote_address)) | 365 remote_address)) |
366 return NULL; | 366 return NULL; |
367 return socket.release(); | 367 return socket.release(); |
368 } | 368 } |
369 | 369 |
370 } // namespace content | 370 } // namespace content |
OLD | NEW |