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

Side by Side Diff: net/socket/tcp_socket_win.cc

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to mojo::edk namespace in preparation for runtim flag Created 5 years, 3 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
OLDNEW
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 #include "net/socket/tcp_socket.h" 5 #include "net/socket/tcp_socket.h"
6 #include "net/socket/tcp_socket_win.h" 6 #include "net/socket/tcp_socket_win.h"
7 7
8 #include <mstcpip.h> 8 #include <mstcpip.h>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 WSACloseEvent(read_overlapped_.hEvent); 228 WSACloseEvent(read_overlapped_.hEvent);
229 memset(&read_overlapped_, 0xaf, sizeof(read_overlapped_)); 229 memset(&read_overlapped_, 0xaf, sizeof(read_overlapped_));
230 WSACloseEvent(write_overlapped_.hEvent); 230 WSACloseEvent(write_overlapped_.hEvent);
231 memset(&write_overlapped_, 0xaf, sizeof(write_overlapped_)); 231 memset(&write_overlapped_, 0xaf, sizeof(write_overlapped_));
232 } 232 }
233 233
234 void TCPSocketWin::Core::WatchForRead() { 234 void TCPSocketWin::Core::WatchForRead() {
235 // We grab an extra reference because there is an IO operation in progress. 235 // We grab an extra reference because there is an IO operation in progress.
236 // Balanced in ReadDelegate::OnObjectSignaled(). 236 // Balanced in ReadDelegate::OnObjectSignaled().
237 AddRef(); 237 AddRef();
238 read_watcher_.StartWatching(read_overlapped_.hEvent, &reader_); 238 read_watcher_.StartWatching(read_overlapped_.hEvent, &reader_, false);
239 } 239 }
240 240
241 void TCPSocketWin::Core::WatchForWrite() { 241 void TCPSocketWin::Core::WatchForWrite() {
242 // We grab an extra reference because there is an IO operation in progress. 242 // We grab an extra reference because there is an IO operation in progress.
243 // Balanced in WriteDelegate::OnObjectSignaled(). 243 // Balanced in WriteDelegate::OnObjectSignaled().
244 AddRef(); 244 AddRef();
245 write_watcher_.StartWatching(write_overlapped_.hEvent, &writer_); 245 write_watcher_.StartWatching(write_overlapped_.hEvent, &writer_, false);
246 } 246 }
247 247
248 void TCPSocketWin::Core::ReadDelegate::OnObjectSignaled(HANDLE object) { 248 void TCPSocketWin::Core::ReadDelegate::OnObjectSignaled(HANDLE object) {
249 DCHECK_EQ(object, core_->read_overlapped_.hEvent); 249 DCHECK_EQ(object, core_->read_overlapped_.hEvent);
250 if (core_->socket_) { 250 if (core_->socket_) {
251 if (core_->socket_->waiting_connect_) 251 if (core_->socket_->waiting_connect_)
252 core_->socket_->DidCompleteConnect(); 252 core_->socket_->DidCompleteConnect();
253 else 253 else
254 core_->socket_->DidSignalRead(); 254 core_->socket_->DidSignalRead();
255 } 255 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 DCHECK(!callback.is_null()); 395 DCHECK(!callback.is_null());
396 DCHECK(accept_callback_.is_null()); 396 DCHECK(accept_callback_.is_null());
397 397
398 net_log_.BeginEvent(NetLog::TYPE_TCP_ACCEPT); 398 net_log_.BeginEvent(NetLog::TYPE_TCP_ACCEPT);
399 399
400 int result = AcceptInternal(socket, address); 400 int result = AcceptInternal(socket, address);
401 401
402 if (result == ERR_IO_PENDING) { 402 if (result == ERR_IO_PENDING) {
403 // Start watching. 403 // Start watching.
404 WSAEventSelect(socket_, accept_event_, FD_ACCEPT); 404 WSAEventSelect(socket_, accept_event_, FD_ACCEPT);
405 accept_watcher_.StartWatching(accept_event_, this); 405 accept_watcher_.StartWatching(accept_event_, this, false);
406 406
407 accept_socket_ = socket; 407 accept_socket_ = socket;
408 accept_address_ = address; 408 accept_address_ = address;
409 accept_callback_ = callback; 409 accept_callback_ = callback;
410 } 410 }
411 411
412 return result; 412 return result;
413 } 413 }
414 414
415 int TCPSocketWin::Connect(const IPEndPoint& address, 415 int TCPSocketWin::Connect(const IPEndPoint& address,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 accept_address_ = NULL; 765 accept_address_ = NULL;
766 base::ResetAndReturn(&accept_callback_).Run(result); 766 base::ResetAndReturn(&accept_callback_).Run(result);
767 } 767 }
768 } else { 768 } else {
769 // This happens when a client opens a connection and closes it before we 769 // This happens when a client opens a connection and closes it before we
770 // have a chance to accept it. 770 // have a chance to accept it.
771 DCHECK(ev.lNetworkEvents == 0); 771 DCHECK(ev.lNetworkEvents == 0);
772 772
773 // Start watching the next FD_ACCEPT event. 773 // Start watching the next FD_ACCEPT event.
774 WSAEventSelect(socket_, accept_event_, FD_ACCEPT); 774 WSAEventSelect(socket_, accept_event_, FD_ACCEPT);
775 accept_watcher_.StartWatching(accept_event_, this); 775 accept_watcher_.StartWatching(accept_event_, this, false);
776 } 776 }
777 } 777 }
778 778
779 int TCPSocketWin::DoConnect() { 779 int TCPSocketWin::DoConnect() {
780 DCHECK_EQ(connect_os_error_, 0); 780 DCHECK_EQ(connect_os_error_, 0);
781 DCHECK(!core_.get()); 781 DCHECK(!core_.get());
782 782
783 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, 783 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT,
784 CreateNetLogIPEndPointCallback(peer_address_.get())); 784 CreateNetLogIPEndPointCallback(peer_address_.get()));
785 785
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1044 }
1045 1045
1046 bool TCPSocketWin::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const { 1046 bool TCPSocketWin::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const {
1047 DCHECK(out_rtt); 1047 DCHECK(out_rtt);
1048 // TODO(bmcquade): Consider implementing using 1048 // TODO(bmcquade): Consider implementing using
1049 // GetPerTcpConnectionEStats/GetPerTcp6ConnectionEStats. 1049 // GetPerTcpConnectionEStats/GetPerTcp6ConnectionEStats.
1050 return false; 1050 return false;
1051 } 1051 }
1052 1052
1053 } // namespace net 1053 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698