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

Unified Diff: net/url_request/url_fetcher_core.cc

Issue 26784003: google_apis: Implement google_apis::ResponseWriter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_fetcher_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_fetcher_core.cc
diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc
index e25fc95a16bc3c8412ddfd8d141241243b5bf570..bd28b4b0161af2c205a3c2cd1766fbc15ef5ab3d 100644
--- a/net/url_request/url_fetcher_core.cc
+++ b/net/url_request/url_fetcher_core.cc
@@ -31,6 +31,8 @@ const int kUploadProgressTimerInterval = 100;
bool g_interception_enabled = false;
bool g_ignore_certificate_requests = false;
+void EmptyCompletionCallback(int result) {}
+
} // namespace
namespace net {
@@ -425,7 +427,6 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request,
current_response_bytes_ += bytes_read;
InformDelegateDownloadProgress();
- InformDelegateDownloadDataIfNecessary(bytes_read);
const int result =
WriteBuffer(new DrainableIOBuffer(buffer_.get(), bytes_read));
@@ -650,7 +651,6 @@ void URLFetcherCore::CancelURLRequest(int error) {
url_request_data_key_ = NULL;
url_request_create_data_callback_.Reset();
was_cancelled_ = true;
- response_writer_.reset();
}
void URLFetcherCore::OnCompletedURLRequest(
@@ -801,12 +801,8 @@ int URLFetcherCore::WriteBuffer(scoped_refptr<DrainableIOBuffer> data) {
data->BytesRemaining(),
base::Bind(&URLFetcherCore::DidWriteBuffer, this, data));
if (result < 0) {
- if (result != ERR_IO_PENDING) {
- CancelURLRequest(result);
- delegate_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, this));
- }
+ if (result != ERR_IO_PENDING)
+ DidWriteBuffer(data, result);
return result;
}
data->DidConsume(result);
@@ -818,6 +814,7 @@ void URLFetcherCore::DidWriteBuffer(scoped_refptr<DrainableIOBuffer> data,
int result) {
if (result < 0) { // Handle errors.
CancelURLRequest(result);
+ response_writer_->Finish(base::Bind(&EmptyCompletionCallback));
delegate_task_runner_->PostTask(
FROM_HERE,
base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, this));
@@ -892,24 +889,4 @@ void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread(
delegate_->OnURLFetchDownloadProgress(fetcher_, current, total);
}
-void URLFetcherCore::InformDelegateDownloadDataIfNecessary(int bytes_read) {
- DCHECK(network_task_runner_->BelongsToCurrentThread());
- if (delegate_ && delegate_->ShouldSendDownloadData()) {
- scoped_ptr<std::string> download_data(
- new std::string(buffer_->data(), bytes_read));
- delegate_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &URLFetcherCore::InformDelegateDownloadDataInDelegateThread,
- this, base::Passed(&download_data)));
- }
-}
-
-void URLFetcherCore::InformDelegateDownloadDataInDelegateThread(
- scoped_ptr<std::string> download_data) {
- DCHECK(delegate_task_runner_->BelongsToCurrentThread());
- if (delegate_)
- delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass());
-}
-
} // namespace net
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_fetcher_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698