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

Unified Diff: chrome/browser/chromeos/gdata/gdata_operations.cc

Issue 10808027: gdrive: Get JSON feeds parsing off the UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Call NotifyFinish/NotifySuccess after parse. Created 8 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
Index: chrome/browser/chromeos/gdata/gdata_operations.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_operations.cc b/chrome/browser/chromeos/gdata/gdata_operations.cc
index e0057eb392b823f9288ef945bfcda7c37497b55f..a3ee3288ded7e50250740e077a9b6ad0663cc332 100644
--- a/chrome/browser/chromeos/gdata/gdata_operations.cc
+++ b/chrome/browser/chromeos/gdata/gdata_operations.cc
@@ -261,8 +261,9 @@ void DownloadFileOperation::OnURLFetchDownloadData(
get_download_data_callback_.Run(HTTP_SUCCESS, download_data.Pass());
}
-bool DownloadFileOperation::ProcessURLFetchResults(
- const URLFetcher* source) {
+void DownloadFileOperation::ProcessURLFetchResults(
+ const URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& result_callback) {
GDataErrorCode code = GetErrorCode(source);
// Take over the ownership of the the downloaded temp file.
@@ -275,7 +276,7 @@ bool DownloadFileOperation::ProcessURLFetchResults(
if (!download_action_callback_.is_null())
download_action_callback_.Run(code, document_url_, temp_file);
- return code == HTTP_SUCCESS;
+ result_callback.Run(code == HTTP_SUCCESS);
}
void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) {
@@ -477,11 +478,12 @@ AuthorizeAppsOperation::GetExtraRequestHeaders() const {
return headers;
}
-bool AuthorizeAppsOperation::ProcessURLFetchResults(
- const URLFetcher* source) {
+void AuthorizeAppsOperation::ProcessURLFetchResults(
+ const URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& result_callback) {
std::string data;
source->GetResponseAsString(&data);
- return GetDataOperation::ProcessURLFetchResults(source);
+ GetDataOperation::ProcessURLFetchResults(source, result_callback);
}
bool AuthorizeAppsOperation::GetContentData(std::string* upload_content_type,
@@ -502,7 +504,10 @@ bool AuthorizeAppsOperation::GetContentData(std::string* upload_content_type,
return true;
}
-base::Value* AuthorizeAppsOperation::ParseResponse(const std::string& data) {
+void AuthorizeAppsOperation::ParseResponse(
+ GDataErrorCode fetch_error_code,
+ const std::string& data,
+ const ProcessURLFetchResultsCallBack& result_callback) {
// Parse entry XML.
XmlReader xml_reader;
scoped_ptr<DocumentEntry> entry;
@@ -531,7 +536,8 @@ base::Value* AuthorizeAppsOperation::ParseResponse(const std::string& data) {
}
}
- return link_list.release();
+ RunCallback(fetch_error_code, link_list.PassAs<base::Value>());
+ result_callback.Run(true);
hashimoto 2012/07/20 04:07:37 nit: Code simply passing true/false is not easy to
yoshiki 2012/07/24 16:58:32 Done.
}
GURL AuthorizeAppsOperation::GetURL() const {
@@ -644,8 +650,9 @@ GURL InitiateUploadOperation::GetURL() const {
return initiate_upload_url_;
}
-bool InitiateUploadOperation::ProcessURLFetchResults(
- const URLFetcher* source) {
+void InitiateUploadOperation::ProcessURLFetchResults(
+ const URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& result_callback) {
GDataErrorCode code = GetErrorCode(source);
std::string upload_location;
@@ -661,7 +668,7 @@ bool InitiateUploadOperation::ProcessURLFetchResults(
if (!callback_.is_null())
callback_.Run(code, GURL(upload_location));
- return code == HTTP_SUCCESS;
+ result_callback.Run(code == HTTP_SUCCESS);
}
void InitiateUploadOperation::NotifySuccessToOperationRegistry() {
@@ -748,8 +755,9 @@ GURL ResumeUploadOperation::GetURL() const {
return params_.upload_location;
}
-bool ResumeUploadOperation::ProcessURLFetchResults(
- const URLFetcher* source) {
+void ResumeUploadOperation::ProcessURLFetchResults(
+ const URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& result_callback) {
GDataErrorCode code = GetErrorCode(source);
net::HttpResponseHeaders* hdrs = source->GetResponseHeaders();
int64 start_range_received = -1;
@@ -810,7 +818,7 @@ bool ResumeUploadOperation::ProcessURLFetchResults(
last_chunk_completed_ = true;
}
- return last_chunk_completed_ || code == HTTP_RESUME_INCOMPLETE;
+ result_callback.Run(last_chunk_completed_ || code == HTTP_RESUME_INCOMPLETE);
}
void ResumeUploadOperation::NotifyStartToOperationRegistry() {

Powered by Google App Engine
This is Rietveld 408576698