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

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

Issue 46573008: Fix a crash in URLFetcherCore by handling a case where |request_| is NULL (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 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 | « 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) 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_fetcher_core.h" 5 #include "net/url_request/url_fetcher_core.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 data->DidConsume(result); 825 data->DidConsume(result);
826 if (WriteBuffer(data) < 0) 826 if (WriteBuffer(data) < 0)
827 return; 827 return;
828 828
829 // Finished writing buffer_. Read some more. 829 // Finished writing buffer_. Read some more.
830 DCHECK_EQ(0, data->BytesRemaining()); 830 DCHECK_EQ(0, data->BytesRemaining());
831 ReadResponse(); 831 ReadResponse();
832 } 832 }
833 833
834 void URLFetcherCore::ReadResponse() { 834 void URLFetcherCore::ReadResponse() {
835 if (!request_.get())
836 return;
mmenke 2013/10/31 18:14:18 I'd really like to just delete the writer on cance
droger 2013/11/04 15:38:04 Done.
835 // Some servers may treat HEAD requests as GET requests. To free up the 837 // Some servers may treat HEAD requests as GET requests. To free up the
836 // network connection as soon as possible, signal that the request has 838 // network connection as soon as possible, signal that the request has
837 // completed immediately, without trying to read any data back (all we care 839 // completed immediately, without trying to read any data back (all we care
838 // about is the response code and headers, which we already have). 840 // about is the response code and headers, which we already have).
839 int bytes_read = 0; 841 int bytes_read = 0;
840 if (request_->status().is_success() && 842 if (request_->status().is_success() &&
841 (request_type_ != URLFetcher::HEAD)) 843 (request_type_ != URLFetcher::HEAD))
842 request_->Read(buffer_.get(), kBufferSize, &bytes_read); 844 request_->Read(buffer_.get(), kBufferSize, &bytes_read);
843 OnReadCompleted(request_.get(), bytes_read); 845 OnReadCompleted(request_.get(), bytes_read);
844 } 846 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 } 885 }
884 886
885 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( 887 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread(
886 int64 current, int64 total) { 888 int64 current, int64 total) {
887 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 889 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
888 if (delegate_) 890 if (delegate_)
889 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); 891 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total);
890 } 892 }
891 893
892 } // namespace net 894 } // namespace net
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