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

Unified Diff: chrome/browser/chromeos/drive/drive_api_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
Index: chrome/browser/chromeos/drive/drive_api_service.cc
diff --git a/chrome/browser/chromeos/drive/drive_api_service.cc b/chrome/browser/chromeos/drive/drive_api_service.cc
index 8fc4dc4e3ae66dd83292b245b573ff621961217f..eac87d08da26bfdba1d23f6b4c0b18b27d5e1c01 100644
--- a/chrome/browser/chromeos/drive/drive_api_service.cc
+++ b/chrome/browser/chromeos/drive/drive_api_service.cc
@@ -61,6 +61,39 @@ void ParseResourceListAndRun(
callback.Run(error, resource_list.Pass());
}
+// Parses the JSON value to ResourceEntry runs |callback|.
+void ParseResourceEntryAndRun(
+ const google_apis::GetResourceEntryCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<base::Value> value) {
+ DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!value) {
+ callback.Run(error, scoped_ptr<google_apis::ResourceEntry>());
+ return;
+ }
+
+ // Parsing FileResource is cheap enough to do on UI thread.
+ scoped_ptr<google_apis::FileResource> file_resource =
+ google_apis::FileResource::CreateFrom(*value);
+ if (!file_resource) {
+ callback.Run(google_apis::GDATA_PARSE_ERROR,
+ scoped_ptr<google_apis::ResourceEntry>());
+ return;
+ }
+
+ // Converting to ResourceEntry is cheap enough to do on UI thread.
+ scoped_ptr<google_apis::ResourceEntry> entry =
+ google_apis::ResourceEntry::CreateFromFileResource(*file_resource);
+ if (!entry) {
+ callback.Run(google_apis::GDATA_PARSE_ERROR,
+ scoped_ptr<google_apis::ResourceEntry>());
+ return;
+ }
+
+ callback.Run(error, entry.Pass());
+}
+
} // namespace
DriveAPIService::DriveAPIService(
@@ -184,7 +217,7 @@ void DriveAPIService::GetChangelist(
void DriveAPIService::GetResourceEntry(
const std::string& resource_id,
- const google_apis::GetDataCallback& callback) {
+ const google_apis::GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
@@ -192,7 +225,7 @@ void DriveAPIService::GetResourceEntry(
operation_registry(),
url_request_context_getter_,
resource_id,
- callback));
+ base::Bind(&ParseResourceEntryAndRun, callback)));
}
void DriveAPIService::GetAccountMetadata(
« no previous file with comments | « chrome/browser/chromeos/drive/drive_api_service.h ('k') | chrome/browser/chromeos/drive/drive_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698