Chromium Code Reviews| 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/files/file_util_proxy.h" | 8 #include "base/files/file_util_proxy.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 url_request_create_data_callback_.Run()); | 727 url_request_create_data_callback_.Run()); |
| 728 } | 728 } |
| 729 | 729 |
| 730 switch (request_type_) { | 730 switch (request_type_) { |
| 731 case URLFetcher::GET: | 731 case URLFetcher::GET: |
| 732 break; | 732 break; |
| 733 | 733 |
| 734 case URLFetcher::POST: | 734 case URLFetcher::POST: |
| 735 case URLFetcher::PUT: | 735 case URLFetcher::PUT: |
| 736 case URLFetcher::PATCH: | 736 case URLFetcher::PATCH: |
| 737 DCHECK(!upload_content_type_.empty()); | 737 // |upload_content_type_| must be set if there is (non-empty) upload |
| 738 // content. | |
| 739 DCHECK(!(is_chunked_upload_ || upload_content_) || | |
| 740 !upload_content_type_.empty()); | |
|
mmenke
2013/02/06 16:23:58
Rather than this, I'd prefer a design that require
hidehiko
2013/02/06 17:19:49
Indeed. I just allowed SetUploadData("", "") for e
| |
| 738 | 741 |
| 739 request_->set_method( | 742 request_->set_method( |
| 740 request_type_ == URLFetcher::POST ? "POST" : | 743 request_type_ == URLFetcher::POST ? "POST" : |
| 741 request_type_ == URLFetcher::PUT ? "PUT" : "PATCH"); | 744 request_type_ == URLFetcher::PUT ? "PUT" : "PATCH"); |
| 742 extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType, | 745 if (!upload_content_type_.empty()) |
| 743 upload_content_type_); | 746 extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType, |
| 747 upload_content_type_); | |
|
mmenke
2013/02/06 16:23:58
nit: Use braces when body is more than one line.
hidehiko
2013/02/06 17:19:49
Done.
| |
| 744 if (upload_content_) | 748 if (upload_content_) |
| 745 request_->set_upload(upload_content_.Pass()); | 749 request_->set_upload(upload_content_.Pass()); |
| 746 current_upload_bytes_ = -1; | 750 current_upload_bytes_ = -1; |
| 747 // TODO(kinaba): http://crbug.com/118103. Implement upload callback in the | 751 // TODO(kinaba): http://crbug.com/118103. Implement upload callback in the |
| 748 // layer and avoid using timer here. | 752 // layer and avoid using timer here. |
| 749 upload_progress_checker_timer_.reset( | 753 upload_progress_checker_timer_.reset( |
| 750 new base::RepeatingTimer<URLFetcherCore>()); | 754 new base::RepeatingTimer<URLFetcherCore>()); |
| 751 upload_progress_checker_timer_->Start( | 755 upload_progress_checker_timer_->Start( |
| 752 FROM_HERE, | 756 FROM_HERE, |
| 753 base::TimeDelta::FromMilliseconds(kUploadProgressTimerInterval), | 757 base::TimeDelta::FromMilliseconds(kUploadProgressTimerInterval), |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1064 } | 1068 } |
| 1065 | 1069 |
| 1066 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( | 1070 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( |
| 1067 scoped_ptr<std::string> download_data) { | 1071 scoped_ptr<std::string> download_data) { |
| 1068 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 1072 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 1069 if (delegate_) | 1073 if (delegate_) |
| 1070 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); | 1074 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); |
| 1071 } | 1075 } |
| 1072 | 1076 |
| 1073 } // namespace net | 1077 } // namespace net |
| OLD | NEW |