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

Side by Side Diff: net/url_request/url_request_job.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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/url_request/url_request_ftp_job.cc ('k') | net/url_request/view_cache_helper.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/url_request/url_request_job.h" 5 #include "net/url_request/url_request_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // This function calls ReadData to get stream data. If a filter exists, passes 61 // This function calls ReadData to get stream data. If a filter exists, passes
62 // the data to the attached filter. Then returns the output from filter back to 62 // the data to the attached filter. Then returns the output from filter back to
63 // the caller. 63 // the caller.
64 bool URLRequestJob::Read(IOBuffer* buf, int buf_size, int *bytes_read) { 64 bool URLRequestJob::Read(IOBuffer* buf, int buf_size, int *bytes_read) {
65 bool rv = false; 65 bool rv = false;
66 66
67 DCHECK_LT(buf_size, 1000000); // Sanity check. 67 DCHECK_LT(buf_size, 1000000); // Sanity check.
68 DCHECK(buf); 68 DCHECK(buf);
69 DCHECK(bytes_read); 69 DCHECK(bytes_read);
70 DCHECK(filtered_read_buffer_ == NULL); 70 DCHECK(filtered_read_buffer_.get() == NULL);
71 DCHECK_EQ(0, filtered_read_buffer_len_); 71 DCHECK_EQ(0, filtered_read_buffer_len_);
72 72
73 *bytes_read = 0; 73 *bytes_read = 0;
74 74
75 // Skip Filter if not present. 75 // Skip Filter if not present.
76 if (!filter_.get()) { 76 if (!filter_.get()) {
77 rv = ReadRawDataHelper(buf, buf_size, bytes_read); 77 rv = ReadRawDataHelper(buf, buf_size, bytes_read);
78 } else { 78 } else {
79 // Save the caller's buffers while we do IO 79 // Save the caller's buffers while we do IO
80 // in the filter's buffers. 80 // in the filter's buffers.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } else { 310 } else {
311 FollowRedirect(new_location, http_status_code); 311 FollowRedirect(new_location, http_status_code);
312 } 312 }
313 return; 313 return;
314 } 314 }
315 } else if (NeedsAuth()) { 315 } else if (NeedsAuth()) {
316 scoped_refptr<AuthChallengeInfo> auth_info; 316 scoped_refptr<AuthChallengeInfo> auth_info;
317 GetAuthChallengeInfo(&auth_info); 317 GetAuthChallengeInfo(&auth_info);
318 // Need to check for a NULL auth_info because the server may have failed 318 // Need to check for a NULL auth_info because the server may have failed
319 // to send a challenge with the 401 response. 319 // to send a challenge with the 401 response.
320 if (auth_info) { 320 if (auth_info.get()) {
321 request_->NotifyAuthRequired(auth_info); 321 request_->NotifyAuthRequired(auth_info.get());
322 // Wait for SetAuth or CancelAuth to be called. 322 // Wait for SetAuth or CancelAuth to be called.
323 return; 323 return;
324 } 324 }
325 } 325 }
326 326
327 has_handled_response_ = true; 327 has_handled_response_ = true;
328 if (request_->status().is_success()) 328 if (request_->status().is_success())
329 filter_.reset(SetupFilter()); 329 filter_.reset(SetupFilter());
330 330
331 if (!filter_.get()) { 331 if (!filter_.get()) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // Do nothing. 477 // Do nothing.
478 } 478 }
479 479
480 void URLRequestJob::FilteredDataRead(int bytes_read) { 480 void URLRequestJob::FilteredDataRead(int bytes_read) {
481 DCHECK(filter_.get()); // don't add data if there is no filter 481 DCHECK(filter_.get()); // don't add data if there is no filter
482 filter_->FlushStreamBuffer(bytes_read); 482 filter_->FlushStreamBuffer(bytes_read);
483 } 483 }
484 484
485 bool URLRequestJob::ReadFilteredData(int* bytes_read) { 485 bool URLRequestJob::ReadFilteredData(int* bytes_read) {
486 DCHECK(filter_.get()); // don't add data if there is no filter 486 DCHECK(filter_.get()); // don't add data if there is no filter
487 DCHECK(filtered_read_buffer_ != NULL); // we need to have a buffer to fill 487 DCHECK(
488 filtered_read_buffer_.get() != NULL); // we need to have a buffer to fill
488 DCHECK_GT(filtered_read_buffer_len_, 0); // sanity check 489 DCHECK_GT(filtered_read_buffer_len_, 0); // sanity check
489 DCHECK_LT(filtered_read_buffer_len_, 1000000); // sanity check 490 DCHECK_LT(filtered_read_buffer_len_, 1000000); // sanity check
490 DCHECK(raw_read_buffer_ == NULL); // there should be no raw read buffer yet 491 DCHECK(
492 raw_read_buffer_.get() ==
493 NULL); // there should be no raw read buffer yet
491 494
492 bool rv = false; 495 bool rv = false;
493 *bytes_read = 0; 496 *bytes_read = 0;
494 497
495 if (is_done()) 498 if (is_done())
496 return true; 499 return true;
497 500
498 if (!filter_needs_more_output_space_ && !filter_->stream_data_len()) { 501 if (!filter_needs_more_output_space_ && !filter_->stream_data_len()) {
499 // We don't have any raw data to work with, so 502 // We don't have any raw data to work with, so
500 // read from the socket. 503 // read from the socket.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 IOBuffer* stream_buffer = filter_->stream_buffer(); 639 IOBuffer* stream_buffer = filter_->stream_buffer();
637 int stream_buffer_size = filter_->stream_buffer_size(); 640 int stream_buffer_size = filter_->stream_buffer_size();
638 rv = ReadRawDataHelper(stream_buffer, stream_buffer_size, bytes_read); 641 rv = ReadRawDataHelper(stream_buffer, stream_buffer_size, bytes_read);
639 } 642 }
640 return rv; 643 return rv;
641 } 644 }
642 645
643 bool URLRequestJob::ReadRawDataHelper(IOBuffer* buf, int buf_size, 646 bool URLRequestJob::ReadRawDataHelper(IOBuffer* buf, int buf_size,
644 int* bytes_read) { 647 int* bytes_read) {
645 DCHECK(!request_->status().is_io_pending()); 648 DCHECK(!request_->status().is_io_pending());
646 DCHECK(raw_read_buffer_ == NULL); 649 DCHECK(raw_read_buffer_.get() == NULL);
647 650
648 // Keep a pointer to the read buffer, so we have access to it in the 651 // Keep a pointer to the read buffer, so we have access to it in the
649 // OnRawReadComplete() callback in the event that the read completes 652 // OnRawReadComplete() callback in the event that the read completes
650 // asynchronously. 653 // asynchronously.
651 raw_read_buffer_ = buf; 654 raw_read_buffer_ = buf;
652 bool rv = ReadRawData(buf, buf_size, bytes_read); 655 bool rv = ReadRawData(buf, buf_size, bytes_read);
653 656
654 if (!request_->status().is_io_pending()) { 657 if (!request_->status().is_io_pending()) {
655 // If |filter_| is NULL, and logging all bytes is enabled, log the raw 658 // If |filter_| is NULL, and logging all bytes is enabled, log the raw
656 // bytes read. 659 // bytes read.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 702 }
700 703
701 bool URLRequestJob::FilterHasData() { 704 bool URLRequestJob::FilterHasData() {
702 return filter_.get() && filter_->stream_data_len(); 705 return filter_.get() && filter_->stream_data_len();
703 } 706 }
704 707
705 void URLRequestJob::UpdatePacketReadTimes() { 708 void URLRequestJob::UpdatePacketReadTimes() {
706 } 709 }
707 710
708 } // namespace net 711 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_ftp_job.cc ('k') | net/url_request/view_cache_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698