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

Side by Side Diff: net/flip/flip_session.cc

Issue 208042: Fixup the flip buffer to use a regular IOBuffer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « net/flip/flip_session.h ('k') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/flip/flip_session.h" 5 #include "net/flip/flip_session.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 connect_callback_(this, &FlipSession::OnSocketConnect)), 89 connect_callback_(this, &FlipSession::OnSocketConnect)),
90 ALLOW_THIS_IN_INITIALIZER_LIST( 90 ALLOW_THIS_IN_INITIALIZER_LIST(
91 read_callback_(this, &FlipSession::OnReadComplete)), 91 read_callback_(this, &FlipSession::OnReadComplete)),
92 ALLOW_THIS_IN_INITIALIZER_LIST( 92 ALLOW_THIS_IN_INITIALIZER_LIST(
93 write_callback_(this, &FlipSession::OnWriteComplete)), 93 write_callback_(this, &FlipSession::OnWriteComplete)),
94 domain_(host), 94 domain_(host),
95 session_(session), 95 session_(session),
96 connection_started_(false), 96 connection_started_(false),
97 delayed_write_pending_(false), 97 delayed_write_pending_(false),
98 write_pending_(false), 98 write_pending_(false),
99 read_buffer_(new net::MovableIOBuffer(kReadBufferSize)), 99 read_buffer_(new IOBuffer(kReadBufferSize)),
100 read_buffer_bytes_read_(0),
101 read_pending_(false), 100 read_pending_(false),
102 stream_hi_water_mark_(0) { 101 stream_hi_water_mark_(0) {
103 // Always start at 1 for the first stream id. 102 // Always start at 1 for the first stream id.
104 // TODO(mbelshe): consider randomization. 103 // TODO(mbelshe): consider randomization.
105 stream_hi_water_mark_ = 1; 104 stream_hi_water_mark_ = 1;
106 105
107 flip_framer_.set_visitor(this); 106 flip_framer_.set_visitor(this);
108 } 107 }
109 108
110 FlipSession::~FlipSession() { 109 FlipSession::~FlipSession() {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // Write more data. We're already in a continuation, so we can 357 // Write more data. We're already in a continuation, so we can
359 // go ahead and write it immediately (without going back to the 358 // go ahead and write it immediately (without going back to the
360 // message loop). 359 // message loop).
361 WriteSocketLater(); 360 WriteSocketLater();
362 } 361 }
363 362
364 void FlipSession::ReadSocket() { 363 void FlipSession::ReadSocket() {
365 if (read_pending_) 364 if (read_pending_)
366 return; 365 return;
367 366
368 size_t max_bytes = kReadBufferSize; 367 int bytes_read = connection_.socket()->Read(read_buffer_.get(),
369 read_buffer_->set_data(read_buffer_bytes_read_); 368 kReadBufferSize,
370 max_bytes -= read_buffer_bytes_read_;
371 int bytes_read = connection_.socket()->Read(read_buffer_.get(), max_bytes,
372 &read_callback_); 369 &read_callback_);
373 switch (bytes_read) { 370 switch (bytes_read) {
374 case 0: 371 case 0:
375 // Socket is closed! 372 // Socket is closed!
376 // TODO(mbelshe): Need to abort any active streams here. 373 // TODO(mbelshe): Need to abort any active streams here.
377 DCHECK(!active_streams_.size()); 374 DCHECK(!active_streams_.size());
378 return; 375 return;
379 case net::ERR_IO_PENDING: 376 case net::ERR_IO_PENDING:
380 // Waiting for data. Nothing to do now. 377 // Waiting for data. Nothing to do now.
381 read_pending_ = true; 378 read_pending_ = true;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 return false; 750 return false;
754 } 751 }
755 752
756 void FlipStreamImpl::OnAbort() { 753 void FlipStreamImpl::OnAbort() {
757 if (delegate_) 754 if (delegate_)
758 delegate_->OnClose(net::ERR_ABORTED); 755 delegate_->OnClose(net::ERR_ABORTED);
759 } 756 }
760 757
761 } // namespace net 758 } // namespace net
762 759
OLDNEW
« no previous file with comments | « net/flip/flip_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698