OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |