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

Unified Diff: chrome/browser/drive/drive_api_service.cc

Issue 305913002: drive: Replace GetResourceListCallback in DriveServiceInterface with FileListCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « chrome/browser/drive/drive_api_service.h ('k') | chrome/browser/drive/drive_service_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_api_service.cc
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc
index 4df202de9a004cdc7e3eda87e2ffa020ac7bf4c5..e49ba16596beaaf85c6523b81d307c3ddc21a2c5 100644
--- a/chrome/browser/drive/drive_api_service.cc
+++ b/chrome/browser/drive/drive_api_service.cc
@@ -25,6 +25,7 @@
#include "net/url_request/url_request_context_getter.h"
using content::BrowserThread;
+using google_apis::AboutResourceCallback;
using google_apis::AppList;
using google_apis::AppListCallback;
using google_apis::AuthStatusCallback;
@@ -35,15 +36,14 @@ using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback;
using google_apis::EntryActionCallback;
using google_apis::FileList;
+using google_apis::FileListCallback;
using google_apis::FileResource;
using google_apis::GDATA_OTHER_ERROR;
using google_apis::GDATA_PARSE_ERROR;
using google_apis::GDataErrorCode;
-using google_apis::AboutResourceCallback;
using google_apis::GetContentCallback;
using google_apis::GetResourceEntryCallback;
using google_apis::GetResourceEntryRequest;
-using google_apis::GetResourceListCallback;
using google_apis::GetShareUrlCallback;
using google_apis::HTTP_NOT_IMPLEMENTED;
using google_apis::HTTP_SUCCESS;
@@ -52,7 +52,6 @@ using google_apis::Link;
using google_apis::ProgressCallback;
using google_apis::RequestSender;
using google_apis::ResourceEntry;
-using google_apis::ResourceList;
using google_apis::UploadRangeCallback;
using google_apis::UploadRangeResponse;
using google_apis::drive::AboutGetRequest;
@@ -123,15 +122,6 @@ const char kChangeListFields[] =
"parents/parentLink,alternateLink,modifiedDate,lastViewedByMeDate,shared),"
"deleted,id,fileId,modificationDate),nextLink,largestChangeId";
-// Callback invoked when the parsing of resource list is completed,
-// regardless whether it is succeeded or not.
-void DidConvertToResourceListOnBlockingPool(
- const GetResourceListCallback& callback,
- scoped_ptr<ResourceList> resource_list) {
- GDataErrorCode error = resource_list ? HTTP_SUCCESS : GDATA_PARSE_ERROR;
- callback.Run(error, resource_list.Pass());
-}
-
// Converts the FileResource value to ResourceEntry and runs |callback| on the
// UI thread.
void ConvertFileEntryToResourceEntryAndRun(
@@ -157,35 +147,6 @@ void ConvertFileEntryToResourceEntryAndRun(
callback.Run(error, entry.Pass());
}
-// Thin adapter of ConvertFileListToResourceList.
-scoped_ptr<ResourceList> ConvertFileListToResourceList(
- scoped_ptr<FileList> file_list) {
- return util::ConvertFileListToResourceList(*file_list);
-}
-
-// Converts the FileList value to ResourceList on blocking pool and runs
-// |callback| on the UI thread.
-void ConvertFileListToResourceListOnBlockingPoolAndRun(
- scoped_refptr<base::TaskRunner> blocking_task_runner,
- const GetResourceListCallback& callback,
- GDataErrorCode error,
- scoped_ptr<FileList> value) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
-
- if (!value) {
- callback.Run(error, scoped_ptr<ResourceList>());
- return;
- }
-
- // Convert the value on blocking pool.
- base::PostTaskAndReplyWithResult(
- blocking_task_runner.get(),
- FROM_HERE,
- base::Bind(&ConvertFileListToResourceList, base::Passed(&value)),
- base::Bind(&DidConvertToResourceListOnBlockingPool, callback));
-}
-
// Converts the FileResource value to ResourceEntry for upload range request,
// and runs |callback| on the UI thread.
void ConvertFileResourceToResourceEntryForUploadRangeAndRun(
@@ -283,7 +244,7 @@ void DriveAPIService::Initialize(const std::string& account_id) {
scopes.push_back(kDriveAppsReadonlyScope);
scopes.push_back(util::kDriveAppsScope);
- // GData WAPI token for GetShareUrl() and GetResourceListInDirectoryByWapi().
+ // GData WAPI token for GetShareUrl().
scopes.push_back(util::kDocsListScope);
sender_.reset(new RequestSender(
@@ -319,24 +280,22 @@ std::string DriveAPIService::GetRootResourceId() const {
return kDriveApiRootDirectoryResourceId;
}
-CancelCallback DriveAPIService::GetAllResourceList(
- const GetResourceListCallback& callback) {
+CancelCallback DriveAPIService::GetAllFileList(
+ const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
FilesListRequest* request = new FilesListRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
- blocking_task_runner_, callback));
+ sender_.get(), url_generator_, callback);
request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q("trashed = false"); // Exclude trashed files.
request->set_fields(kFileListFields);
return sender_->StartRequestWithRetry(request);
}
-CancelCallback DriveAPIService::GetResourceListInDirectory(
+CancelCallback DriveAPIService::GetFileListInDirectory(
const std::string& directory_resource_id,
- const GetResourceListCallback& callback) {
+ const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!directory_resource_id.empty());
DCHECK(!callback.is_null());
@@ -349,9 +308,7 @@ CancelCallback DriveAPIService::GetResourceListInDirectory(
// to client side.
// We aren't interested in files in trash in this context, neither.
FilesListRequest* request = new FilesListRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
- blocking_task_runner_, callback));
+ sender_.get(), url_generator_, callback);
request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q(base::StringPrintf(
"'%s' in parents and trashed = false",
@@ -362,15 +319,13 @@ CancelCallback DriveAPIService::GetResourceListInDirectory(
CancelCallback DriveAPIService::Search(
const std::string& search_query,
- const GetResourceListCallback& callback) {
+ const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!search_query.empty());
DCHECK(!callback.is_null());
FilesListRequest* request = new FilesListRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
- blocking_task_runner_, callback));
+ sender_.get(), url_generator_, callback);
request->set_max_results(kMaxNumFilesResourcePerRequestForSearch);
request->set_q(drive::util::TranslateQuery(search_query));
request->set_fields(kFileListFields);
@@ -380,7 +335,7 @@ CancelCallback DriveAPIService::Search(
CancelCallback DriveAPIService::SearchByTitle(
const std::string& title,
const std::string& directory_resource_id,
- const GetResourceListCallback& callback) {
+ const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!title.empty());
DCHECK(!callback.is_null());
@@ -396,9 +351,7 @@ CancelCallback DriveAPIService::SearchByTitle(
query += " and trashed = false";
FilesListRequest* request = new FilesListRequest(
- sender_.get(), url_generator_,
- base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
- blocking_task_runner_, callback));
+ sender_.get(), url_generator_, callback);
request->set_max_results(kMaxNumFilesResourcePerRequest);
request->set_q(query);
request->set_fields(kFileListFields);
@@ -435,15 +388,13 @@ CancelCallback DriveAPIService::GetRemainingChangeList(
CancelCallback DriveAPIService::GetRemainingFileList(
const GURL& next_link,
- const GetResourceListCallback& callback) {
+ const FileListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!next_link.is_empty());
DCHECK(!callback.is_null());
FilesListNextPageRequest* request = new FilesListNextPageRequest(
- sender_.get(),
- base::Bind(&ConvertFileListToResourceListOnBlockingPoolAndRun,
- blocking_task_runner_, callback));
+ sender_.get(), callback);
request->set_next_link(next_link);
request->set_fields(kFileListFields);
return sender_->StartRequestWithRetry(request);
« no previous file with comments | « chrome/browser/drive/drive_api_service.h ('k') | chrome/browser/drive/drive_service_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698