| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/google_apis/drive_api_service.h" | 5 #include "chrome/browser/google_apis/drive_api_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 runner_->StartOperationWithRetry( | 334 runner_->StartOperationWithRetry( |
| 335 new GetFilelistOperation( | 335 new GetFilelistOperation( |
| 336 operation_registry(), | 336 operation_registry(), |
| 337 url_request_context_getter_, | 337 url_request_context_getter_, |
| 338 url_generator_, | 338 url_generator_, |
| 339 search_query, | 339 search_query, |
| 340 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); | 340 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); |
| 341 } | 341 } |
| 342 | 342 |
| 343 void DriveAPIService::SearchInDirectory( | 343 void DriveAPIService::SearchByTitle( |
| 344 const std::string& search_query, | 344 const std::string& title, |
| 345 const std::string& directory_resource_id, | 345 const std::string& directory_resource_id, |
| 346 const GetResourceListCallback& callback) { | 346 const GetResourceListCallback& callback) { |
| 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 348 DCHECK(!search_query.empty()); | 348 DCHECK(!title.empty()); |
| 349 DCHECK(!directory_resource_id.empty()); | |
| 350 DCHECK(!callback.is_null()); | 349 DCHECK(!callback.is_null()); |
| 351 | 350 |
| 351 std::string query; |
| 352 base::StringAppendF(&query, "title contains '%s'", |
| 353 drive::util::EscapeQueryStringValue(title).c_str()); |
| 354 if (!directory_resource_id.empty()) { |
| 355 base::StringAppendF( |
| 356 &query, " and '%s' in parents", |
| 357 drive::util::EscapeQueryStringValue(directory_resource_id).c_str()); |
| 358 } |
| 359 query += " and trashed = false"; |
| 360 |
| 352 runner_->StartOperationWithRetry( | 361 runner_->StartOperationWithRetry( |
| 353 new GetFilelistOperation( | 362 new GetFilelistOperation( |
| 354 operation_registry(), | 363 operation_registry(), |
| 355 url_request_context_getter_, | 364 url_request_context_getter_, |
| 356 url_generator_, | 365 url_generator_, |
| 357 base::StringPrintf( | 366 query, |
| 358 "%s and '%s' in parents and trashed = false", | |
| 359 search_query.c_str(), | |
| 360 drive::util::EscapeQueryStringValue( | |
| 361 directory_resource_id).c_str()), | |
| 362 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); | 367 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); |
| 363 } | 368 } |
| 364 | 369 |
| 365 void DriveAPIService::GetChangeList(int64 start_changestamp, | 370 void DriveAPIService::GetChangeList(int64 start_changestamp, |
| 366 const GetResourceListCallback& callback) { | 371 const GetResourceListCallback& callback) { |
| 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 372 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 368 DCHECK(!callback.is_null()); | 373 DCHECK(!callback.is_null()); |
| 369 | 374 |
| 370 runner_->StartOperationWithRetry( | 375 runner_->StartOperationWithRetry( |
| 371 new GetChangelistOperation( | 376 new GetChangelistOperation( |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 } | 718 } |
| 714 | 719 |
| 715 void DriveAPIService::OnProgressUpdate( | 720 void DriveAPIService::OnProgressUpdate( |
| 716 const OperationProgressStatusList& list) { | 721 const OperationProgressStatusList& list) { |
| 717 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 718 FOR_EACH_OBSERVER( | 723 FOR_EACH_OBSERVER( |
| 719 DriveServiceObserver, observers_, OnProgressUpdate(list)); | 724 DriveServiceObserver, observers_, OnProgressUpdate(list)); |
| 720 } | 725 } |
| 721 | 726 |
| 722 } // namespace google_apis | 727 } // namespace google_apis |
| OLD | NEW |