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

Side by Side Diff: net/quic/quic_http_stream.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/quic/quic_headers_stream_test.cc ('k') | net/quic/quic_http_stream_test.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/quic/quic_http_stream.h" 5 #include "net/quic/quic_http_stream.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace net { 24 namespace net {
25 25
26 static const size_t kHeaderBufInitialSize = 4096; 26 static const size_t kHeaderBufInitialSize = 4096;
27 27
28 QuicHttpStream::QuicHttpStream(const base::WeakPtr<QuicClientSession>& session) 28 QuicHttpStream::QuicHttpStream(const base::WeakPtr<QuicClientSession>& session)
29 : next_state_(STATE_NONE), 29 : next_state_(STATE_NONE),
30 session_(session), 30 session_(session),
31 session_error_(OK), 31 session_error_(OK),
32 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), 32 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()),
33 stream_(NULL), 33 stream_(nullptr),
34 request_info_(NULL), 34 request_info_(nullptr),
35 request_body_stream_(NULL), 35 request_body_stream_(nullptr),
36 priority_(MINIMUM_PRIORITY), 36 priority_(MINIMUM_PRIORITY),
37 response_info_(NULL), 37 response_info_(nullptr),
38 response_status_(OK), 38 response_status_(OK),
39 response_headers_received_(false), 39 response_headers_received_(false),
40 read_buf_(new GrowableIOBuffer()), 40 read_buf_(new GrowableIOBuffer()),
41 closed_stream_received_bytes_(0), 41 closed_stream_received_bytes_(0),
42 user_buffer_len_(0), 42 user_buffer_len_(0),
43 weak_factory_(this) { 43 weak_factory_(this) {
44 DCHECK(session_); 44 DCHECK(session_);
45 session_->AddObserver(this); 45 session_->AddObserver(this);
46 } 46 }
47 47
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (!request_body_stream_) 148 if (!request_body_stream_)
149 return UploadProgress(); 149 return UploadProgress();
150 150
151 return UploadProgress(request_body_stream_->position(), 151 return UploadProgress(request_body_stream_->position(),
152 request_body_stream_->size()); 152 request_body_stream_->size());
153 } 153 }
154 154
155 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) { 155 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) {
156 CHECK(!callback.is_null()); 156 CHECK(!callback.is_null());
157 157
158 if (stream_ == NULL) 158 if (stream_ == nullptr)
159 return response_status_; 159 return response_status_;
160 160
161 // Check if we already have the response headers. If so, return synchronously. 161 // Check if we already have the response headers. If so, return synchronously.
162 if (response_headers_received_) 162 if (response_headers_received_)
163 return OK; 163 return OK;
164 164
165 // Still waiting for the response, return IO_PENDING. 165 // Still waiting for the response, return IO_PENDING.
166 CHECK(callback_.is_null()); 166 CHECK(callback_.is_null());
167 callback_ = callback; 167 callback_ = callback;
168 return ERR_IO_PENDING; 168 return ERR_IO_PENDING;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 callback_ = callback; 209 callback_ = callback;
210 user_buffer_ = buf; 210 user_buffer_ = buf;
211 user_buffer_len_ = buf_len; 211 user_buffer_len_ = buf_len;
212 return ERR_IO_PENDING; 212 return ERR_IO_PENDING;
213 } 213 }
214 214
215 void QuicHttpStream::Close(bool not_reusable) { 215 void QuicHttpStream::Close(bool not_reusable) {
216 // Note: the not_reusable flag has no meaning for SPDY streams. 216 // Note: the not_reusable flag has no meaning for SPDY streams.
217 if (stream_) { 217 if (stream_) {
218 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 218 closed_stream_received_bytes_ = stream_->stream_bytes_read();
219 stream_->SetDelegate(NULL); 219 stream_->SetDelegate(nullptr);
220 stream_->Reset(QUIC_STREAM_CANCELLED); 220 stream_->Reset(QUIC_STREAM_CANCELLED);
221 stream_ = NULL; 221 stream_ = nullptr;
222 response_status_ = was_handshake_confirmed_ ? 222 response_status_ = was_handshake_confirmed_ ?
223 ERR_CONNECTION_CLOSED : ERR_QUIC_HANDSHAKE_FAILED; 223 ERR_CONNECTION_CLOSED : ERR_QUIC_HANDSHAKE_FAILED;
224 } 224 }
225 } 225 }
226 226
227 HttpStream* QuicHttpStream::RenewStreamForAuth() { 227 HttpStream* QuicHttpStream::RenewStreamForAuth() {
228 return NULL; 228 return nullptr;
229 } 229 }
230 230
231 bool QuicHttpStream::IsResponseBodyComplete() const { 231 bool QuicHttpStream::IsResponseBodyComplete() const {
232 return next_state_ == STATE_OPEN && !stream_; 232 return next_state_ == STATE_OPEN && !stream_;
233 } 233 }
234 234
235 bool QuicHttpStream::CanFindEndOfResponse() const { 235 bool QuicHttpStream::CanFindEndOfResponse() const {
236 return true; 236 return true;
237 } 237 }
238 238
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 if (length <= user_buffer_len_) { 315 if (length <= user_buffer_len_) {
316 memcpy(user_buffer_->data(), data, length); 316 memcpy(user_buffer_->data(), data, length);
317 } else { 317 } else {
318 memcpy(user_buffer_->data(), data, user_buffer_len_); 318 memcpy(user_buffer_->data(), data, user_buffer_len_);
319 int delta = length - user_buffer_len_; 319 int delta = length - user_buffer_len_;
320 BufferResponseBody(data + user_buffer_len_, delta); 320 BufferResponseBody(data + user_buffer_len_, delta);
321 length = user_buffer_len_; 321 length = user_buffer_len_;
322 } 322 }
323 323
324 user_buffer_ = NULL; 324 user_buffer_ = nullptr;
325 user_buffer_len_ = 0; 325 user_buffer_len_ = 0;
326 DoCallback(length); 326 DoCallback(length);
327 return OK; 327 return OK;
328 } 328 }
329 329
330 void QuicHttpStream::OnClose(QuicErrorCode error) { 330 void QuicHttpStream::OnClose(QuicErrorCode error) {
331 if (error != QUIC_NO_ERROR) { 331 if (error != QUIC_NO_ERROR) {
332 response_status_ = was_handshake_confirmed_ ? 332 response_status_ = was_handshake_confirmed_ ?
333 ERR_QUIC_PROTOCOL_ERROR : ERR_QUIC_HANDSHAKE_FAILED; 333 ERR_QUIC_PROTOCOL_ERROR : ERR_QUIC_HANDSHAKE_FAILED;
334 } else if (!response_headers_received_) { 334 } else if (!response_headers_received_) {
335 response_status_ = ERR_ABORTED; 335 response_status_ = ERR_ABORTED;
336 } 336 }
337 337
338 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 338 closed_stream_received_bytes_ = stream_->stream_bytes_read();
339 stream_ = NULL; 339 stream_ = nullptr;
340 if (!callback_.is_null()) 340 if (!callback_.is_null())
341 DoCallback(response_status_); 341 DoCallback(response_status_);
342 } 342 }
343 343
344 void QuicHttpStream::OnError(int error) { 344 void QuicHttpStream::OnError(int error) {
345 stream_ = NULL; 345 stream_ = nullptr;
346 response_status_ = was_handshake_confirmed_ ? 346 response_status_ = was_handshake_confirmed_ ?
347 error : ERR_QUIC_HANDSHAKE_FAILED; 347 error : ERR_QUIC_HANDSHAKE_FAILED;
348 if (!callback_.is_null()) 348 if (!callback_.is_null())
349 DoCallback(response_status_); 349 DoCallback(response_status_);
350 } 350 }
351 351
352 bool QuicHttpStream::HasSendHeadersComplete() { 352 bool QuicHttpStream::HasSendHeadersComplete() {
353 return next_state_ > STATE_SEND_HEADERS_COMPLETE; 353 return next_state_ > STATE_SEND_HEADERS_COMPLETE;
354 } 354 }
355 355
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 stream_net_log_.AddEvent( 427 stream_net_log_.AddEvent(
428 NetLog::TYPE_HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS, 428 NetLog::TYPE_HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS,
429 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, 429 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_,
430 priority_)); 430 priority_));
431 // Also log to the QuicSession's net log. 431 // Also log to the QuicSession's net log.
432 stream_->net_log().AddEvent( 432 stream_->net_log().AddEvent(
433 NetLog::TYPE_QUIC_HTTP_STREAM_SEND_REQUEST_HEADERS, 433 NetLog::TYPE_QUIC_HTTP_STREAM_SEND_REQUEST_HEADERS,
434 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, 434 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_,
435 priority_)); 435 priority_));
436 436
437 bool has_upload_data = request_body_stream_ != NULL; 437 bool has_upload_data = request_body_stream_ != nullptr;
438 438
439 next_state_ = STATE_SEND_HEADERS_COMPLETE; 439 next_state_ = STATE_SEND_HEADERS_COMPLETE;
440 int rv = stream_->WriteHeaders(request_headers_, !has_upload_data, NULL); 440 int rv = stream_->WriteHeaders(request_headers_, !has_upload_data, nullptr);
441 request_headers_.clear(); 441 request_headers_.clear();
442 return rv; 442 return rv;
443 } 443 }
444 444
445 int QuicHttpStream::DoSendHeadersComplete(int rv) { 445 int QuicHttpStream::DoSendHeadersComplete(int rv) {
446 if (rv < 0) 446 if (rv < 0)
447 return rv; 447 return rv;
448 448
449 next_state_ = request_body_stream_ ? 449 next_state_ = request_body_stream_ ?
450 STATE_READ_REQUEST_BODY : STATE_OPEN; 450 STATE_READ_REQUEST_BODY : STATE_OPEN;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 void QuicHttpStream::BufferResponseBody(const char* data, int length) { 557 void QuicHttpStream::BufferResponseBody(const char* data, int length) {
558 if (length == 0) 558 if (length == 0)
559 return; 559 return;
560 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); 560 IOBufferWithSize* io_buffer = new IOBufferWithSize(length);
561 memcpy(io_buffer->data(), data, length); 561 memcpy(io_buffer->data(), data, length);
562 response_body_.push_back(make_scoped_refptr(io_buffer)); 562 response_body_.push_back(make_scoped_refptr(io_buffer));
563 } 563 }
564 564
565 } // namespace net 565 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_headers_stream_test.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698