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

Side by Side Diff: chrome/browser/sync/tools/chrome_async_socket.cc

Issue 2966011: Fixed some minor bugs with ChromeAsyncSocket. (Closed)
Patch Set: Created 10 years, 5 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 | « no previous file | chrome/browser/sync/tools/chrome_async_socket_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/sync/tools/chrome_async_socket.h" 5 #include "chrome/browser/sync/tools/chrome_async_socket.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <winsock2.h> 8 #include <winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <arpa/inet.h> 10 #include <arpa/inet.h>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 DoNetErrorFromStatus(status); 242 DoNetErrorFromStatus(status);
243 DoClose(); 243 DoClose();
244 } 244 }
245 } 245 }
246 246
247 // (maybe) read_state_ == IDLE -> read_state_ == POSTED (via 247 // (maybe) read_state_ == IDLE -> read_state_ == POSTED (via
248 // PostDoRead()) 248 // PostDoRead())
249 249
250 bool ChromeAsyncSocket::Read(char* data, size_t len, size_t* len_read) { 250 bool ChromeAsyncSocket::Read(char* data, size_t len, size_t* len_read) {
251 if (!IsOpen() && (state_ != STATE_TLS_CONNECTING)) { 251 if (!IsOpen() && (state_ != STATE_TLS_CONNECTING)) {
252 LOG(DFATAL) << "Read() called on non-open non-tls-connecting socket"; 252 // Read() may be called on a closed socket if a previous read
253 // causes a socket close (e.g., client sends wrong password and
254 // server terminates connection).
255 //
256 // TODO(akalin): Fix handling of this on the libjingle side.
257 if (state_ != STATE_CLOSED) {
258 LOG(DFATAL) << "Read() called on non-open non-tls-connecting socket";
259 }
253 DoNonNetError(ERROR_WRONGSTATE); 260 DoNonNetError(ERROR_WRONGSTATE);
254 return false; 261 return false;
255 } 262 }
256 DCHECK_LE(read_start_, read_end_); 263 DCHECK_LE(read_start_, read_end_);
257 if ((state_ == STATE_TLS_CONNECTING) || read_end_ == 0) { 264 if ((state_ == STATE_TLS_CONNECTING) || read_end_ == 0) {
258 if (state_ == STATE_TLS_CONNECTING) { 265 if (state_ == STATE_TLS_CONNECTING) {
259 DCHECK_EQ(read_state_, IDLE); 266 DCHECK_EQ(read_state_, IDLE);
260 DCHECK_EQ(read_end_, 0); 267 DCHECK_EQ(read_end_, 0);
261 } else { 268 } else {
262 DCHECK_NE(read_state_, IDLE); 269 DCHECK_NE(read_state_, IDLE);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 457
451 void ChromeAsyncSocket::ProcessSSLConnectDone(int status) { 458 void ChromeAsyncSocket::ProcessSSLConnectDone(int status) {
452 DCHECK_NE(status, net::ERR_IO_PENDING); 459 DCHECK_NE(status, net::ERR_IO_PENDING);
453 DCHECK_EQ(state_, STATE_TLS_CONNECTING); 460 DCHECK_EQ(state_, STATE_TLS_CONNECTING);
454 DCHECK_EQ(read_state_, IDLE); 461 DCHECK_EQ(read_state_, IDLE);
455 DCHECK_EQ(read_start_, 0); 462 DCHECK_EQ(read_start_, 0);
456 DCHECK_EQ(read_end_, 0); 463 DCHECK_EQ(read_end_, 0);
457 DCHECK_EQ(write_state_, IDLE); 464 DCHECK_EQ(write_state_, IDLE);
458 if (status != net::OK) { 465 if (status != net::OK) {
459 DoNetErrorFromStatus(status); 466 DoNetErrorFromStatus(status);
467 DoClose();
460 return; 468 return;
461 } 469 }
462 state_ = STATE_TLS_OPEN; 470 state_ = STATE_TLS_OPEN;
463 PostDoRead(); 471 PostDoRead();
464 if (write_end_ > 0) { 472 if (write_end_ > 0) {
465 PostDoWrite(); 473 PostDoWrite();
466 } 474 }
467 SignalSSLConnected(); 475 SignalSSLConnected();
468 } 476 }
469 477
470 } // namespace sync_tools 478 } // namespace sync_tools
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/tools/chrome_async_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698