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

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

Issue 2425673006: Make URLFetcherFileWriter::Finish() skip closing file when there is an error (Closed)
Patch Set: Fix test Created 4 years, 2 months 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
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 <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
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,
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
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
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
OLDNEW
« no previous file with comments | « net/url_request/test_url_fetcher_factory.cc ('k') | net/url_request/url_fetcher_response_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698