Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: net/udp/udp_socket_win.cc

Issue 914853002: Add CHECK() in UdpSocketLibevent to debug crbug.com/452121 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/udp/udp_socket_win.h ('k') | remoting/protocol/chromium_socket_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return MapSystemError(WSAGetLastError()); 289 return MapSystemError(WSAGetLastError());
290 if (!use_non_blocking_io_) { 290 if (!use_non_blocking_io_) {
291 core_ = new Core(this); 291 core_ = new Core(this);
292 } else { 292 } else {
293 read_write_event_.Set(WSACreateEvent()); 293 read_write_event_.Set(WSACreateEvent());
294 WSAEventSelect(socket_, read_write_event_.Get(), FD_READ | FD_WRITE); 294 WSAEventSelect(socket_, read_write_event_.Get(), FD_READ | FD_WRITE);
295 } 295 }
296 return OK; 296 return OK;
297 } 297 }
298 298
299 void UDPSocketWin::Close() { 299 int UDPSocketWin::Close() {
300 DCHECK(CalledOnValidThread()); 300 DCHECK(CalledOnValidThread());
301 301
302 if (socket_ == INVALID_SOCKET) 302 if (socket_ == INVALID_SOCKET)
303 return; 303 return OK;
304 304
305 if (qos_handle_) { 305 if (qos_handle_) {
306 QwaveAPI::Get().CloseHandle(qos_handle_); 306 QwaveAPI::Get().CloseHandle(qos_handle_);
307 } 307 }
308 308
309 // Zero out any pending read/write callback state. 309 // Zero out any pending read/write callback state.
310 read_callback_.Reset(); 310 read_callback_.Reset();
311 recv_from_address_ = NULL; 311 recv_from_address_ = NULL;
312 write_callback_.Reset(); 312 write_callback_.Reset();
313 313
314 base::TimeTicks start_time = base::TimeTicks::Now(); 314 base::TimeTicks start_time = base::TimeTicks::Now();
315 closesocket(socket_); 315 int result = MapSystemError(closesocket(socket_));
316 UMA_HISTOGRAM_TIMES("Net.UDPSocketWinClose", 316 UMA_HISTOGRAM_TIMES("Net.UDPSocketWinClose",
317 base::TimeTicks::Now() - start_time); 317 base::TimeTicks::Now() - start_time);
318 socket_ = INVALID_SOCKET; 318 socket_ = INVALID_SOCKET;
319 addr_family_ = 0; 319 addr_family_ = 0;
320 is_connected_ = false; 320 is_connected_ = false;
321 321
322 read_write_watcher_.StopWatching(); 322 read_write_watcher_.StopWatching();
323 read_write_event_.Close(); 323 read_write_event_.Close();
324 324
325 if (core_) { 325 if (core_) {
326 core_->Detach(); 326 core_->Detach();
327 core_ = NULL; 327 core_ = NULL;
328 } 328 }
329
330 return result;
329 } 331 }
330 332
331 int UDPSocketWin::GetPeerAddress(IPEndPoint* address) const { 333 int UDPSocketWin::GetPeerAddress(IPEndPoint* address) const {
332 DCHECK(CalledOnValidThread()); 334 DCHECK(CalledOnValidThread());
333 DCHECK(address); 335 DCHECK(address);
334 if (!is_connected()) 336 if (!is_connected())
335 return ERR_SOCKET_NOT_CONNECTED; 337 return ERR_SOCKET_NOT_CONNECTED;
336 338
337 // TODO(szym): Simplify. http://crbug.com/126152 339 // TODO(szym): Simplify. http://crbug.com/126152
338 if (!remote_address_.get()) { 340 if (!remote_address_.get()) {
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 void UDPSocketWin::DetachFromThread() { 1175 void UDPSocketWin::DetachFromThread() {
1174 base::NonThreadSafe::DetachFromThread(); 1176 base::NonThreadSafe::DetachFromThread();
1175 } 1177 }
1176 1178
1177 void UDPSocketWin::UseNonBlockingIO() { 1179 void UDPSocketWin::UseNonBlockingIO() {
1178 DCHECK(!core_); 1180 DCHECK(!core_);
1179 use_non_blocking_io_ = true; 1181 use_non_blocking_io_ = true;
1180 } 1182 }
1181 1183
1182 } // namespace net 1184 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_win.h ('k') | remoting/protocol/chromium_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698