Commit adcb4569 authored by satorux@chromium.org's avatar satorux@chromium.org

drive: Minor cleanup around ChangeListLoader::LoadFromServerIfNeeded()

Add ChangeListLoader::CheckForUpdates()
Make ChangeListLoader::LoadFromServerIfNeeded() private.

BUG=193417
TEST=Open Drive in Files.app; Ctrl-click-on the gear menu and select 'Reload'. Confirm that the files appear shortly.

Review URL: https://codereview.chromium.org/14292002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194496 0039d316-1c4b-4281-b951-d872f2087c98
parent 9be4e08b
......@@ -646,6 +646,15 @@ void ChangeListLoader::CheckLocalChangestamp(
resource_metadata_->GetLargestChangestamp(callback);
}
void ChangeListLoader::CheckForUpdates(const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (loaded() && !refreshing())
LoadFromServerIfNeeded(DirectoryFetchInfo(), callback);
}
void ChangeListLoader::UpdateFromFeed(
scoped_ptr<google_apis::AboutResource> about_resource,
ScopedVector<ChangeList> change_lists,
......
......@@ -88,13 +88,9 @@ class ChangeListLoader {
const GURL& next_feed,
const LoadFeedListCallback& callback);
// Initiates the change list loading from the server if the local
// changestamp is older than the server changestamp.
// See the comment at Load() for |directory_fetch_info| parameter.
// |callback| must not be null.
// TODO(satorux): make this private. crbug.com/193417
void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info,
const FileOperationCallback& callback);
// Checks for updates on the server. Does nothing if the change list is now
// being loaded or refreshed. |callback| must not be null.
void CheckForUpdates(const FileOperationCallback& callback);
// Updates whole directory structure feeds collected in |feed_list|.
// Record file statistics as UMA histograms.
......@@ -111,6 +107,13 @@ class ChangeListLoader {
bool refreshing() const { return refreshing_; }
private:
// Initiates the change list loading from the server if the local
// changestamp is older than the server changestamp.
// See the comment at Load() for |directory_fetch_info| parameter.
// |callback| must not be null.
void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info,
const FileOperationCallback& callback);
// Checks the local changestamp. |callback| must not be null.
void CheckLocalChangestamp(const GetChangestampCallback& callback);
......
......@@ -257,7 +257,7 @@ void DriveFileSystem::Initialize() {
void DriveFileSystem::ReloadAfterReset() {
SetupChangeListLoader();
change_list_loader_->LoadFromServerIfNeeded(
change_list_loader_->LoadIfNeeded(
DirectoryFetchInfo(),
base::Bind(&DriveFileSystem::OnUpdateChecked,
weak_ptr_factory_.GetWeakPtr()));
......@@ -271,15 +271,11 @@ void DriveFileSystem::SetupChangeListLoader() {
}
void DriveFileSystem::CheckForUpdates() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DVLOG(1) << "CheckForUpdates";
if (change_list_loader_ &&
change_list_loader_->loaded() &&
!change_list_loader_->refreshing()) {
change_list_loader_->LoadFromServerIfNeeded(
DirectoryFetchInfo(),
if (change_list_loader_) {
change_list_loader_->CheckForUpdates(
base::Bind(&DriveFileSystem::OnUpdateChecked,
weak_ptr_factory_.GetWeakPtr()));
}
......
......@@ -187,7 +187,7 @@ class DriveFileSystemTest : public testing::Test {
// Loads test json file as root ("/drive") element.
bool LoadRootFeedDocument() {
DriveFileError error = DRIVE_FILE_ERROR_FAILED;
file_system_->change_list_loader()->LoadFromServerIfNeeded(
file_system_->change_list_loader()->LoadIfNeeded(
DirectoryFetchInfo(),
google_apis::test_util::CreateCopyResultCallback(&error));
google_apis::test_util::RunBlockingPoolTask();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment