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

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

Issue 14146006: Refactoring: replace SearchInDirectory by SearchByTitle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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/drive_api_service.cc
diff --git a/chrome/browser/google_apis/drive_api_service.cc b/chrome/browser/google_apis/drive_api_service.cc
index f10c130afb75e7820aeaa998e85c7893de7928bd..547931580bd00f57d4660b088bd524b723fd2713 100644
--- a/chrome/browser/google_apis/drive_api_service.cc
+++ b/chrome/browser/google_apis/drive_api_service.cc
@@ -349,25 +349,30 @@ void DriveAPIService::Search(const std::string& search_query,
base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback)));
}
-void DriveAPIService::SearchInDirectory(
- const std::string& search_query,
+void DriveAPIService::SearchByTitle(
+ const std::string& title,
const std::string& directory_resource_id,
const GetResourceListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!search_query.empty());
- DCHECK(!directory_resource_id.empty());
+ DCHECK(!title.empty());
DCHECK(!callback.is_null());
+ std::string query;
+ base::StringAppendF(&query, "title contains '%s'",
+ drive::util::EscapeQueryStringValue(title).c_str());
+ if (!directory_resource_id.empty()) {
+ base::StringAppendF(
+ &query, " and '%s' in parents",
+ drive::util::EscapeQueryStringValue(directory_resource_id).c_str());
+ }
+ query += " and trashed = false";
+
runner_->StartOperationWithRetry(
new GetFilelistOperation(
operation_registry(),
url_request_context_getter_,
url_generator_,
- base::StringPrintf(
- "%s and '%s' in parents and trashed = false",
- search_query.c_str(),
- drive::util::EscapeQueryStringValue(
- directory_resource_id).c_str()),
+ query,
kMaxNumFilesResourcePerRequest,
base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback)));
}
« no previous file with comments | « chrome/browser/google_apis/drive_api_service.h ('k') | chrome/browser/google_apis/drive_service_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698