| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // thread which is specified in Init(). | 32 // thread which is specified in Init(). |
| 33 class P2PSocketClientImpl : public P2PSocketClient { | 33 class P2PSocketClientImpl : public P2PSocketClient { |
| 34 public: | 34 public: |
| 35 explicit P2PSocketClientImpl(P2PSocketDispatcher* dispatcher); | 35 explicit P2PSocketClientImpl(P2PSocketDispatcher* dispatcher); |
| 36 | 36 |
| 37 // Initialize socket of the specified |type| and connected to the | 37 // Initialize socket of the specified |type| and connected to the |
| 38 // specified |address|. |address| matters only when |type| is set to | 38 // specified |address|. |address| matters only when |type| is set to |
| 39 // P2P_SOCKET_TCP_CLIENT. | 39 // P2P_SOCKET_TCP_CLIENT. |
| 40 virtual void Init(P2PSocketType type, | 40 virtual void Init(P2PSocketType type, |
| 41 const net::IPEndPoint& local_address, | 41 const net::IPEndPoint& local_address, |
| 42 uint16_t min_port, |
| 43 uint16_t max_port, |
| 42 const P2PHostAndIPEndPoint& remote_address, | 44 const P2PHostAndIPEndPoint& remote_address, |
| 43 P2PSocketClientDelegate* delegate); | 45 P2PSocketClientDelegate* delegate); |
| 44 | 46 |
| 45 // Send the |data| to the |address| using Differentiated Services Code Point | 47 // Send the |data| to the |address| using Differentiated Services Code Point |
| 46 // |dscp|. Return value is the unique packet_id for this packet. | 48 // |dscp|. Return value is the unique packet_id for this packet. |
| 47 uint64_t Send(const net::IPEndPoint& address, | 49 uint64_t Send(const net::IPEndPoint& address, |
| 48 const std::vector<char>& data, | 50 const std::vector<char>& data, |
| 49 const rtc::PacketOptions& options) override; | 51 const rtc::PacketOptions& options) override; |
| 50 | 52 |
| 51 // Setting socket options. | 53 // Setting socket options. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Helper function to be called by Send to handle different threading | 99 // Helper function to be called by Send to handle different threading |
| 98 // condition. | 100 // condition. |
| 99 void SendWithPacketId(const net::IPEndPoint& address, | 101 void SendWithPacketId(const net::IPEndPoint& address, |
| 100 const std::vector<char>& data, | 102 const std::vector<char>& data, |
| 101 const rtc::PacketOptions& options, | 103 const rtc::PacketOptions& options, |
| 102 uint64_t packet_id); | 104 uint64_t packet_id); |
| 103 | 105 |
| 104 // Scheduled on the IPC thread to finish initialization. | 106 // Scheduled on the IPC thread to finish initialization. |
| 105 void DoInit(P2PSocketType type, | 107 void DoInit(P2PSocketType type, |
| 106 const net::IPEndPoint& local_address, | 108 const net::IPEndPoint& local_address, |
| 109 uint16_t min_port, |
| 110 uint16_t max_port, |
| 107 const P2PHostAndIPEndPoint& remote_address); | 111 const P2PHostAndIPEndPoint& remote_address); |
| 108 | 112 |
| 109 // Scheduled on the IPC thread to finish closing the connection. | 113 // Scheduled on the IPC thread to finish closing the connection. |
| 110 void DoClose(); | 114 void DoClose(); |
| 111 | 115 |
| 112 // Called by the dispatcher when it is destroyed. | 116 // Called by the dispatcher when it is destroyed. |
| 113 void Detach(); | 117 void Detach(); |
| 114 | 118 |
| 115 P2PSocketDispatcher* dispatcher_; | 119 P2PSocketDispatcher* dispatcher_; |
| 116 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; | 120 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; |
| 117 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; | 121 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; |
| 118 int socket_id_; | 122 int socket_id_; |
| 119 P2PSocketClientDelegate* delegate_; | 123 P2PSocketClientDelegate* delegate_; |
| 120 State state_; | 124 State state_; |
| 121 | 125 |
| 122 // These two fields are used to identify packets for tracing. | 126 // These two fields are used to identify packets for tracing. |
| 123 uint32_t random_socket_id_; | 127 uint32_t random_socket_id_; |
| 124 uint32_t next_packet_id_; | 128 uint32_t next_packet_id_; |
| 125 | 129 |
| 126 DISALLOW_COPY_AND_ASSIGN(P2PSocketClientImpl); | 130 DISALLOW_COPY_AND_ASSIGN(P2PSocketClientImpl); |
| 127 }; | 131 }; |
| 128 | 132 |
| 129 } // namespace content | 133 } // namespace content |
| 130 | 134 |
| 131 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ | 135 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ |
| OLD | NEW |