| 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 "net/udp/udp_socket_win.h" | 5 #include "net/udp/udp_socket_win.h" |
| 6 | 6 |
| 7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/metrics/stats_counters.h" | 15 #include "base/metrics/stats_counters.h" |
| 16 #include "base/profiler/scoped_profile.h" | 16 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 18 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 19 #include "net/base/ip_endpoint.h" | 19 #include "net/base/ip_endpoint.h" |
| 20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 #include "net/base/winsock_init.h" | 23 #include "net/base/winsock_init.h" |
| 24 #include "net/base/winsock_util.h" | 24 #include "net/base/winsock_util.h" |
| 25 #include "net/socket/socket_descriptor.h" | 25 #include "net/socket/socket_descriptor.h" |
| 26 #include "net/udp/udp_net_log_parameters.h" | 26 #include "net/udp/udp_net_log_parameters.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 void UDPSocketWin::Core::WatchForWrite() { | 139 void UDPSocketWin::Core::WatchForWrite() { |
| 140 // We grab an extra reference because there is an IO operation in progress. | 140 // We grab an extra reference because there is an IO operation in progress. |
| 141 // Balanced in WriteDelegate::OnObjectSignaled(). | 141 // Balanced in WriteDelegate::OnObjectSignaled(). |
| 142 AddRef(); | 142 AddRef(); |
| 143 write_watcher_.StartWatching(write_overlapped_.hEvent, &writer_); | 143 write_watcher_.StartWatching(write_overlapped_.hEvent, &writer_); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void UDPSocketWin::Core::ReadDelegate::OnObjectSignaled(HANDLE object) { | 146 void UDPSocketWin::Core::ReadDelegate::OnObjectSignaled(HANDLE object) { |
| 147 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 147 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
| 148 tracked_objects::ScopedProfile tracking_profile( | 148 tracked_objects::ScopedTracker tracking_profile( |
| 149 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 149 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 150 "UDPSocketWin_Core_ReadDelegate_OnObjectSignaled")); | 150 "UDPSocketWin_Core_ReadDelegate_OnObjectSignaled")); |
| 151 | 151 |
| 152 DCHECK_EQ(object, core_->read_overlapped_.hEvent); | 152 DCHECK_EQ(object, core_->read_overlapped_.hEvent); |
| 153 if (core_->socket_) | 153 if (core_->socket_) |
| 154 core_->socket_->DidCompleteRead(); | 154 core_->socket_->DidCompleteRead(); |
| 155 | 155 |
| 156 core_->Release(); | 156 core_->Release(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void UDPSocketWin::Core::WriteDelegate::OnObjectSignaled(HANDLE object) { | 159 void UDPSocketWin::Core::WriteDelegate::OnObjectSignaled(HANDLE object) { |
| 160 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 160 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
| 161 tracked_objects::ScopedProfile tracking_profile( | 161 tracked_objects::ScopedTracker tracking_profile( |
| 162 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 162 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 163 "UDPSocketWin_Core_WriteDelegate_OnObjectSignaled")); | 163 "UDPSocketWin_Core_WriteDelegate_OnObjectSignaled")); |
| 164 | 164 |
| 165 DCHECK_EQ(object, core_->write_overlapped_.hEvent); | 165 DCHECK_EQ(object, core_->write_overlapped_.hEvent); |
| 166 if (core_->socket_) | 166 if (core_->socket_) |
| 167 core_->socket_->DidCompleteWrite(); | 167 core_->socket_->DidCompleteWrite(); |
| 168 | 168 |
| 169 core_->Release(); | 169 core_->Release(); |
| 170 } | 170 } |
| 171 //----------------------------------------------------------------------------- | 171 //----------------------------------------------------------------------------- |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 NULL); | 1016 NULL); |
| 1017 | 1017 |
| 1018 return OK; | 1018 return OK; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 void UDPSocketWin::DetachFromThread() { | 1021 void UDPSocketWin::DetachFromThread() { |
| 1022 base::NonThreadSafe::DetachFromThread(); | 1022 base::NonThreadSafe::DetachFromThread(); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 } // namespace net | 1025 } // namespace net |
| OLD | NEW |