Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2593)

Unified Diff: chrome/browser/chromeos/drive/file_system/search_operation.cc

Issue 16142003: Report all Drive search results even if resource metadata is not fully loaded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_system/search_operation.cc
diff --git a/chrome/browser/chromeos/drive/file_system/search_operation.cc b/chrome/browser/chromeos/drive/file_system/search_operation.cc
index 59fcff38bef7e30ed58b5417be47396a383a2462..a1d6b647509bd5382570744fa054e46d2468ac7c 100644
--- a/chrome/browser/chromeos/drive/file_system/search_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/search_operation.cc
@@ -39,28 +39,30 @@ FileError RefreshEntriesOnBlockingPool(
result->reserve(entries.size());
for (size_t i = 0; i < entries.size(); ++i) {
ResourceEntry entry = ConvertToResourceEntry(*entries[i]);
- base::FilePath drive_file_path;
- FileError error = resource_metadata->RefreshEntry(
- entry, &drive_file_path, &entry);
- if (error == FILE_ERROR_OK) {
- result->push_back(SearchResultInfo(drive_file_path, entry));
- } else if (error == FILE_ERROR_NOT_FOUND) {
- // The result is absent in local resource metadata. There are two cases:
+ const std::string id = entry.resource_id();
+ FileError error = resource_metadata->RefreshEntry(entry, NULL, &entry);
+ if (error == FILE_ERROR_NOT_FOUND) {
+ // The result is absent in local resource metadata. This can happen if
+ // the metadata is not synced to the latest server state yet. In that
+ // case, we temporarily add the file to the special "drive/other"
+ // directory in order to assign a path, which is needed to access the
+ // file through FileSystem API.
//
- // 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;
+ // It will be moved to the right place when the metadata gets synced
+ // in normal loading process in ChangeListProcessor.
+ entry.set_parent_resource_id(util::kDriveOtherDirSpecialResourceId);
+ error = resource_metadata->AddEntry(entry);
+
+ // FILE_ERROR_EXISTS may happen if we have already added the entry to
+ // "drive/other" once before. That's not an error.
+ if (error == FILE_ERROR_OK || error == FILE_ERROR_EXISTS)
+ error = resource_metadata->GetResourceEntryById(id, &entry);
}
+ // Other errors are fatal. Give up to return the search result.
+ if (error != FILE_ERROR_OK)
+ return error;
+ result->push_back(SearchResultInfo(resource_metadata->GetFilePath(id),
+ entry));
}
return FILE_ERROR_OK;
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698