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/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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 void ChangeListLoader::LoadIfNeeded( | 502 void ChangeListLoader::LoadIfNeeded( |
503 const DirectoryFetchInfo& directory_fetch_info, | 503 const DirectoryFetchInfo& directory_fetch_info, |
504 const FileOperationCallback& callback) { | 504 const FileOperationCallback& callback) { |
505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
506 DCHECK(!callback.is_null()); | 506 DCHECK(!callback.is_null()); |
507 | 507 |
508 // If feed has already been loaded, for normal feed fetch (= empty | 508 // If feed has already been loaded, for normal feed fetch (= empty |
509 // directory_fetch_info), we have nothing to do. For "fast fetch", we need to | 509 // directory_fetch_info), we have nothing to do. For "fast fetch", we need to |
510 // schedule a fetching if a feed refresh is currently running, because we | 510 // schedule a fetching if a feed refresh is currently running, because we |
511 // don't want to wait a possibly large delta feed to arrive. | 511 // don't want to wait a possibly large delta feed to arrive. |
512 if (loaded() && (directory_fetch_info.empty() || !IsRefreshing())) { | 512 if (loaded_ && (directory_fetch_info.empty() || !IsRefreshing())) { |
513 base::MessageLoopProxy::current()->PostTask( | 513 base::MessageLoopProxy::current()->PostTask( |
514 FROM_HERE, | 514 FROM_HERE, |
515 base::Bind(callback, DRIVE_FILE_OK)); | 515 base::Bind(callback, DRIVE_FILE_OK)); |
516 return; | 516 return; |
517 } | 517 } |
518 Load(directory_fetch_info, callback); | 518 Load(directory_fetch_info, callback); |
519 } | 519 } |
520 | 520 |
521 void ChangeListLoader::Load(const DirectoryFetchInfo& directory_fetch_info, | 521 void ChangeListLoader::Load(const DirectoryFetchInfo& directory_fetch_info, |
522 const FileOperationCallback& callback) { | 522 const FileOperationCallback& callback) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 base::Bind(&ChangeListLoader::OnDirectoryLoadComplete, | 596 base::Bind(&ChangeListLoader::OnDirectoryLoadComplete, |
597 weak_ptr_factory_.GetWeakPtr(), | 597 weak_ptr_factory_.GetWeakPtr(), |
598 directory_fetch_info)); | 598 directory_fetch_info)); |
599 } | 599 } |
600 } | 600 } |
601 | 601 |
602 void ChangeListLoader::CheckForUpdates(const FileOperationCallback& callback) { | 602 void ChangeListLoader::CheckForUpdates(const FileOperationCallback& callback) { |
603 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 603 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
604 DCHECK(!callback.is_null()); | 604 DCHECK(!callback.is_null()); |
605 | 605 |
606 if (loaded() && !IsRefreshing()) | 606 if (loaded_ && !IsRefreshing()) |
607 Load(DirectoryFetchInfo(), callback); | 607 Load(DirectoryFetchInfo(), callback); |
608 } | 608 } |
609 | 609 |
610 void ChangeListLoader::UpdateFromFeed( | 610 void ChangeListLoader::UpdateFromFeed( |
611 scoped_ptr<google_apis::AboutResource> about_resource, | 611 scoped_ptr<google_apis::AboutResource> about_resource, |
612 ScopedVector<ChangeList> change_lists, | 612 ScopedVector<ChangeList> change_lists, |
613 bool is_delta_feed, | 613 bool is_delta_feed, |
614 const base::Closure& update_finished_callback) { | 614 const base::Closure& update_finished_callback) { |
615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
616 DCHECK(!update_finished_callback.is_null()); | 616 DCHECK(!update_finished_callback.is_null()); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 for (size_t i = 0; i < callbacks.size(); ++i) { | 732 for (size_t i = 0; i < callbacks.size(); ++i) { |
733 base::MessageLoopProxy::current()->PostTask( | 733 base::MessageLoopProxy::current()->PostTask( |
734 FROM_HERE, | 734 FROM_HERE, |
735 base::Bind(callbacks[i], error)); | 735 base::Bind(callbacks[i], error)); |
736 } | 736 } |
737 pending_load_callback_.erase(it); | 737 pending_load_callback_.erase(it); |
738 } | 738 } |
739 } | 739 } |
740 | 740 |
741 } // namespace drive | 741 } // namespace drive |
OLD | NEW |