OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ |
6 #define CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ | 6 #define CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // thread which is specified in Init(). | 28 // thread which is specified in Init(). |
29 class P2PSocketClientImpl : public P2PSocketClient { | 29 class P2PSocketClientImpl : public P2PSocketClient { |
30 public: | 30 public: |
31 explicit P2PSocketClientImpl(P2PSocketDispatcher* dispatcher); | 31 explicit P2PSocketClientImpl(P2PSocketDispatcher* dispatcher); |
32 | 32 |
33 // Initialize socket of the specified |type| and connected to the | 33 // Initialize socket of the specified |type| and connected to the |
34 // specified |address|. |address| matters only when |type| is set to | 34 // specified |address|. |address| matters only when |type| is set to |
35 // P2P_SOCKET_TCP_CLIENT. | 35 // P2P_SOCKET_TCP_CLIENT. |
36 virtual void Init(P2PSocketType type, | 36 virtual void Init(P2PSocketType type, |
37 const net::IPEndPoint& local_address, | 37 const net::IPEndPoint& local_address, |
38 const net::IPEndPoint& remote_address, | 38 const P2PHostAndIPEndPoint& remote_address, |
39 P2PSocketClientDelegate* delegate); | 39 P2PSocketClientDelegate* delegate); |
40 | 40 |
41 // Send the |data| to the |address|. | 41 // Send the |data| to the |address|. |
42 virtual void Send(const net::IPEndPoint& address, | 42 virtual void Send(const net::IPEndPoint& address, |
43 const std::vector<char>& data) OVERRIDE; | 43 const std::vector<char>& data) OVERRIDE; |
44 | 44 |
45 // Send the |data| to the |address| using Differentiated Services Code Point | 45 // Send the |data| to the |address| using Differentiated Services Code Point |
46 // |dscp|. | 46 // |dscp|. |
47 virtual void SendWithDscp(const net::IPEndPoint& address, | 47 virtual void SendWithDscp(const net::IPEndPoint& address, |
48 const std::vector<char>& data, | 48 const std::vector<char>& data, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 scoped_refptr<P2PSocketClient> new_client); | 89 scoped_refptr<P2PSocketClient> new_client); |
90 void DeliverOnSendComplete(); | 90 void DeliverOnSendComplete(); |
91 void DeliverOnError(); | 91 void DeliverOnError(); |
92 void DeliverOnDataReceived(const net::IPEndPoint& address, | 92 void DeliverOnDataReceived(const net::IPEndPoint& address, |
93 const std::vector<char>& data, | 93 const std::vector<char>& data, |
94 const base::TimeTicks& timestamp); | 94 const base::TimeTicks& timestamp); |
95 | 95 |
96 // Scheduled on the IPC thread to finish initialization. | 96 // Scheduled on the IPC thread to finish initialization. |
97 void DoInit(P2PSocketType type, | 97 void DoInit(P2PSocketType type, |
98 const net::IPEndPoint& local_address, | 98 const net::IPEndPoint& local_address, |
99 const net::IPEndPoint& remote_address); | 99 const P2PHostAndIPEndPoint& remote_address); |
100 | 100 |
101 // Scheduled on the IPC thread to finish closing the connection. | 101 // Scheduled on the IPC thread to finish closing the connection. |
102 void DoClose(); | 102 void DoClose(); |
103 | 103 |
104 // Called by the dispatcher when it is destroyed. | 104 // Called by the dispatcher when it is destroyed. |
105 void Detach(); | 105 void Detach(); |
106 | 106 |
107 P2PSocketDispatcher* dispatcher_; | 107 P2PSocketDispatcher* dispatcher_; |
108 scoped_refptr<base::MessageLoopProxy> ipc_message_loop_; | 108 scoped_refptr<base::MessageLoopProxy> ipc_message_loop_; |
109 scoped_refptr<base::MessageLoopProxy> delegate_message_loop_; | 109 scoped_refptr<base::MessageLoopProxy> delegate_message_loop_; |
110 int socket_id_; | 110 int socket_id_; |
111 P2PSocketClientDelegate* delegate_; | 111 P2PSocketClientDelegate* delegate_; |
112 State state_; | 112 State state_; |
113 | 113 |
114 // These two fields are used to identify packets for tracing. | 114 // These two fields are used to identify packets for tracing. |
115 uint32 random_socket_id_; | 115 uint32 random_socket_id_; |
116 uint32 next_packet_id_; | 116 uint32 next_packet_id_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(P2PSocketClientImpl); | 118 DISALLOW_COPY_AND_ASSIGN(P2PSocketClientImpl); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace content | 121 } // namespace content |
122 | 122 |
123 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ | 123 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ |
OLD | NEW |