| 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 #ifndef NET_UDP_UDP_SOCKET_WIN_H_ | 5 #ifndef NET_UDP_UDP_SOCKET_WIN_H_ |
| 6 #define NET_UDP_UDP_SOCKET_WIN_H_ | 6 #define NET_UDP_UDP_SOCKET_WIN_H_ |
| 7 | 7 |
| 8 #include <qos2.h> | 8 #include <qos2.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <winsock2.h> | 10 #include <winsock2.h> |
| 11 | 11 |
| 12 #include <memory> |
| 13 |
| 12 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 15 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/win/object_watcher.h" | 18 #include "base/win/object_watcher.h" |
| 18 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
| 19 #include "net/base/address_family.h" | 20 #include "net/base/address_family.h" |
| 20 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
| 21 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 22 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
| 23 #include "net/base/net_export.h" | 24 #include "net/base/net_export.h" |
| 24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| 25 #include "net/base/rand_callback.h" | 26 #include "net/base/rand_callback.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 267 |
| 267 // How to do source port binding, used only when UDPSocket is part of | 268 // How to do source port binding, used only when UDPSocket is part of |
| 268 // UDPClientSocket, since UDPServerSocket provides Bind. | 269 // UDPClientSocket, since UDPServerSocket provides Bind. |
| 269 DatagramSocket::BindType bind_type_; | 270 DatagramSocket::BindType bind_type_; |
| 270 | 271 |
| 271 // PRNG function for generating port numbers. | 272 // PRNG function for generating port numbers. |
| 272 RandIntCallback rand_int_cb_; | 273 RandIntCallback rand_int_cb_; |
| 273 | 274 |
| 274 // These are mutable since they're just cached copies to make | 275 // These are mutable since they're just cached copies to make |
| 275 // GetPeerAddress/GetLocalAddress smarter. | 276 // GetPeerAddress/GetLocalAddress smarter. |
| 276 mutable scoped_ptr<IPEndPoint> local_address_; | 277 mutable std::unique_ptr<IPEndPoint> local_address_; |
| 277 mutable scoped_ptr<IPEndPoint> remote_address_; | 278 mutable std::unique_ptr<IPEndPoint> remote_address_; |
| 278 | 279 |
| 279 // The core of the socket that can live longer than the socket itself. We pass | 280 // The core of the socket that can live longer than the socket itself. We pass |
| 280 // resources to the Windows async IO functions and we have to make sure that | 281 // resources to the Windows async IO functions and we have to make sure that |
| 281 // they are not destroyed while the OS still references them. | 282 // they are not destroyed while the OS still references them. |
| 282 scoped_refptr<Core> core_; | 283 scoped_refptr<Core> core_; |
| 283 | 284 |
| 284 // True if non-blocking IO is used. | 285 // True if non-blocking IO is used. |
| 285 bool use_non_blocking_io_; | 286 bool use_non_blocking_io_; |
| 286 | 287 |
| 287 // Watches |read_write_event_|. | 288 // Watches |read_write_event_|. |
| 288 base::win::ObjectWatcher read_write_watcher_; | 289 base::win::ObjectWatcher read_write_watcher_; |
| 289 | 290 |
| 290 // Events for read and write. | 291 // Events for read and write. |
| 291 base::win::ScopedHandle read_write_event_; | 292 base::win::ScopedHandle read_write_event_; |
| 292 | 293 |
| 293 // The buffers used in Read() and Write(). | 294 // The buffers used in Read() and Write(). |
| 294 scoped_refptr<IOBuffer> read_iobuffer_; | 295 scoped_refptr<IOBuffer> read_iobuffer_; |
| 295 scoped_refptr<IOBuffer> write_iobuffer_; | 296 scoped_refptr<IOBuffer> write_iobuffer_; |
| 296 | 297 |
| 297 int read_iobuffer_len_; | 298 int read_iobuffer_len_; |
| 298 int write_iobuffer_len_; | 299 int write_iobuffer_len_; |
| 299 | 300 |
| 300 IPEndPoint* recv_from_address_; | 301 IPEndPoint* recv_from_address_; |
| 301 | 302 |
| 302 // Cached copy of the current address we're sending to, if any. Used for | 303 // Cached copy of the current address we're sending to, if any. Used for |
| 303 // logging. | 304 // logging. |
| 304 scoped_ptr<IPEndPoint> send_to_address_; | 305 std::unique_ptr<IPEndPoint> send_to_address_; |
| 305 | 306 |
| 306 // External callback; called when read is complete. | 307 // External callback; called when read is complete. |
| 307 CompletionCallback read_callback_; | 308 CompletionCallback read_callback_; |
| 308 | 309 |
| 309 // External callback; called when write is complete. | 310 // External callback; called when write is complete. |
| 310 CompletionCallback write_callback_; | 311 CompletionCallback write_callback_; |
| 311 | 312 |
| 312 BoundNetLog net_log_; | 313 BoundNetLog net_log_; |
| 313 | 314 |
| 314 // QWAVE data. Used to set DSCP bits on outgoing packets. | 315 // QWAVE data. Used to set DSCP bits on outgoing packets. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 SetFlowFn set_flow_func_; | 372 SetFlowFn set_flow_func_; |
| 372 | 373 |
| 373 FRIEND_TEST_ALL_PREFIXES(UDPSocketTest, SetDSCPFake); | 374 FRIEND_TEST_ALL_PREFIXES(UDPSocketTest, SetDSCPFake); |
| 374 DISALLOW_COPY_AND_ASSIGN(QwaveAPI); | 375 DISALLOW_COPY_AND_ASSIGN(QwaveAPI); |
| 375 }; | 376 }; |
| 376 | 377 |
| 377 | 378 |
| 378 } // namespace net | 379 } // namespace net |
| 379 | 380 |
| 380 #endif // NET_UDP_UDP_SOCKET_WIN_H_ | 381 #endif // NET_UDP_UDP_SOCKET_WIN_H_ |
| OLD | NEW |