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

Side by Side Diff: net/base/tcp_client_socket_win.cc

Issue 18788: Add a dummy function CrashBug6500 so that the return... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/tcp_client_socket.h" 5 #include "net/base/tcp_client_socket.h"
6 6
7 #include "base/memory_debug.h" 7 #include "base/memory_debug.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/trace_event.h" 9 #include "base/trace_event.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 int err = WSAGetLastError(); 192 int err = WSAGetLastError();
193 if (err == WSA_IO_PENDING) { 193 if (err == WSA_IO_PENDING) {
194 watcher_.StartWatching(overlapped_.hEvent, this); 194 watcher_.StartWatching(overlapped_.hEvent, this);
195 wait_state_ = WAITING_READ; 195 wait_state_ = WAITING_READ;
196 callback_ = callback; 196 callback_ = callback;
197 return ERR_IO_PENDING; 197 return ERR_IO_PENDING;
198 } 198 }
199 return MapWinsockError(err); 199 return MapWinsockError(err);
200 } 200 }
201 201
202 // TODO(wtc): This temporary function is intended to determine the return
203 // value and error code of the WaitForSingleObject call in
204 // TCPClientSocket::Write if it doesn't return the expected WAIT_OBJECT_0.
205 // See http://crbug.com/6500.
206 static void CrashBug6500(DWORD wait_rv, DWORD wait_error) {
207 // wait_error is meaningful only if wait_rv is WAIT_FAILED.
208 CHECK(false) << wait_rv << wait_error;
209 }
210
202 int TCPClientSocket::Write(const char* buf, 211 int TCPClientSocket::Write(const char* buf,
203 int buf_len, 212 int buf_len,
204 CompletionCallback* callback) { 213 CompletionCallback* callback) {
205 DCHECK(socket_ != INVALID_SOCKET); 214 DCHECK(socket_ != INVALID_SOCKET);
206 DCHECK(wait_state_ == NOT_WAITING); 215 DCHECK(wait_state_ == NOT_WAITING);
207 DCHECK(!callback_); 216 DCHECK(!callback_);
208 217
209 buffer_.len = buf_len; 218 buffer_.len = buf_len;
210 buffer_.buf = const_cast<char*>(buf); 219 buffer_.buf = const_cast<char*>(buf);
211 220
212 TRACE_EVENT_BEGIN("socket.write", this, ""); 221 TRACE_EVENT_BEGIN("socket.write", this, "");
213 // TODO(wtc): Remove the CHECKs after enough testing. 222 // TODO(wtc): Remove the CHECKs after enough testing.
214 CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT); 223 CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT);
215 DWORD num; 224 DWORD num;
216 int rv = WSASend(socket_, &buffer_, 1, &num, 0, &overlapped_, NULL); 225 int rv = WSASend(socket_, &buffer_, 1, &num, 0, &overlapped_, NULL);
217 if (rv == 0) { 226 if (rv == 0) {
218 // TODO(wtc): These temporary CHECKs are intended to determine the return
219 // value and error code of the WaitForSingleObject call if it doesn't
220 // return the expected WAIT_OBJECT_0. See http://crbug.com/6500.
221 DWORD wait_rv = WaitForSingleObject(overlapped_.hEvent, 0); 227 DWORD wait_rv = WaitForSingleObject(overlapped_.hEvent, 0);
222 if (wait_rv != WAIT_OBJECT_0) { 228 if (wait_rv != WAIT_OBJECT_0) {
223 if (wait_rv == WAIT_ABANDONED) { 229 DWORD wait_error = GetLastError();
224 CHECK(false); 230 CrashBug6500(wait_rv, wait_error);
225 } else if (wait_rv == WAIT_TIMEOUT) {
226 CHECK(false);
227 } else if (wait_rv == WAIT_FAILED) {
228 DWORD wait_error = GetLastError();
229 if (wait_error == ERROR_INVALID_HANDLE) {
230 CHECK(false);
231 } else {
232 CHECK(false);
233 }
234 } else {
235 CHECK(false);
236 }
237 } 231 }
238 BOOL ok = WSAResetEvent(overlapped_.hEvent); 232 BOOL ok = WSAResetEvent(overlapped_.hEvent);
239 CHECK(ok); 233 CHECK(ok);
240 TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num)); 234 TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num));
241 return static_cast<int>(num); 235 return static_cast<int>(num);
242 } 236 }
243 int err = WSAGetLastError(); 237 int err = WSAGetLastError();
244 if (err == WSA_IO_PENDING) { 238 if (err == WSA_IO_PENDING) {
245 watcher_.StartWatching(overlapped_.hEvent, this); 239 watcher_.StartWatching(overlapped_.hEvent, this);
246 wait_state_ = WAITING_WRITE; 240 wait_state_ = WAITING_WRITE;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 DidCompleteIO(); 374 DidCompleteIO();
381 break; 375 break;
382 default: 376 default:
383 NOTREACHED(); 377 NOTREACHED();
384 break; 378 break;
385 } 379 }
386 } 380 }
387 381
388 } // namespace net 382 } // namespace net
389 383
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698