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

Unified Diff: chrome/browser/google_apis/base_requests.cc

Issue 19771024: Parse content in the response for upload iff the upload is successfully done. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | « no previous file | chrome/browser/google_apis/drive_api_requests_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/base_requests.cc
diff --git a/chrome/browser/google_apis/base_requests.cc b/chrome/browser/google_apis/base_requests.cc
index 8963eb994f8242815283d714e1e73e3f0c6139fb..2dbaddeb82a94687e0cfe2cd876b49ab4f4af90e 100644
--- a/chrome/browser/google_apis/base_requests.cc
+++ b/chrome/browser/google_apis/base_requests.cc
@@ -490,8 +490,9 @@ void UploadRangeRequestBase::ProcessURLFetchResults(
scoped_ptr<base::Value>());
OnProcessURLFetchResultsComplete(true);
- } else {
- // There might be explanation of unexpected error code in response.
+ } else if (code == HTTP_CREATED || code == HTTP_SUCCESS) {
+ // The upload is successfully done. Parse the response which should be
+ // the entry's metadata.
std::string response_content;
source->GetResponseAsString(&response_content);
@@ -500,16 +501,21 @@ void UploadRangeRequestBase::ProcessURLFetchResults(
base::Bind(&UploadRangeRequestBase::OnDataParsed,
weak_ptr_factory_.GetWeakPtr(),
code));
+ } else {
+ // Failed to upload. Run callbacks to notify the error.
+ OnRangeRequestComplete(
+ UploadRangeResponse(code, -1, -1), scoped_ptr<base::Value>());
+ OnProcessURLFetchResultsComplete(false);
}
}
void UploadRangeRequestBase::OnDataParsed(GDataErrorCode code,
scoped_ptr<base::Value> value) {
DCHECK(CalledOnValidThread());
+ DCHECK(code == HTTP_CREATED || code == HTTP_SUCCESS);
OnRangeRequestComplete(UploadRangeResponse(code, -1, -1), value.Pass());
- OnProcessURLFetchResultsComplete(
- code == HTTP_CREATED || code == HTTP_SUCCESS);
+ OnProcessURLFetchResultsComplete(true);
}
void UploadRangeRequestBase::RunCallbackOnPrematureFailure(
« no previous file with comments | « no previous file | chrome/browser/google_apis/drive_api_requests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698