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

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

Issue 118993002: drive: Move FileSystem::LoadDirectoryIfNeeded to ChangeListLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 b3eb49f35dc18cac6d4f37a8b9b0ff0b6fbe6512..8ceecdfe360644ecffb533d33ec7071fdc1c551f 100644
--- a/chrome/browser/chromeos/drive/file_system.cc
+++ b/chrome/browser/chromeos/drive/file_system.cc
@@ -9,7 +9,6 @@
#include "base/platform_file.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/chromeos/drive/change_list_loader.h"
-#include "chrome/browser/chromeos/drive/change_list_processor.h"
#include "chrome/browser/chromeos/drive/drive.pb.h"
#include "chrome/browser/chromeos/drive/file_cache.h"
#include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
@@ -243,24 +242,7 @@ void FileSystem::Reload(const FileOperationCallback& callback) {
blocking_task_runner_,
FROM_HERE,
base::Bind(&ResetOnBlockingPool, resource_metadata_, cache_),
- base::Bind(&FileSystem::ReloadAfterReset,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
-}
-
-void FileSystem::ReloadAfterReset(const FileOperationCallback& callback,
- FileError error) {
- if (error != FILE_ERROR_OK) {
- LOG(ERROR) << "Failed to reload Drive file system: "
- << FileErrorToString(error);
- callback.Run(error);
- return;
- }
-
- change_list_loader_->LoadIfNeeded(
- internal::DirectoryFetchInfo(),
- base::Bind(&FileSystem::OnUpdateChecked, weak_ptr_factory_.GetWeakPtr()));
- callback.Run(error);
+ callback);
kinaba 2013/12/20 04:54:14 drive-internals has a button labeled "Clear local
hashimoto 2013/12/20 06:29:29 Changed the text and renamed Reload() to Reset().
}
void FileSystem::ResetComponents() {
@@ -417,7 +399,7 @@ void FileSystem::CreateDirectory(
DCHECK(!callback.is_null());
// Ensure its parent directory is loaded to the local metadata.
- LoadDirectoryIfNeeded(
+ change_list_loader_->LoadDirectoryIfNeeded(
directory_path.DirName(),
base::Bind(&FileSystem::CreateDirectoryAfterLoad,
weak_ptr_factory_.GetWeakPtr(),
@@ -606,13 +588,8 @@ void FileSystem::GetResourceEntryAfterGetEntry(
if (error == FILE_ERROR_NOT_FOUND) {
// If the information about the path is not in the local ResourceMetadata,
// try fetching information of the directory and retry.
- //
- // Note: this forms mutual recursion between GetResourceEntry and
- // LoadDirectoryIfNeeded, because directory loading requires the existence
- // of directory entry itself. The recursion terminates because we always go
- // up the hierarchy by .DirName() bounded under the Drive root path.
if (util::GetDriveGrandRootPath().IsParent(file_path)) {
- LoadDirectoryIfNeeded(
+ change_list_loader_->LoadDirectoryIfNeeded(
file_path.DirName(),
base::Bind(&FileSystem::GetResourceEntryAfterLoad,
weak_ptr_factory_.GetWeakPtr(),
@@ -656,7 +633,7 @@ void FileSystem::ReadDirectory(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- LoadDirectoryIfNeeded(
+ change_list_loader_->LoadDirectoryIfNeeded(
directory_path,
base::Bind(&FileSystem::ReadDirectoryAfterLoad,
weak_ptr_factory_.GetWeakPtr(),
@@ -664,51 +641,6 @@ void FileSystem::ReadDirectory(
callback));
}
-void FileSystem::LoadDirectoryIfNeeded(const base::FilePath& directory_path,
- const FileOperationCallback& callback) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
-
- GetResourceEntry(
- directory_path,
- base::Bind(&FileSystem::LoadDirectoryIfNeededAfterGetEntry,
- weak_ptr_factory_.GetWeakPtr(),
- directory_path,
- callback));
-}
-
-void FileSystem::LoadDirectoryIfNeededAfterGetEntry(
- const base::FilePath& directory_path,
- const FileOperationCallback& callback,
- FileError error,
- scoped_ptr<ResourceEntry> entry) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
-
- if (error != FILE_ERROR_OK) {
- callback.Run(error);
- return;
- }
-
- if (!entry->file_info().is_directory()) {
- callback.Run(FILE_ERROR_NOT_A_DIRECTORY);
- return;
- }
-
- // drive/other does not exist on the server.
- if (entry->local_id() == util::kDriveOtherDirLocalId) {
- callback.Run(FILE_ERROR_OK);
- return;
- }
-
- // Pass the directory fetch info so we can fetch the contents of the
- // directory before loading change lists.
- internal::DirectoryFetchInfo directory_fetch_info(
- entry->resource_id(),
- entry->directory_specific_info().changestamp());
- change_list_loader_->LoadIfNeeded(directory_fetch_info, callback);
-}
-
void FileSystem::ReadDirectoryAfterLoad(
const base::FilePath& directory_path,
const ReadDirectoryCallback& callback,

Powered by Google App Engine
This is Rietveld 408576698