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

Side by Side Diff: chrome/browser/chromeos/drive/change_list_loader.cc

Issue 13913012: Get rid of GetResourceList for ChangeListLoader::SearchFromServer method. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chromeos/drive/change_list_loader.h" 5 #include "chrome/browser/chromeos/drive/change_list_loader.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 base::Bind(&util::EmptyFileOperationCallback)); 255 base::Bind(&util::EmptyFileOperationCallback));
256 } else { 256 } else {
257 // The directory fast-fetch failed, but the change list loading may 257 // The directory fast-fetch failed, but the change list loading may
258 // succeed. Keep passing |callback| so it's run after the change list 258 // succeed. Keep passing |callback| so it's run after the change list
259 // loading is complete. 259 // loading is complete.
260 LoadChangeListFromServer( 260 LoadChangeListFromServer(
261 about_resource.Pass(), start_changestamp, callback); 261 about_resource.Pass(), start_changestamp, callback);
262 } 262 }
263 } 263 }
264 264
265 void ChangeListLoader::SearchFromServerAfterGetResourceList(
266 const LoadFeedListCallback& callback,
267 google_apis::GDataErrorCode status,
268 scoped_ptr<google_apis::ResourceList> resource_list) {
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
270 DCHECK(!callback.is_null());
271
272 DriveFileError error = util::GDataToDriveFileError(status);
273 if (error != DRIVE_FILE_OK) {
274 callback.Run(ScopedVector<ChangeList>(), error);
275 return;
276 }
277
278 DCHECK(resource_list);
279
280 ScopedVector<ChangeList> change_lists;
281 change_lists.push_back(new ChangeList(*resource_list));
282 callback.Run(change_lists.Pass(), DRIVE_FILE_OK);
283 }
284
265 void ChangeListLoader::OnGetAppList(google_apis::GDataErrorCode status, 285 void ChangeListLoader::OnGetAppList(google_apis::GDataErrorCode status,
266 scoped_ptr<google_apis::AppList> app_list) { 286 scoped_ptr<google_apis::AppList> app_list) {
267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
268 288
269 DriveFileError error = util::GDataToDriveFileError(status); 289 DriveFileError error = util::GDataToDriveFileError(status);
270 if (error != DRIVE_FILE_OK) 290 if (error != DRIVE_FILE_OK)
271 return; 291 return;
272 292
273 if (app_list.get()) { 293 if (app_list.get()) {
274 webapps_registry_->UpdateFromAppList(*app_list); 294 webapps_registry_->UpdateFromAppList(*app_list);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // Also notify the observers. 499 // Also notify the observers.
480 if (error == DRIVE_FILE_OK) { 500 if (error == DRIVE_FILE_OK) {
481 FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, 501 FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_,
482 OnDirectoryChanged(directory_path)); 502 OnDirectoryChanged(directory_path));
483 } 503 }
484 } 504 }
485 505
486 void ChangeListLoader::SearchFromServer( 506 void ChangeListLoader::SearchFromServer(
487 const std::string& search_query, 507 const std::string& search_query,
488 const GURL& next_feed, 508 const GURL& next_feed,
489 const LoadFeedListCallback& feed_load_callback) { 509 const LoadFeedListCallback& callback) {
490 DCHECK(!feed_load_callback.is_null()); 510 DCHECK(!callback.is_null());
491 511
492 scoped_ptr<LoadFeedParams> params(new LoadFeedParams); 512 if (next_feed.is_empty()) {
493 params->search_query = search_query; 513 // This is first request for the |search_query|.
494 params->feed_to_load = next_feed; 514 scheduler_->Search(
495 params->load_subsequent_feeds = false; 515 search_query,
496 LoadFromServer(params.Pass(), feed_load_callback); 516 base::Bind(&ChangeListLoader::SearchFromServerAfterGetResourceList,
517 weak_ptr_factory_.GetWeakPtr(), callback));
518 } else {
519 // There is the remaining result so fetch it.
520 scheduler_->ContinueGetResourceList(
521 next_feed,
522 base::Bind(&ChangeListLoader::SearchFromServerAfterGetResourceList,
523 weak_ptr_factory_.GetWeakPtr(), callback));
524 }
497 } 525 }
498 526
499 void ChangeListLoader::UpdateMetadataFromFeedAfterLoadFromServer( 527 void ChangeListLoader::UpdateMetadataFromFeedAfterLoadFromServer(
500 scoped_ptr<google_apis::AboutResource> about_resource, 528 scoped_ptr<google_apis::AboutResource> about_resource,
501 bool is_delta_feed, 529 bool is_delta_feed,
502 const FileOperationCallback& callback, 530 const FileOperationCallback& callback,
503 ScopedVector<ChangeList> change_lists, 531 ScopedVector<ChangeList> change_lists,
504 DriveFileError error) { 532 DriveFileError error) {
505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
506 DCHECK(!callback.is_null()); 534 DCHECK(!callback.is_null());
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 for (size_t i = 0; i < callbacks.size(); ++i) { 878 for (size_t i = 0; i < callbacks.size(); ++i) {
851 base::MessageLoopProxy::current()->PostTask( 879 base::MessageLoopProxy::current()->PostTask(
852 FROM_HERE, 880 FROM_HERE,
853 base::Bind(callbacks[i], error)); 881 base::Bind(callbacks[i], error));
854 } 882 }
855 pending_load_callback_.erase(it); 883 pending_load_callback_.erase(it);
856 } 884 }
857 } 885 }
858 886
859 } // namespace drive 887 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698