Commit 8a06ebd3 authored by satorux@chromium.org's avatar satorux@chromium.org

Revert 137657 - Remove directory_path argument from chromeos::FindEntryCallback

Nothing is wrong with this patch, but we don't want to submit refactoring
patches until M20 issues are fixed.

BUG=126672
TEST=unit_tests --gtest_filter="GData*"


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

TBR=hashimoto@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10399063

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137658 0039d316-1c4b-4281-b951-d872f2087c98
parent 7c2b9fa9
......@@ -8,6 +8,7 @@ namespace gdata {
void ReadOnlyFindEntryCallback(GDataEntry** out,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry) {
if (error == base::PLATFORM_FILE_OK)
*out = entry;
......
......@@ -17,12 +17,15 @@ class GDataEntry;
// object provided to this callback under lock. It must not be used outside
// of the callback method. This callback can be invoked on different thread
// than one that started the request.
typedef base::Callback<void(base::PlatformFileError error, GDataEntry* entry)>
typedef base::Callback<void(base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry)>
FindEntryCallback;
// Callback used to find a directory element for file system updates.
void ReadOnlyFindEntryCallback(GDataEntry** out,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry);
} // namespace gdata
......
......@@ -785,7 +785,8 @@ void RelayFindEntryCallback(scoped_refptr<base::MessageLoopProxy> relay_proxy,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry) {
relay_proxy->PostTask(FROM_HERE, base::Bind(callback, error, entry));
relay_proxy->PostTask(FROM_HERE,
base::Bind(callback, error, directory_path, entry));
}
// Ditto for FileOperationCallback.
......@@ -1021,6 +1022,7 @@ void GDataFileSystem::CheckForUpdates() {
void GDataFileSystem::OnUpdateChecked(ContentOrigin initial_origin,
base::PlatformFileError error,
const FilePath& /* directory_path */,
GDataEntry* /* entry */) {
if (error != base::PLATFORM_FILE_OK) {
base::AutoLock lock(lock_);
......@@ -1115,9 +1117,9 @@ void GDataFileSystem::FindEntryByResourceIdSync(
file = entry->AsGDataFile();
if (file)
callback.Run(base::PLATFORM_FILE_OK, file);
callback.Run(base::PLATFORM_FILE_OK, file->parent()->GetFilePath(), file);
else
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
}
void GDataFileSystem::FindEntryByPathAsyncOnUIThread(
......@@ -1299,8 +1301,10 @@ void GDataFileSystem::LoadFeedFromServer(
void GDataFileSystem::OnFeedFromServerLoaded(GetDocumentsParams* params,
base::PlatformFileError error) {
if (error != base::PLATFORM_FILE_OK) {
if (!params->callback.is_null())
params->callback.Run(error, NULL);
if (!params->callback.is_null()) {
params->callback.Run(error, FilePath(),
reinterpret_cast<GDataEntry*>(NULL));
}
return;
}
......@@ -1310,8 +1314,10 @@ void GDataFileSystem::OnFeedFromServerLoaded(GetDocumentsParams* params,
params->root_feed_changestamp);
if (error != base::PLATFORM_FILE_OK) {
if (!params->callback.is_null())
params->callback.Run(error, NULL);
if (!params->callback.is_null()) {
params->callback.Run(error, FilePath(),
reinterpret_cast<GDataEntry*>(NULL));
}
return;
}
......@@ -2389,6 +2395,7 @@ void GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread(
void GDataFileSystem::OnGetEntryInfo(const GetEntryInfoCallback& callback,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......@@ -2436,11 +2443,14 @@ void GDataFileSystem::GetFileInfoByPathAsyncOnUIThread(
FindEntryByPathAsyncOnUIThread(
file_path,
base::Bind(&GDataFileSystem::OnGetFileInfo, ui_weak_ptr_, callback));
base::Bind(&GDataFileSystem::OnGetFileInfo,
ui_weak_ptr_,
callback));
}
void GDataFileSystem::OnGetFileInfo(const GetFileInfoCallback& callback,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......@@ -2501,6 +2511,7 @@ void GDataFileSystem::ReadDirectoryByPathAsyncOnUIThread(
void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......
......@@ -958,6 +958,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
// directory.
void OnUpdateChecked(ContentOrigin initial_origin,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry);
// Starts root feed load from the cache. If successful, it will try to find
......@@ -1342,16 +1343,19 @@ class GDataFileSystem : public GDataFileSystemInterface,
// Called when an entry is found for GetEntryInfoByPathAsync().
void OnGetEntryInfo(const GetEntryInfoCallback& callback,
base::PlatformFileError error,
const FilePath& entry_path,
GDataEntry* entry);
// Called when an entry is found for GetFileInfoByPathAsync().
void OnGetFileInfo(const GetFileInfoCallback& callback,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry);
// Called when an entry is found for ReadDirectoryByPathAsync().
void OnReadDirectory(const ReadDirectoryCallback& callback,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry);
// Finds file info by using virtual |file_path|. This call will also
......
......@@ -958,9 +958,13 @@ class GDataFileSystemTest : public testing::Test {
static void OnExpectToFindEntry(const FilePath& search_file_path,
base::PlatformFileError error,
const FilePath& directory_path,
GDataEntry* entry) {
ASSERT_TRUE(entry);
ASSERT_EQ(search_file_path, entry->GetFilePath());
if (entry->file_info().is_directory)
ASSERT_EQ(search_file_path, directory_path);
else
ASSERT_EQ(search_file_path, directory_path.Append(entry->file_name()));
}
static Value* LoadJSONFile(const std::string& filename) {
......
......@@ -519,7 +519,8 @@ void GDataRootDirectory::FindEntryByPath(const FilePath& file_path,
if (path_type == util::GDATA_SEARCH_PATH_ROOT ||
path_type == util::GDATA_SEARCH_PATH_QUERY) {
callback.Run(base::PLATFORM_FILE_OK, fake_search_directory_.get());
callback.Run(base::PLATFORM_FILE_OK, file_path.DirName(),
fake_search_directory_.get());
return;
}
......@@ -528,7 +529,7 @@ void GDataRootDirectory::FindEntryByPath(const FilePath& file_path,
if (path_type != util::GDATA_SEARCH_PATH_INVALID) {
if (!ModifyFindEntryParamsForSearchPath(file_path,
&components, &current_dir, &directory_path)) {
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
return;
}
}
......@@ -539,16 +540,16 @@ void GDataRootDirectory::FindEntryByPath(const FilePath& file_path,
// Last element must match, if not last then it must be a directory.
if (i == components.size() - 1) {
if (current_dir->file_name() == components[i])
callback.Run(base::PLATFORM_FILE_OK, current_dir);
callback.Run(base::PLATFORM_FILE_OK, directory_path, current_dir);
else
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
return;
}
// Not the last part of the path, search for the next segment.
GDataEntry* entry = current_dir->FindChild(components[i + 1]);
if (!entry) {
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
return;
}
......@@ -558,14 +559,14 @@ void GDataRootDirectory::FindEntryByPath(const FilePath& file_path,
current_dir = entry->AsGDataDirectory();
} else {
if ((i + 1) == (components.size() - 1))
callback.Run(base::PLATFORM_FILE_OK, entry);
callback.Run(base::PLATFORM_FILE_OK, directory_path, entry);
else
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
return;
}
}
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
}
GDataEntry* GDataRootDirectory::GetEntryByResourceId(
......
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