OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET2_MANAGER_WINDOWS_H_ | 11 #ifndef WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET2_MANAGER_WINDOWS_H_ |
12 #define WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET2_MANAGER_WINDOWS_H_ | 12 #define WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET2_MANAGER_WINDOWS_H_ |
13 | 13 |
14 #include <winsock2.h> | 14 #include <winsock2.h> |
15 #include <list> | 15 #include <list> |
16 | 16 |
17 #include "webrtc/system_wrappers/include/atomic32.h" | 17 #include "webrtc/system_wrappers/include/atomic32.h" |
18 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 18 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
19 #include "webrtc/system_wrappers/include/event_wrapper.h" | 19 #include "webrtc/system_wrappers/include/event_wrapper.h" |
20 #include "webrtc/system_wrappers/include/thread_wrapper.h" | 20 #include "webrtc/base/platform_thread.h" |
21 #include "webrtc/test/channel_transport/udp_socket2_win.h" | 21 #include "webrtc/test/channel_transport/udp_socket2_win.h" |
22 #include "webrtc/test/channel_transport/udp_socket_manager_wrapper.h" | 22 #include "webrtc/test/channel_transport/udp_socket_manager_wrapper.h" |
23 #include "webrtc/test/channel_transport/udp_transport.h" | 23 #include "webrtc/test/channel_transport/udp_transport.h" |
24 | 24 |
25 #define MAX_IO_BUFF_SIZE 1600 | 25 #define MAX_IO_BUFF_SIZE 1600 |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
28 namespace test { | 28 namespace test { |
29 | 29 |
30 enum IO_OPERATION { | 30 enum IO_OPERATION { |
31 OP_READ, | 31 OP_READ, |
32 OP_WRITE | 32 OP_WRITE |
33 }; | 33 }; |
34 | 34 |
35 class UdpSocket2Windows; | 35 class UdpSocket2Windows; |
36 | 36 |
37 // Struct used for all socket I/O operations. | 37 // Struct used for all socket I/O operations. |
38 struct PerIoContext { | 38 struct PerIoContext { |
39 WSAOVERLAPPED overlapped; | 39 WSAOVERLAPPED overlapped; |
40 char buffer[MAX_IO_BUFF_SIZE]; | 40 char buffer[MAX_IO_BUFF_SIZE]; |
41 WSABUF wsabuf; | 41 WSABUF wsabuf; |
42 size_t nTotalBytes; | 42 size_t nTotalBytes; |
43 int nSentBytes; | 43 int nSentBytes; |
44 int bytes; | 44 int bytes; |
45 IO_OPERATION ioOperation; | 45 IO_OPERATION ioOperation; |
46 SocketAddress from; | 46 SocketAddress from; |
47 int fromLen; | 47 int fromLen; |
48 // Should be set to true if the I/O context was passed to the system by | 48 // Should be set to true if the I/O context was passed to the system by |
49 // a thread not controlled by the socket implementation. | 49 // a thread not controlled by the socket implementation. |
50 bool ioInitiatedByThreadWrapper; | 50 bool ioInitiatedByPlatformThread; |
51 // TODO (hellner): Not used. Delete it. | 51 // TODO (hellner): Not used. Delete it. |
52 PerIoContext* pNextFree; | 52 PerIoContext* pNextFree; |
53 }; | 53 }; |
54 | 54 |
55 struct IoContextPoolItem; | 55 struct IoContextPoolItem; |
56 struct IoContextPoolItemPayload | 56 struct IoContextPoolItemPayload |
57 { | 57 { |
58 PerIoContext ioContext; | 58 PerIoContext ioContext; |
59 IoContextPoolItem* base; | 59 IoContextPoolItem* base; |
60 }; | 60 }; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 virtual ~UdpSocket2WorkerWindows(); | 98 virtual ~UdpSocket2WorkerWindows(); |
99 | 99 |
100 virtual bool Start(); | 100 virtual bool Start(); |
101 virtual bool Stop(); | 101 virtual bool Stop(); |
102 virtual int32_t Init(); | 102 virtual int32_t Init(); |
103 protected: | 103 protected: |
104 static bool Run(void* obj); | 104 static bool Run(void* obj); |
105 bool Process(); | 105 bool Process(); |
106 private: | 106 private: |
107 HANDLE _ioCompletionHandle; | 107 HANDLE _ioCompletionHandle; |
108 rtc::scoped_ptr<ThreadWrapper> _pThread; | 108 rtc::scoped_ptr<PlatformThread> _pThread; |
109 static int32_t _numOfWorkers; | 109 static int32_t _numOfWorkers; |
110 int32_t _workerNumber; | 110 int32_t _workerNumber; |
111 volatile bool _stop; | 111 volatile bool _stop; |
112 bool _init; | 112 bool _init; |
113 }; | 113 }; |
114 | 114 |
115 class UdpSocket2ManagerWindows : public UdpSocketManager | 115 class UdpSocket2ManagerWindows : public UdpSocketManager |
116 { | 116 { |
117 public: | 117 public: |
118 UdpSocket2ManagerWindows(); | 118 UdpSocket2ManagerWindows(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 EventWrapper* _event; | 153 EventWrapper* _event; |
154 | 154 |
155 HANDLE _ioCompletionHandle; | 155 HANDLE _ioCompletionHandle; |
156 IoContextPool _ioContextPool; | 156 IoContextPool _ioContextPool; |
157 }; | 157 }; |
158 | 158 |
159 } // namespace test | 159 } // namespace test |
160 } // namespace webrtc | 160 } // namespace webrtc |
161 | 161 |
162 #endif // WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET2_MANAGER_WINDOWS_H_ | 162 #endif // WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET2_MANAGER_WINDOWS_H_ |
OLD | NEW |