summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/drive/file_system.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/drive/file_system.cc')
-rw-r--r--chrome/browser/chromeos/drive/file_system.cc93
1 files changed, 13 insertions, 80 deletions
diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc
index bfffa60..d7c2d70 100644
--- a/chrome/browser/chromeos/drive/file_system.cc
+++ b/chrome/browser/chromeos/drive/file_system.cc
@@ -1213,84 +1213,18 @@ void FileSystem::OnGetAboutResource(
about_resource->quota_bytes_used());
}
-void FileSystem::OnSearch(const SearchCallback& search_callback,
- ScopedVector<ChangeList> change_lists,
- FileError error) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!search_callback.is_null());
-
- if (error != FILE_ERROR_OK) {
- search_callback.Run(error,
- GURL(),
- scoped_ptr<std::vector<SearchResultInfo> >());
- return;
- }
-
- // The search results will be returned using virtual directory.
- // The directory is not really part of the file system, so it has no parent or
- // root.
- std::vector<SearchResultInfo>* results(new std::vector<SearchResultInfo>());
- scoped_ptr<std::vector<SearchResultInfo> > result_vec(results);
-
- DCHECK_EQ(1u, change_lists.size());
- const ChangeList* change_list = change_lists[0];
-
- // TODO(tbarzic): Limit total number of returned results for the query.
- const GURL& next_feed = change_list->next_url();
-
- const base::Closure callback = base::Bind(
- search_callback, FILE_ERROR_OK, next_feed, base::Passed(&result_vec));
-
- const std::vector<ResourceEntry>& entries = change_list->entries();
- if (entries.empty()) {
- callback.Run();
- return;
- }
-
- DVLOG(1) << "OnSearch number of entries=" << entries.size();
- // Go through all entries generated by the feed and add them to the search
- // result directory.
- for (size_t i = 0; i < entries.size(); ++i) {
- // Run the callback if this is the last iteration of the loop.
- const bool should_run_callback = (i + 1 == entries.size());
- const ResourceEntry& entry = entries[i];
-
- const GetEntryInfoWithFilePathCallback entry_info_callback =
- base::Bind(&FileSystem::AddToSearchResults,
- weak_ptr_factory_.GetWeakPtr(),
- results,
- should_run_callback,
- callback);
-
- resource_metadata_->RefreshEntryOnUIThread(entry, entry_info_callback);
- }
-}
-
-void FileSystem::AddToSearchResults(
- std::vector<SearchResultInfo>* results,
- bool should_run_callback,
- const base::Closure& callback,
- FileError error,
- const base::FilePath& drive_file_path,
- scoped_ptr<ResourceEntry> entry) {
+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 a result is not present in our local file system snapshot, call
- // CheckForUpdates to refresh the snapshot with a delta feed. This may happen
- // if the entry has recently been added to the drive (and we still haven't
- // received its delta feed).
- if (error == FILE_ERROR_OK) {
- DCHECK(entry.get());
- results->push_back(SearchResultInfo(drive_file_path, *entry.get()));
- DVLOG(1) << "AddToSearchResults " << drive_file_path.value();
- } else if (error == FILE_ERROR_NOT_FOUND) {
+ if (is_update_needed)
CheckForUpdates();
- } else {
- NOTREACHED();
- }
- if (should_run_callback)
- callback.Run();
+ callback.Run(error, next_feed, result.Pass());
}
void FileSystem::Search(const std::string& search_query,
@@ -1299,12 +1233,11 @@ void FileSystem::Search(const std::string& search_query,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- change_list_loader_->SearchFromServer(
- search_query,
- next_feed,
- base::Bind(&FileSystem::OnSearch,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
+ drive_operations_.Search(search_query,
+ next_feed,
+ base::Bind(&FileSystem::OnSearch,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
}
void FileSystem::SearchMetadata(const std::string& query,