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 <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 // See comments re: HEAD requests in ReadResponse(). | 470 // See comments re: HEAD requests in ReadResponse(). |
471 if (bytes_read != ERR_IO_PENDING || request_type_ == URLFetcher::HEAD) { | 471 if (bytes_read != ERR_IO_PENDING || request_type_ == URLFetcher::HEAD) { |
472 status_ = URLRequestStatus::FromError(bytes_read); | 472 status_ = URLRequestStatus::FromError(bytes_read); |
473 received_response_content_length_ = | 473 received_response_content_length_ = |
474 request_->received_response_content_length(); | 474 request_->received_response_content_length(); |
475 total_received_bytes_ += request_->GetTotalReceivedBytes(); | 475 total_received_bytes_ += request_->GetTotalReceivedBytes(); |
476 ReleaseRequest(); | 476 ReleaseRequest(); |
477 | 477 |
478 // No more data to write. | 478 // No more data to write. |
479 const int result = response_writer_->Finish( | 479 const int result = response_writer_->Finish( |
480 bytes_read > 0 ? OK : bytes_read, | |
mmenke
2016/10/18 20:20:01
Hrm...I'd normally ask for an integration test tha
xunjieli
2016/10/18 21:18:07
I see. So in the future URLRequest::Delegate::OnRe
mmenke
2016/10/18 21:40:46
No, in the future, I want it not to call into the
xunjieli
2016/10/19 12:00:21
Acknowledged. Thanks for explaining!
| |
480 base::Bind(&URLFetcherCore::DidFinishWriting, this)); | 481 base::Bind(&URLFetcherCore::DidFinishWriting, this)); |
481 if (result != ERR_IO_PENDING) | 482 if (result != ERR_IO_PENDING) |
482 DidFinishWriting(result); | 483 DidFinishWriting(result); |
483 } | 484 } |
484 } | 485 } |
485 | 486 |
486 void URLFetcherCore::OnContextShuttingDown() { | 487 void URLFetcherCore::OnContextShuttingDown() { |
487 DCHECK(request_); | 488 DCHECK(request_); |
488 CancelRequestAndInformDelegate(ERR_CONTEXT_SHUT_DOWN); | 489 CancelRequestAndInformDelegate(ERR_CONTEXT_SHUT_DOWN); |
489 } | 490 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 return result; | 855 return result; |
855 } | 856 } |
856 data->DidConsume(result); | 857 data->DidConsume(result); |
857 } | 858 } |
858 return OK; | 859 return OK; |
859 } | 860 } |
860 | 861 |
861 void URLFetcherCore::DidWriteBuffer(scoped_refptr<DrainableIOBuffer> data, | 862 void URLFetcherCore::DidWriteBuffer(scoped_refptr<DrainableIOBuffer> data, |
862 int result) { | 863 int result) { |
863 if (result < 0) { // Handle errors. | 864 if (result < 0) { // Handle errors. |
864 response_writer_->Finish(base::Bind(&EmptyCompletionCallback)); | 865 response_writer_->Finish(result, base::Bind(&EmptyCompletionCallback)); |
865 CancelRequestAndInformDelegate(result); | 866 CancelRequestAndInformDelegate(result); |
866 return; | 867 return; |
867 } | 868 } |
868 | 869 |
869 // Continue writing. | 870 // Continue writing. |
870 data->DidConsume(result); | 871 data->DidConsume(result); |
871 if (WriteBuffer(data) < 0) | 872 if (WriteBuffer(data) < 0) |
872 return; | 873 return; |
873 | 874 |
874 // Finished writing buffer_. Read some more, unless the request has been | 875 // Finished writing buffer_. Read some more, unless the request has been |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 } | 949 } |
949 | 950 |
950 void URLFetcherCore::AssertHasNoUploadData() const { | 951 void URLFetcherCore::AssertHasNoUploadData() const { |
951 DCHECK(!upload_content_set_); | 952 DCHECK(!upload_content_set_); |
952 DCHECK(upload_content_.empty()); | 953 DCHECK(upload_content_.empty()); |
953 DCHECK(upload_file_path_.empty()); | 954 DCHECK(upload_file_path_.empty()); |
954 DCHECK(upload_stream_factory_.is_null()); | 955 DCHECK(upload_stream_factory_.is_null()); |
955 } | 956 } |
956 | 957 |
957 } // namespace net | 958 } // namespace net |
OLD | NEW |