summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 16:31:35 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 16:31:35 +0000
commitba268ed9dafa05d0343a0cb794e37de39681ac24 (patch)
tree2f08517a742942530db618160f661d88e2592703
parentcd2434bc3b2f3fb3ad29afb2c13e22fd1ac6c988 (diff)
downloadchromium_src-ba268ed9dafa05d0343a0cb794e37de39681ac24.zip
chromium_src-ba268ed9dafa05d0343a0cb794e37de39681ac24.tar.gz
chromium_src-ba268ed9dafa05d0343a0cb794e37de39681ac24.tar.bz2
Remove CheckForUpdates hack in Drive Search.
It was added in the old days of Drive integration that did not synced the file list in a timely manner. Since the latest implementation automatically calls CheckForUpdates when notified, we don't need to call it here explicitly anymore. BUG=243641 Review URL: https://chromiumcodereview.appspot.com/15965003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202106 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/file_system.cc20
-rw-r--r--chrome/browser/chromeos/drive/file_system.h7
-rw-r--r--chrome/browser/chromeos/drive/file_system/drive_operations.h5
-rw-r--r--chrome/browser/chromeos/drive/file_system/search_operation.cc40
-rw-r--r--chrome/browser/chromeos/drive/file_system/search_operation.h1
-rw-r--r--chrome/browser/chromeos/drive/file_system_unittest.cc16
6 files changed, 23 insertions, 66 deletions
diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc
index 975fbd5..9fa085a 100644
--- a/chrome/browser/chromeos/drive/file_system.cc
+++ b/chrome/browser/chromeos/drive/file_system.cc
@@ -1187,31 +1187,13 @@ void FileSystem::OnGetAboutResource(
about_resource->quota_bytes_used());
}
-void FileSystem::OnSearch(const SearchCallback& callback,
- FileError error,
- bool is_update_needed,
- const GURL& next_feed,
- scoped_ptr<std::vector<SearchResultInfo> > result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
-
- if (is_update_needed)
- CheckForUpdates();
-
- callback.Run(error, next_feed, result.Pass());
-}
-
void FileSystem::Search(const std::string& search_query,
const GURL& next_feed,
const SearchCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- drive_operations_.Search(search_query,
- next_feed,
- base::Bind(&FileSystem::OnSearch,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
+ drive_operations_.Search(search_query, next_feed, callback);
}
void FileSystem::SearchMetadata(const std::string& query,
diff --git a/chrome/browser/chromeos/drive/file_system.h b/chrome/browser/chromeos/drive/file_system.h
index d602caa..ed27234 100644
--- a/chrome/browser/chromeos/drive/file_system.h
+++ b/chrome/browser/chromeos/drive/file_system.h
@@ -185,13 +185,6 @@ class FileSystem : public FileSystemInterface,
// Called on preference change.
void OnDisableDriveHostedFilesChanged();
- // Part of Search(). Called after DriveOperations::Search is completed.
- void OnSearch(const SearchCallback& callback,
- FileError error,
- bool is_update_needed,
- const GURL& next_feed,
- scoped_ptr<std::vector<SearchResultInfo> > result);
-
// Part of CreateDirectory(). Called after ChangeListLoader::LoadIfNeeded()
// is called and made sure that the resource metadata is loaded.
void CreateDirectoryAfterLoad(const base::FilePath& directory_path,
diff --git a/chrome/browser/chromeos/drive/file_system/drive_operations.h b/chrome/browser/chromeos/drive/file_system/drive_operations.h
index 82ef73a..5355d0e 100644
--- a/chrome/browser/chromeos/drive/file_system/drive_operations.h
+++ b/chrome/browser/chromeos/drive/file_system/drive_operations.h
@@ -41,15 +41,12 @@ class UpdateOperation;
// Callback for DriveOperations::Search.
// On success, |error| is FILE_ERROR_OK, and remaining arguments are valid to
-// use. if |is_update_needed| is true, some mismatch is found between
-// the result from the server and local metadata, so the caller should update
-// the resource metadata.
+// use.
// |next_feed| is the URL to fetch the remaining result from the server. Maybe
// empty if there is no more results.
// On error, |error| is set to other than FILE_ERROR_OK, and the caller
// shouldn't use remaining arguments.
typedef base::Callback<void(FileError error,
- bool is_update_needed,
const GURL& next_feed,
scoped_ptr<std::vector<SearchResultInfo> > result)>
SearchOperationCallback;
diff --git a/chrome/browser/chromeos/drive/file_system/search_operation.cc b/chrome/browser/chromeos/drive/file_system/search_operation.cc
index a7084a2..59fcff3 100644
--- a/chrome/browser/chromeos/drive/file_system/search_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/search_operation.cc
@@ -26,16 +26,12 @@ namespace file_system {
namespace {
// Refreshes entries of |resource_metadata| based on |resource_list|, and
-// returns the result. |is_update_needed| will be set to true, if an
-// inconsistency is found between |resource_list| and |resource_metadata|.
-// Refreshed entries will be stored into |result|.
+// returns the result. Refreshed entries will be stored into |result|.
FileError RefreshEntriesOnBlockingPool(
internal::ResourceMetadata* resource_metadata,
scoped_ptr<google_apis::ResourceList> resource_list,
- bool* is_update_needed,
std::vector<SearchResultInfo>* result) {
DCHECK(resource_metadata);
- DCHECK(is_update_needed);
DCHECK(result);
const ScopedVector<google_apis::ResourceEntry>& entries =
@@ -49,13 +45,18 @@ FileError RefreshEntriesOnBlockingPool(
if (error == FILE_ERROR_OK) {
result->push_back(SearchResultInfo(drive_file_path, entry));
} else if (error == FILE_ERROR_NOT_FOUND) {
- // If a result is not present in our local resource metadata,
- // it is necessary to update the resource metadata.
- // This may happen if the entry has recently been added to the drive (and
- // we haven't received the delta update feed yet).
- // This is not a fatal error, so skip to add the result, but notify
- // the caller that the update is needed.
- *is_update_needed = true;
+ // The result is absent in local resource metadata. There are two cases:
+ //
+ // 1) Resource metadata is not up-to-date, and the entry has recently
+ // been added to the drive. This is not a fatal error, so just skip to
+ // add the result. We should soon receive XMPP update notification
+ // and refresh both the metadata and search result UI in Files.app.
+ //
+ // 2) Resource metadata is not fully loaded.
+ // TODO(kinaba) crbug.com/181075:
+ // In this case, we are doing "fast fetch" fetching directory lists on
+ // the fly to quickly deliver results to the user. However, we have no
+ // such equivalent for Search.
} else {
// Otherwise, it is a fatal error. Give up to return the search result.
return error;
@@ -110,8 +111,7 @@ void SearchOperation::SearchAfterGetResourceList(
FileError error = util::GDataToFileError(gdata_error);
if (error != FILE_ERROR_OK) {
- callback.Run(
- error, false, GURL(), scoped_ptr<std::vector<SearchResultInfo> >());
+ callback.Run(error, GURL(), scoped_ptr<std::vector<SearchResultInfo> >());
return;
}
@@ -128,11 +128,10 @@ void SearchOperation::SearchAfterGetResourceList(
if (resource_list->entries().empty()) {
// Short cut. If the resource entry is empty, we don't need to refresh
// the resource metadata.
- callback.Run(FILE_ERROR_OK, false, next_feed, result.Pass());
+ callback.Run(FILE_ERROR_OK, next_feed, result.Pass());
return;
}
- bool* is_update_needed = new bool(false);
std::vector<SearchResultInfo>* result_ptr = result.get();
base::PostTaskAndReplyWithResult(
blocking_task_runner_,
@@ -140,34 +139,29 @@ void SearchOperation::SearchAfterGetResourceList(
base::Bind(&RefreshEntriesOnBlockingPool,
metadata_,
base::Passed(&resource_list),
- is_update_needed,
result_ptr),
base::Bind(&SearchOperation::SearchAfterRefreshEntry,
weak_ptr_factory_.GetWeakPtr(),
callback,
next_feed,
- base::Owned(is_update_needed),
base::Passed(&result)));
}
void SearchOperation::SearchAfterRefreshEntry(
const SearchOperationCallback& callback,
const GURL& next_feed,
- bool* is_update_needed,
scoped_ptr<std::vector<SearchResultInfo> > result,
FileError error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- DCHECK(is_update_needed);
DCHECK(result);
if (error != FILE_ERROR_OK) {
- callback.Run(
- error, false, GURL(), scoped_ptr<std::vector<SearchResultInfo> >());
+ callback.Run(error, GURL(), scoped_ptr<std::vector<SearchResultInfo> >());
return;
}
- callback.Run(error, *is_update_needed, next_feed, result.Pass());
+ callback.Run(error, next_feed, result.Pass());
}
} // namespace file_system
diff --git a/chrome/browser/chromeos/drive/file_system/search_operation.h b/chrome/browser/chromeos/drive/file_system/search_operation.h
index fe82543..f96dd4f 100644
--- a/chrome/browser/chromeos/drive/file_system/search_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/search_operation.h
@@ -62,7 +62,6 @@ class SearchOperation {
void SearchAfterRefreshEntry(
const SearchOperationCallback& callback,
const GURL& next_feed,
- bool* is_update_needed,
scoped_ptr<std::vector<SearchResultInfo> > result,
FileError error);
diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc
index c2129cc..5848e11 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -1766,7 +1766,7 @@ TEST_F(DriveFileSystemTest, ContentSearch) {
GURL());
file_system_->Search("Directory", GURL(), callback);
- message_loop_.Run(); // Wait to get our result.
+ google_apis::test_util::RunBlockingPoolTask();
}
TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) {
@@ -1780,22 +1780,16 @@ TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) {
"New Directory 1!",
google_apis::test_util::CreateCopyResultCallback(
&error, &resource_entry));
- message_loop_.RunUntilIdle();
+ google_apis::test_util::RunBlockingPoolTask();
// As the result of the first Search(), only entries in the current file
// system snapshot are expected to be returned (i.e. "New Directory 1!"
// shouldn't be included in the search result even though it matches
// "Directory 1".
const SearchResultPair kExpectedResults[] = {
- { "drive/root/Directory 1", true }
+ { "drive/root/Directory 1", true }
};
- // At the same time, unknown entry should trigger delta feed request.
- // This will cause notification to directory observers (e.g., File Browser)
- // so that they can request search again.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(_))
- .Times(AtLeast(1));
-
SearchCallback callback = base::Bind(
&DriveSearchCallback,
&message_loop_,
@@ -1803,8 +1797,6 @@ TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) {
GURL());
file_system_->Search("\"Directory 1\"", GURL(), callback);
- // Make sure all the delayed tasks to complete.
- // message_loop_.Run() can return before the delta feed processing finishes.
google_apis::test_util::RunBlockingPoolTask();
}
@@ -1821,7 +1813,7 @@ TEST_F(DriveFileSystemTest, ContentSearchEmptyResult) {
GURL());
file_system_->Search("\"no-match query\"", GURL(), callback);
- message_loop_.Run(); // Wait to get our result.
+ google_apis::test_util::RunBlockingPoolTask();
}
TEST_F(DriveFileSystemTest, GetAvailableSpace) {