Commit b58303a8 authored by kinaba@chromium.org's avatar kinaba@chromium.org

drive: Remove unused functions from ResourceMetadata.

BUG=none

Review URL: https://chromiumcodereview.appspot.com/23571005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220556 0039d316-1c4b-4281-b951-d872f2087c98
parent 52d7340d
...@@ -57,48 +57,8 @@ void RunReadDirectoryCallback(const ReadDirectoryCallback& callback, ...@@ -57,48 +57,8 @@ void RunReadDirectoryCallback(const ReadDirectoryCallback& callback,
callback.Run(error, entries.Pass()); callback.Run(error, entries.Pass());
} }
// Runs |callback| with arguments.
void RunFileMoveCallback(const FileMoveCallback& callback,
base::FilePath* path,
FileError error) {
DCHECK(!callback.is_null());
DCHECK(path);
callback.Run(error, *path);
}
// Helper function to run tasks with FileMoveCallback.
void PostFileMoveTask(
base::TaskRunner* task_runner,
const base::Callback<FileError(base::FilePath* out_file_path)>& task,
const FileMoveCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!task.is_null());
DCHECK(!callback.is_null());
base::FilePath* file_path = new base::FilePath;
base::PostTaskAndReplyWithResult(
task_runner,
FROM_HERE,
base::Bind(task, file_path),
base::Bind(&RunFileMoveCallback, callback, base::Owned(file_path)));
}
} // namespace } // namespace
EntryInfoResult::EntryInfoResult() : error(FILE_ERROR_FAILED) {
}
EntryInfoResult::~EntryInfoResult() {
}
EntryInfoPairResult::EntryInfoPairResult() {
}
EntryInfoPairResult::~EntryInfoPairResult() {
}
namespace internal { namespace internal {
ResourceMetadata::ResourceMetadata( ResourceMetadata::ResourceMetadata(
...@@ -499,73 +459,6 @@ FileError ResourceMetadata::GetIdByResourceId(const std::string& resource_id, ...@@ -499,73 +459,6 @@ FileError ResourceMetadata::GetIdByResourceId(const std::string& resource_id,
return error; return error;
} }
void ResourceMetadata::GetResourceEntryPairByPathsOnUIThread(
const base::FilePath& first_path,
const base::FilePath& second_path,
const GetResourceEntryPairCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
// Get the first entry.
GetResourceEntryByPathOnUIThread(
first_path,
base::Bind(
&ResourceMetadata::GetResourceEntryPairByPathsOnUIThreadAfterGetFirst,
weak_ptr_factory_.GetWeakPtr(),
first_path,
second_path,
callback));
}
void ResourceMetadata::GetResourceEntryPairByPathsOnUIThreadAfterGetFirst(
const base::FilePath& first_path,
const base::FilePath& second_path,
const GetResourceEntryPairCallback& callback,
FileError error,
scoped_ptr<ResourceEntry> entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult);
result->first.path = first_path;
result->first.error = error;
result->first.entry = entry.Pass();
// If the first one is not found, don't continue.
if (error != FILE_ERROR_OK) {
callback.Run(result.Pass());
return;
}
// Get the second entry.
GetResourceEntryByPathOnUIThread(
second_path,
base::Bind(
&ResourceMetadata::
GetResourceEntryPairByPathsOnUIThreadAfterGetSecond,
weak_ptr_factory_.GetWeakPtr(),
second_path,
callback,
base::Passed(&result)));
}
void ResourceMetadata::GetResourceEntryPairByPathsOnUIThreadAfterGetSecond(
const base::FilePath& second_path,
const GetResourceEntryPairCallback& callback,
scoped_ptr<EntryInfoPairResult> result,
FileError error,
scoped_ptr<ResourceEntry> entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
DCHECK(result.get());
result->second.path = second_path;
result->second.error = error;
result->second.entry = entry.Pass();
callback.Run(result.Pass());
}
bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id, bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id,
const ResourceEntry& entry) { const ResourceEntry& entry) {
DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
......
...@@ -24,13 +24,6 @@ namespace drive { ...@@ -24,13 +24,6 @@ namespace drive {
typedef std::vector<ResourceEntry> ResourceEntryVector; typedef std::vector<ResourceEntry> ResourceEntryVector;
// Callback similar to FileOperationCallback but with a given |file_path|.
// Used for operations that change a file path like moving files.
typedef base::Callback<void(FileError error,
const base::FilePath& file_path)>
FileMoveCallback;
// Used to get a resource entry from the file system. // Used to get a resource entry from the file system.
// If |error| is not FILE_ERROR_OK, |entry_info| is set to NULL. // If |error| is not FILE_ERROR_OK, |entry_info| is set to NULL.
typedef base::Callback<void(FileError error, typedef base::Callback<void(FileError error,
...@@ -43,30 +36,6 @@ typedef base::Callback<void(FileError error, ...@@ -43,30 +36,6 @@ typedef base::Callback<void(FileError error,
typedef base::Callback<void(int64)> GetChangestampCallback; typedef base::Callback<void(int64)> GetChangestampCallback;
// This is a part of EntryInfoPairResult.
struct EntryInfoResult {
EntryInfoResult();
~EntryInfoResult();
base::FilePath path;
FileError error;
scoped_ptr<ResourceEntry> entry;
};
// The result of GetResourceEntryPairCallback(). Used to get a pair of entries
// in one function call.
struct EntryInfoPairResult {
EntryInfoPairResult();
~EntryInfoPairResult();
EntryInfoResult first;
EntryInfoResult second; // Only filled if the first entry is found.
};
// Used to receive the result from GetResourceEntryPairCallback().
typedef base::Callback<void(scoped_ptr<EntryInfoPairResult> pair_result)>
GetResourceEntryPairCallback;
typedef base::Callback<void(const ResourceEntry& entry)> IterateCallback; typedef base::Callback<void(const ResourceEntry& entry)> IterateCallback;
namespace internal { namespace internal {
...@@ -147,16 +116,6 @@ class ResourceMetadata { ...@@ -147,16 +116,6 @@ class ResourceMetadata {
FileError ReadDirectoryByPath(const base::FilePath& file_path, FileError ReadDirectoryByPath(const base::FilePath& file_path,
ResourceEntryVector* out_entries); ResourceEntryVector* out_entries);
// Similar to GetResourceEntryByPath() but this function finds a pair of
// entries by |first_path| and |second_path|. If the entry for
// |first_path| is not found, this function does not try to get the
// entry of |second_path|. |callback| must not be null.
// Must be called on the UI thread.
void GetResourceEntryPairByPathsOnUIThread(
const base::FilePath& first_path,
const base::FilePath& second_path,
const GetResourceEntryPairCallback& callback);
// Replaces an existing entry whose ID is |id| with |entry|. // Replaces an existing entry whose ID is |id| with |entry|.
FileError RefreshEntry(const std::string& id, const ResourceEntry& entry); FileError RefreshEntry(const std::string& id, const ResourceEntry& entry);
...@@ -193,25 +152,6 @@ class ResourceMetadata { ...@@ -193,25 +152,6 @@ class ResourceMetadata {
// Used to implement Destroy(). // Used to implement Destroy().
void DestroyOnBlockingPool(); void DestroyOnBlockingPool();
// Continues with GetResourceEntryPairByPathsOnUIThread after the first
// entry has been asynchronously fetched. This fetches the second entry
// only if the first was found.
void GetResourceEntryPairByPathsOnUIThreadAfterGetFirst(
const base::FilePath& first_path,
const base::FilePath& second_path,
const GetResourceEntryPairCallback& callback,
FileError error,
scoped_ptr<ResourceEntry> entry);
// Continues with GetResourceEntryPairByPathsOnUIThread after the second
// entry has been asynchronously fetched.
void GetResourceEntryPairByPathsOnUIThreadAfterGetSecond(
const base::FilePath& second_path,
const GetResourceEntryPairCallback& callback,
scoped_ptr<EntryInfoPairResult> result,
FileError error,
scoped_ptr<ResourceEntry> entry);
// Puts an entry under its parent directory. Removes the child from the old // Puts an entry under its parent directory. Removes the child from the old
// parent if there is. This method will also do name de-duplication to ensure // parent if there is. This method will also do name de-duplication to ensure
// that the exposed presentation path does not have naming conflicts. Two // that the exposed presentation path does not have naming conflicts. Two
......
...@@ -342,64 +342,6 @@ TEST_F(ResourceMetadataTestOnUIThread, ReadDirectoryByPath) { ...@@ -342,64 +342,6 @@ TEST_F(ResourceMetadataTestOnUIThread, ReadDirectoryByPath) {
EXPECT_FALSE(entries.get()); EXPECT_FALSE(entries.get());
} }
TEST_F(ResourceMetadataTestOnUIThread, GetResourceEntryPairByPaths) {
// Confirm that existing two files are found.
scoped_ptr<EntryInfoPairResult> pair_result;
resource_metadata_->GetResourceEntryPairByPathsOnUIThread(
base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"),
google_apis::test_util::CreateCopyResultCallback(&pair_result));
test_util::RunBlockingPoolTask();
// The first entry should be found.
EXPECT_EQ(FILE_ERROR_OK, pair_result->first.error);
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
pair_result->first.path);
ASSERT_TRUE(pair_result->first.entry.get());
EXPECT_EQ("file4", pair_result->first.entry->base_name());
// The second entry should be found.
EXPECT_EQ(FILE_ERROR_OK, pair_result->second.error);
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"),
pair_result->second.path);
ASSERT_TRUE(pair_result->second.entry.get());
EXPECT_EQ("file5", pair_result->second.entry->base_name());
// Confirm that the first non existent file is not found.
pair_result.reset();
resource_metadata_->GetResourceEntryPairByPathsOnUIThread(
base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"),
google_apis::test_util::CreateCopyResultCallback(&pair_result));
test_util::RunBlockingPoolTask();
// The first entry should not be found.
EXPECT_EQ(FILE_ERROR_NOT_FOUND, pair_result->first.error);
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
pair_result->first.path);
ASSERT_FALSE(pair_result->first.entry.get());
// The second entry should not be found, because the first one failed.
EXPECT_EQ(FILE_ERROR_FAILED, pair_result->second.error);
EXPECT_EQ(base::FilePath(), pair_result->second.path);
ASSERT_FALSE(pair_result->second.entry.get());
// Confirm that the second non existent file is not found.
pair_result.reset();
resource_metadata_->GetResourceEntryPairByPathsOnUIThread(
base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
google_apis::test_util::CreateCopyResultCallback(&pair_result));
test_util::RunBlockingPoolTask();
// The first entry should be found.
EXPECT_EQ(FILE_ERROR_OK, pair_result->first.error);
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"),
pair_result->first.path);
ASSERT_TRUE(pair_result->first.entry.get());
EXPECT_EQ("file4", pair_result->first.entry->base_name());
// The second entry should not be found.
EXPECT_EQ(FILE_ERROR_NOT_FOUND, pair_result->second.error);
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"),
pair_result->second.path);
ASSERT_FALSE(pair_result->second.entry.get());
}
TEST_F(ResourceMetadataTestOnUIThread, Reset) { TEST_F(ResourceMetadataTestOnUIThread, Reset) {
// The grand root has "root" which is not empty. // The grand root has "root" which is not empty.
scoped_ptr<ResourceEntryVector> entries; scoped_ptr<ResourceEntryVector> entries;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment