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

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

Issue 11530004: google_apis: DriveServiceInterface::GetResourceEntry() returns ResourceEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years 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 | « chrome/browser/google_apis/gdata_wapi_service.h ('k') | chrome/browser/google_apis/mock_drive_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/gdata_wapi_service.cc
diff --git a/chrome/browser/google_apis/gdata_wapi_service.cc b/chrome/browser/google_apis/gdata_wapi_service.cc
index 20be5b5c9a6904f0f97496b1545688e0a8767ac5..62f2af3c2974fd8134cffc0bfb726039ede9d669 100644
--- a/chrome/browser/google_apis/gdata_wapi_service.cc
+++ b/chrome/browser/google_apis/gdata_wapi_service.cc
@@ -107,6 +107,28 @@ void ParseResourceListAndRun(const GetResourceListCallback& callback,
base::Bind(&DidParseResourceListOnBlockingPool, callback, error));
}
+// Parses the JSON value to ResourceEntry runs |callback|.
+void ParseResourceEntryAndRun(const GetResourceEntryCallback& callback,
+ GDataErrorCode error,
+ scoped_ptr<base::Value> value) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!value) {
+ callback.Run(error, scoped_ptr<ResourceEntry>());
+ return;
+ }
+
+ // Parsing ResourceEntry is cheap enough to do on UI thread.
+ scoped_ptr<ResourceEntry> entry =
+ google_apis::ResourceEntry::ExtractAndParse(*value);
+ if (!entry) {
+ callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>());
+ return;
+ }
+
+ callback.Run(error, entry.Pass());
+}
+
// OAuth2 scopes for the documents API.
const char kDocsListScope[] = "https://docs.google.com/feeds/";
const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/";
@@ -213,16 +235,17 @@ void GDataWapiService::GetResourceList(
void GDataWapiService::GetResourceEntry(
const std::string& resource_id,
- const GetDataCallback& callback) {
+ const GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
runner_->StartOperationWithRetry(
- new GetResourceEntryOperation(operation_registry(),
- url_request_context_getter_,
- url_generator_,
- resource_id,
- callback));
+ new GetResourceEntryOperation(
+ operation_registry(),
+ url_request_context_getter_,
+ url_generator_,
+ resource_id,
+ base::Bind(&ParseResourceEntryAndRun, callback)));
}
void GDataWapiService::GetAccountMetadata(const GetDataCallback& callback) {
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.h ('k') | chrome/browser/google_apis/mock_drive_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698