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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 FROM_HERE, | 819 FROM_HERE, |
820 base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, this)); | 820 base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, this)); |
821 return; | 821 return; |
822 } | 822 } |
823 | 823 |
824 // Continue writing. | 824 // Continue writing. |
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, unless the request has been |
| 830 // cancelled and deleted. |
830 DCHECK_EQ(0, data->BytesRemaining()); | 831 DCHECK_EQ(0, data->BytesRemaining()); |
831 ReadResponse(); | 832 if (request_.get()) |
| 833 ReadResponse(); |
832 } | 834 } |
833 | 835 |
834 void URLFetcherCore::ReadResponse() { | 836 void URLFetcherCore::ReadResponse() { |
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)) |
(...skipping 41 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 |