Commit 69bd6de5 authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Fire the callback for all code paths for ChangeListLoader::LoadIfNeeded.

Previously the passed callback was only called if we actually decided
to do the load, now we always call it. This is to support chaining
together async loading operations. I have no insight into why the
callback is dropped in the original code.

Bug: 715355
Change-Id: I5c40f862c0894ce5261880482b5da87ccaf6edfa
Reviewed-on: https://chromium-review.googlesource.com/1098737
Commit-Queue: Stuart Langley <slangley@chromium.org>
Reviewed-by: default avatarSasha Morrissey <sashab@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567603}
parent 5cf52645
......@@ -198,6 +198,15 @@ TEST_F(ChangeListLoaderTest, Load) {
ResourceEntry entry;
EXPECT_EQ(FILE_ERROR_OK,
metadata_->GetResourceEntryByPath(file_path, &entry));
// Calling LoadIfNeeded a second time is a no-op, ensure that the
// callback is called.
error = FILE_ERROR_FAILED;
change_list_loader_->LoadIfNeeded(
google_apis::test_util::CreateCopyResultCallback(&error));
EXPECT_FALSE(change_list_loader_->IsRefreshing());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(FILE_ERROR_OK, error);
}
TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) {
......
......@@ -277,6 +277,9 @@ void ChangeListLoader::LoadIfNeeded(const FileOperationCallback& callback) {
// If the metadata is not yet loaded, start loading.
if (!loaded_ && !IsRefreshing())
Load(callback);
else
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, FILE_ERROR_OK));
}
void ChangeListLoader::Load(const FileOperationCallback& callback) {
......
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