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

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

Issue 12388017: Move the responsibility to convert from JSON to AccountMetadata into gdata_wapi_operations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148632_gdata_wapi_get_about_resource_impl
Patch Set: Created 7 years, 10 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/google_apis/gdata_wapi_operations.cc
diff --git a/chrome/browser/google_apis/gdata_wapi_operations.cc b/chrome/browser/google_apis/gdata_wapi_operations.cc
index 2f0a16f0e318d3bcaafe1e076f9c874be2803f10..c33c336ab2572c8736330a9ac860b5c19da23962 100644
--- a/chrome/browser/google_apis/gdata_wapi_operations.cc
+++ b/chrome/browser/google_apis/gdata_wapi_operations.cc
@@ -32,6 +32,30 @@ const char kFeedField[] = "feed";
// Templates for file uploading.
const char kUploadResponseRange[] = "range";
+// Parses the JSON value to AccountMetadataFeed and runs |callback| on the UI
+// thread once parsing is done.
+void ParseAccounetMetadataAndRun(const GetAccountMetadataCallback& callback,
+ GDataErrorCode error,
+ scoped_ptr<base::Value> value) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ if (!value) {
+ callback.Run(error, scoped_ptr<AccountMetadataFeed>());
+ return;
+ }
+
+ // Parsing AccountMetadataFeed is cheap enough to do on UI thread.
+ scoped_ptr<AccountMetadataFeed> entry =
+ google_apis::AccountMetadataFeed::CreateFrom(*value);
+ if (!entry) {
+ callback.Run(GDATA_PARSE_ERROR, scoped_ptr<AccountMetadataFeed>());
+ return;
+ }
+
+ callback.Run(error, entry.Pass());
+}
+
// Parses the |value| to ResourceEntry with error handling.
// This is designed to be used for ResumeUploadOperation and
// GetUploadStatusOperation.
@@ -110,8 +134,9 @@ GetAccountMetadataOperation::GetAccountMetadataOperation(
OperationRegistry* registry,
net::URLRequestContextGetter* url_request_context_getter,
const GDataWapiUrlGenerator& url_generator,
- const GetDataCallback& callback)
- : GetDataOperation(registry, url_request_context_getter, callback),
+ const GetAccountMetadataCallback& callback)
+ : GetDataOperation(registry, url_request_context_getter,
+ base::Bind(&ParseAccounetMetadataAndRun, callback)),
url_generator_(url_generator) {
DCHECK(!callback.is_null());
}
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_operations.h ('k') | chrome/browser/google_apis/gdata_wapi_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698