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

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

Issue 14838003: Try fast-fetch rather than full fetch if drive::FileSystem::GetEntryInfo failed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « chrome/browser/chromeos/drive/file_system.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_system.cc
diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc
index 8dbcec9d68617709560947fbb43e6d1e73bdb911..786ee03272d4990fc10d3279375dec36bbab61b7 100644
--- a/chrome/browser/chromeos/drive/file_system.cc
+++ b/chrome/browser/chromeos/drive/file_system.cc
@@ -663,11 +663,10 @@ void FileSystem::GetEntryInfoByPathAfterGetEntry1(
return;
}
- // Start loading if needed. Note that directory_fetch_info is empty here,
- // as we don't need to fetch the contents of a directory when we just need
- // to get an entry of the directory.
- change_list_loader_->LoadIfNeeded(
- DirectoryFetchInfo(),
+ // If the information about the path is not in the local ResourceMetadata,
+ // try fetching information of the directory and retry.
+ LoadDirectoryIfNeeded(
+ file_path.DirName(),
base::Bind(&FileSystem::GetEntryInfoByPathAfterLoad,
weak_ptr_factory_.GetWeakPtr(),
file_path,
@@ -715,40 +714,46 @@ void FileSystem::ReadDirectoryByPath(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
+ LoadDirectoryIfNeeded(
+ directory_path,
+ base::Bind(&FileSystem::ReadDirectoryByPathAfterLoad,
+ weak_ptr_factory_.GetWeakPtr(),
+ directory_path,
+ callback));
+}
+
+void FileSystem::LoadDirectoryIfNeeded(const base::FilePath& directory_path,
+ const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
// As described in GetEntryInfoByPath(), ResourceMetadata may know
// about the entry even if the file system is not yet fully loaded, hence we
// should just ask ResourceMetadata first.
resource_metadata_->GetEntryInfoByPath(
directory_path,
- base::Bind(&FileSystem::ReadDirectoryByPathAfterGetEntry,
+ base::Bind(&FileSystem::LoadDirectoryIfNeededAfterGetEntry,
weak_ptr_factory_.GetWeakPtr(),
directory_path,
callback));
}
-void FileSystem::ReadDirectoryByPathAfterGetEntry(
+void FileSystem::LoadDirectoryIfNeededAfterGetEntry(
const base::FilePath& directory_path,
- const ReadDirectoryWithSettingCallback& callback,
+ const FileOperationCallback& callback,
FileError error,
scoped_ptr<DriveEntryProto> entry_proto) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (error != FILE_ERROR_OK) {
- // If we don't know about the directory, start loading.
- change_list_loader_->LoadIfNeeded(
- DirectoryFetchInfo(),
- base::Bind(&FileSystem::ReadDirectoryByPathAfterLoad,
- weak_ptr_factory_.GetWeakPtr(),
- directory_path,
- callback));
+ // If we don't know about the directory, start loading full feed.
satorux1 2013/05/02 04:42:38 full feed -> full resource list.
kinaba 2013/05/02 11:32:11 Done.
+ change_list_loader_->LoadIfNeeded(DirectoryFetchInfo(), callback);
return;
}
if (!entry_proto->file_info().is_directory()) {
- callback.Run(FILE_ERROR_NOT_A_DIRECTORY,
- hide_hosted_docs_,
- scoped_ptr<DriveEntryProtoVector>());
+ callback.Run(FILE_ERROR_NOT_A_DIRECTORY);
return;
}
@@ -757,12 +762,7 @@ void FileSystem::ReadDirectoryByPathAfterGetEntry(
DirectoryFetchInfo directory_fetch_info(
entry_proto->resource_id(),
entry_proto->directory_specific_info().changestamp());
- change_list_loader_->LoadIfNeeded(
- directory_fetch_info,
- base::Bind(&FileSystem::ReadDirectoryByPathAfterLoad,
- weak_ptr_factory_.GetWeakPtr(),
- directory_path,
- callback));
+ change_list_loader_->LoadIfNeeded(directory_fetch_info, callback);
}
void FileSystem::ReadDirectoryByPathAfterLoad(
« no previous file with comments | « chrome/browser/chromeos/drive/file_system.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698