summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 02:55:44 +0000
committertbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 02:55:44 +0000
commitf98ac64588453aec3fc63070c5d3a4d96662221a (patch)
tree4ed89c558ca6b7707fa0e2296827f74494e499b1
parent146be2e5165365b500fd573769c4fb53343d6276 (diff)
downloadchromium_src-f98ac64588453aec3fc63070c5d3a4d96662221a.zip
chromium_src-f98ac64588453aec3fc63070c5d3a4d96662221a.tar.gz
chromium_src-f98ac64588453aec3fc63070c5d3a4d96662221a.tar.bz2
Remove (hacky) handling for drive/.search paths from gdata file system.
We don't need this anymore. NOTE: this shouldn't go in before: http://codereview.chromium.org/10539165/ TEST=existing tests. (manual: confirmed drive search still works in file browser) BUG=129068 Review URL: https://chromiumcodereview.appspot.com/10562016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142906 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_private_api.cc3
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system.cc172
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system.h21
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc15
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc431
-rw-r--r--chrome/browser/chromeos/gdata/gdata_files.cc68
-rw-r--r--chrome/browser/chromeos/gdata/gdata_files.h38
-rw-r--r--chrome/browser/chromeos/gdata/gdata_util.cc51
-rw-r--r--chrome/browser/chromeos/gdata/gdata_util.h33
-rw-r--r--chrome/browser/chromeos/gdata/mock_gdata_file_system.h5
10 files changed, 55 insertions, 782 deletions
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index 0215449..e4ae2c8 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -2158,8 +2158,7 @@ void SearchDriveFunction::OnFileSystemOpened(
system_service->file_system()->Search(
query_,
- base::Bind(&SearchDriveFunction::OnSearch, this),
- gdata::ReadDirectoryCallback());
+ base::Bind(&SearchDriveFunction::OnSearch, this));
}
void SearchDriveFunction::OnSearch(
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 00c3edb..188fe54 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -437,17 +437,6 @@ void GetFileInfoOnBlockingPool(const FilePath& path,
*result = file_util::GetFileInfo(path, file_info);
}
-// Tests if we are allowed to create new directory in the provided directory.
-bool ShouldCreateDirectory(const FilePath& directory_path) {
- // We allow directory creation for paths that are on gdata file system
- // (GDATA_SEARCH_PATH_INVALID) and paths that reference actual gdata file
- // system path (GDATA_SEARCH_PATH_RESULT_CHILD).
- util::GDataSearchPathType path_type =
- util::GetSearchPathStatus(directory_path);
- return path_type == util::GDATA_SEARCH_PATH_INVALID ||
- path_type == util::GDATA_SEARCH_PATH_RESULT_CHILD;
-}
-
// Copies a file from |src_file_path| to |dest_file_path| on the local
// file system using file_util::CopyFile. |error| is set to
// base::PLATFORM_FILE_OK on success or base::PLATFORM_FILE_ERROR_FAILED
@@ -1196,27 +1185,24 @@ void GDataFileSystem::Copy(const FilePath& src_file_path,
CreateRelayCallback(callback)));
}
-void GDataFileSystem::CopyOnUIThread(const FilePath& original_src_file_path,
- const FilePath& original_dest_file_path,
+void GDataFileSystem::CopyOnUIThread(const FilePath& src_file_path,
+ const FilePath& dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::PlatformFileError error = base::PLATFORM_FILE_OK;
- FilePath dest_parent_path = original_dest_file_path.DirName();
-
- FilePath src_file_path;
- FilePath dest_file_path;
+ FilePath dest_parent_path = dest_file_path.DirName();
std::string src_file_resource_id;
bool src_file_is_hosted_document = false;
- GDataEntry* src_entry = GetGDataEntryByPath(original_src_file_path);
+ GDataEntry* src_entry = GetGDataEntryByPath(src_file_path);
GDataEntry* dest_parent = GetGDataEntryByPath(dest_parent_path);
if (!src_entry || !dest_parent) {
error = base::PLATFORM_FILE_ERROR_NOT_FOUND;
} else if (!dest_parent->AsGDataDirectory()) {
error = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
- } else if (!src_entry->AsGDataFile() || dest_parent->is_detached()) {
+ } else if (!src_entry->AsGDataFile()) {
// TODO(benchan): Implement copy for directories. In the interim,
// we handle recursive directory copy in the file manager.
error = base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
@@ -1224,16 +1210,6 @@ void GDataFileSystem::CopyOnUIThread(const FilePath& original_src_file_path,
src_file_resource_id = src_entry->resource_id();
src_file_is_hosted_document =
src_entry->AsGDataFile()->is_hosted_document();
- // |original_src_file_path| and |original_dest_file_path| don't have to
- // necessary be equal to |src_entry|'s or |dest_entry|'s file path (e.g.
- // paths used to display gdata content search results).
- // That's why, instead of using |original_src_file_path| and
- // |original_dest_file_path|, we will get file paths to use in copy
- // operation from the entries.
- src_file_path = src_entry->GetFilePath();
- dest_parent_path = dest_parent->GetFilePath();
- dest_file_path = dest_parent_path.Append(
- original_dest_file_path.BaseName());
}
if (error != base::PLATFORM_FILE_OK) {
@@ -1243,9 +1219,6 @@ void GDataFileSystem::CopyOnUIThread(const FilePath& original_src_file_path,
return;
}
- DCHECK(!src_file_path.empty());
- DCHECK(!dest_file_path.empty());
-
if (src_file_is_hosted_document) {
CopyDocumentToDirectory(dest_parent_path,
src_file_resource_id,
@@ -1408,39 +1381,20 @@ void GDataFileSystem::Move(const FilePath& src_file_path,
CreateRelayCallback(callback)));
}
-void GDataFileSystem::MoveOnUIThread(const FilePath& original_src_file_path,
- const FilePath& original_dest_file_path,
+void GDataFileSystem::MoveOnUIThread(const FilePath& src_file_path,
+ const FilePath& dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::PlatformFileError error = base::PLATFORM_FILE_OK;
- FilePath dest_parent_path = original_dest_file_path.DirName();
-
- FilePath src_file_path;
- FilePath dest_file_path;
- FilePath dest_name = original_dest_file_path.BaseName();
+ FilePath dest_parent_path = dest_file_path.DirName();
- GDataEntry* src_entry = GetGDataEntryByPath(original_src_file_path);
+ GDataEntry* src_entry = GetGDataEntryByPath(src_file_path);
GDataEntry* dest_parent = GetGDataEntryByPath(dest_parent_path);
if (!src_entry || !dest_parent) {
error = base::PLATFORM_FILE_ERROR_NOT_FOUND;
} else if (!dest_parent->AsGDataDirectory()) {
error = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
- } else if (dest_parent->is_detached()) {
- // We allow moving to a directory without file system root only if it's
- // done as part of renaming (i.e. source and destination parent paths are
- // the same).
- if (original_src_file_path.DirName() != dest_parent_path) {
- error = base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- } else {
- // If we are indeed renaming, we have to strip resource id from the file
- // name.
- std::string resource_id;
- std::string file_name;
- util::ParseSearchFileName(dest_name.value(), &resource_id, &file_name);
- if (!file_name.empty())
- dest_name = FilePath(file_name);
- }
}
if (error != base::PLATFORM_FILE_OK) {
@@ -1450,28 +1404,15 @@ void GDataFileSystem::MoveOnUIThread(const FilePath& original_src_file_path,
}
return;
}
- // |original_src_file_path| and |original_dest_file_path| don't have to
- // necessary be equal to |src_entry|'s or |dest_entry|'s file path (e.g.
- // paths used to display gdata content search results).
- // That's why, instead of using |original_src_file_path| and
- // |original_dest_file_path|, we will get file paths to use in move
- // operation from the entries.
- src_file_path = src_entry->GetFilePath();
- if (!dest_parent->is_detached())
- dest_parent_path = dest_parent->GetFilePath();
- dest_file_path = dest_parent_path.Append(dest_name);
-
- DCHECK(!src_file_path.empty());
- DCHECK(!dest_file_path.empty());
// If the file/directory is moved to the same directory, just rename it.
- if (original_src_file_path.DirName() == dest_parent_path) {
+ if (src_file_path.DirName() == dest_parent_path) {
FilePathUpdateCallback final_file_path_update_callback =
base::Bind(&GDataFileSystem::OnFilePathUpdated,
ui_weak_ptr_,
callback);
- Rename(original_src_file_path, dest_name.value(),
+ Rename(src_file_path, dest_file_path.BaseName().value(),
final_file_path_update_callback);
return;
}
@@ -1608,7 +1549,7 @@ void GDataFileSystem::RemoveOnUIThread(
base::Bind(&GDataFileSystem::OnRemovedDocument,
ui_weak_ptr_,
callback,
- entry->GetFilePath()));
+ file_path));
}
void GDataFileSystem::CreateDirectory(
@@ -1633,14 +1574,6 @@ void GDataFileSystem::CreateDirectoryOnUIThread(
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!ShouldCreateDirectory(directory_path)) {
- if (!callback.is_null()) {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, base::PLATFORM_FILE_ERROR_INVALID_OPERATION));
- }
- return;
- }
-
FilePath last_parent_dir_path;
FilePath first_missing_path;
GURL last_parent_dir_url;
@@ -2392,26 +2325,20 @@ void GDataFileSystem::OnCreateDirectoryCompleted(
}
}
-void GDataFileSystem::OnSearch(const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback,
+void GDataFileSystem::OnSearch(const SearchCallback& callback,
GetDocumentsParams* params,
base::PlatformFileError error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (error != base::PLATFORM_FILE_OK) {
if (!callback.is_null())
- callback.Run(error,
- hide_hosted_docs_,
- scoped_ptr<GDataDirectoryProto>());
- if (!search_callback.is_null())
- search_callback.Run(error, scoped_ptr<std::vector<SearchResultInfo> >());
+ callback.Run(error, scoped_ptr<std::vector<SearchResultInfo> >());
return;
}
// The search results will be returned using virtual directory.
// The directory is not really part of the file system, so it has no parent or
// root.
- scoped_ptr<GDataDirectory> search_dir(new GDataDirectory(NULL, NULL));
scoped_ptr<std::vector<SearchResultInfo> > results(
new std::vector<SearchResultInfo>());
@@ -2422,69 +2349,60 @@ void GDataFileSystem::OnSearch(const SearchCallback& search_callback,
// result directory.
for (size_t i = 0; i < feed->entries().size(); ++i){
DocumentEntry* doc = feed->entries()->at(i);
- GDataEntry* entry = GDataEntry::FromDocumentEntry(NULL, doc, root_.get());
-
- if (!entry)
- continue;
-
- GDataEntry* old_entry = root_->GetEntryByResourceId(entry->resource_id());
+ scoped_ptr<GDataEntry> entry(
+ GDataEntry::FromDocumentEntry(NULL, doc, root_.get()));
- // If a result is not present in our local file system snapshot, ignore it.
- // For example, this may happen if the entry has recently been added to the
- // drive (and we still haven't received its delta feed).
- if (!old_entry)
+ if (!entry.get())
continue;
- bool is_directory = old_entry->AsGDataDirectory() != NULL;
- results->push_back(SearchResultInfo(old_entry->GetFilePath(),
- is_directory));
-
DCHECK_EQ(doc->resource_id(), entry->resource_id());
DCHECK(!entry->is_deleted());
+ std::string entry_resource_id = entry->resource_id();
+
+ // This will do nothing if the entry is not already present in file system.
if (entry->AsGDataFile()) {
- // We have to make a new copy of the entry because |search_dir| will later
- // take ownership of |entry|.
- GDataEntry* entry_to_save =
- GDataEntry::FromDocumentEntry(NULL, doc, root_.get());
- DCHECK(entry_to_save && entry_to_save->AsGDataFile());
- DCHECK_EQ(entry->resource_id(), entry_to_save->resource_id());
- scoped_ptr<GDataFile>entry_to_save_as_file(entry_to_save->AsGDataFile());
- root_->RefreshFile(entry_to_save_as_file.Pass());
+ scoped_ptr<GDataFile> entry_as_file(entry.release()->AsGDataFile());
+ root_->RefreshFile(entry_as_file.Pass());
+ // We shouldn't use entry object after this point.
+ DCHECK(!entry.get());
}
- entry->set_title(entry->resource_id() + "." + entry->title());
+ // We will need information about result entry to create info for callback.
+ // We can't use |entry| anymore, so we have to refetch entry from file
+ // system. Also, |entry| doesn't have file path set before |RefreshFile|
+ // call, so we can't get file path from there.
+ GDataEntry* saved_entry = root_->GetEntryByResourceId(entry_resource_id);
- search_dir->AddEntry(entry);
- }
+ // If a result is not present in our local file system snapshot, ignore it.
+ // For example, this may happen if the entry has recently been added to the
+ // drive (and we still haven't received its delta feed).
+ if (!saved_entry)
+ continue;
- scoped_ptr<GDataDirectoryProto> directory_proto(new GDataDirectoryProto);
- search_dir->ToProto(directory_proto.get());
+ bool is_directory = saved_entry->AsGDataDirectory() != NULL;
+ results->push_back(SearchResultInfo(saved_entry->GetFilePath(),
+ is_directory));
+ }
if (!callback.is_null())
- callback.Run(error, hide_hosted_docs_, directory_proto.Pass());
- if (!search_callback.is_null())
- search_callback.Run(error, results.Pass());
+ callback.Run(error, results.Pass());
}
void GDataFileSystem::Search(const std::string& search_query,
- const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback) {
+ const SearchCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
RunTaskOnUIThread(base::Bind(&GDataFileSystem::SearchAsyncOnUIThread,
ui_weak_ptr_,
search_query,
- CreateRelayCallback(search_callback),
CreateRelayCallback(callback)));
}
void GDataFileSystem::SearchAsyncOnUIThread(
const std::string& search_query,
- const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback) {
+ const SearchCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
scoped_ptr<std::vector<DocumentFeed*> > feed_list(
new std::vector<DocumentFeed*>);
@@ -2500,7 +2418,7 @@ void GDataFileSystem::SearchAsyncOnUIThread(
std::string(), // No directory resource ID.
FindEntryCallback(), // Not used.
base::Bind(&GDataFileSystem::OnSearch,
- ui_weak_ptr_, search_callback, callback));
+ ui_weak_ptr_, callback));
}
void GDataFileSystem::OnGetDocuments(ContentOrigin initial_origin,
@@ -3355,11 +3273,7 @@ base::PlatformFileError GDataFileSystem::AddNewDirectory(
parent_dir->AddEntry(new_entry);
- // |directory_path| is not necessary same as |entry->GetFilePath()|. It may be
- // virtual path that references the entry (e.g. path under which content
- // search result is shown).
- // We want to dispatch directory changed with the actual entry's path.
- NotifyDirectoryChanged(entry->GetFilePath());
+ NotifyDirectoryChanged(directory_path);
return base::PLATFORM_FILE_OK;
}
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h
index 645fc16..058de7f 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.h
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.h
@@ -332,18 +332,12 @@ class GDataFileSystemInterface {
virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0;
// Does server side content search for |search_query|.
- // Search results will be returned in two ways:
- // 1' As list of results' |SearchResultInfo| structs, which contains file's
- // path and is_directory flag. This is done using |search_callback|.
- // 2' As gdata entries in temp directory proto, and their
- // title/file_name will be formatted |<resource_id>.<original_file_name>|.
- // This will be returned via |callback|.
+ // Search results will be returned as a list of results' |SearchResultInfo|
+ // structs, which contains file's path and is_directory flag.
//
- // TODO(tbarzic): Get rid of 2' once we're ready.
// Can be called from UI/IO thread. |callback| is run on the calling thread.
virtual void Search(const std::string& search_query,
- const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback) = 0;
+ const SearchCallback& callback) = 0;
// Fetches the user's Account Metadata to find out current quota information
// and returns it to the callback.
@@ -382,8 +376,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
const std::string& resource_id,
const FindEntryCallback& callback) OVERRIDE;
virtual void Search(const std::string& search_query,
- const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback) OVERRIDE;
+ const SearchCallback& callback) OVERRIDE;
virtual void TransferFileFromRemoteToLocal(
const FilePath& remote_src_file_path,
const FilePath& local_dest_file_path,
@@ -575,8 +568,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
// |LoadFeedFromServer|.
// |params| params used for getting document feed for content search.
// |error| error code returned by |LoadFeedFromServer|.
- void OnSearch(const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback,
+ void OnSearch(const SearchCallback& callback,
GetDocumentsParams* params,
base::PlatformFileError error);
@@ -1076,8 +1068,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
// The following functions are used to forward calls to asynchronous public
// member functions to UI thread.
void SearchAsyncOnUIThread(const std::string& search_query,
- const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback);
+ const SearchCallback& callback);
void OpenFileOnUIThread(const FilePath& file_path,
const OpenFileCallback& callback);
void CloseFileOnUIThread(const FilePath& file_path,
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc b/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc
index 3000d4f..5d72c16 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/chromeos/gdata/gdata_file_system.h"
#include "chrome/browser/chromeos/gdata/gdata.pb.h"
#include "chrome/browser/chromeos/gdata/gdata_system_service.h"
-#include "chrome/browser/chromeos/gdata/gdata_util.h"
#include "webkit/blob/shareable_file_reference.h"
#include "webkit/fileapi/file_system_file_util_proxy.h"
#include "webkit/fileapi/file_system_types.h"
@@ -253,20 +252,6 @@ void GDataFileSystemProxy::ReadDirectory(const GURL& file_url,
return;
}
- // File paths with type GDATA_SEARH_PATH_QUERY are virtual path reserved for
- // displaying gdata content search results. They are formatted so their base
- // name equals to search query. So to get their contents, we have to kick off
- // content search.
- if (util::GetSearchPathStatus(file_path) == util::GDATA_SEARCH_PATH_QUERY) {
- file_system_->Search(
- file_path.BaseName().value(),
- gdata::SearchCallback(),
- base::Bind(&GDataFileSystemProxy::OnReadDirectory,
- this,
- callback));
- return;
- }
-
file_system_->ReadDirectoryByPath(
file_path,
base::Bind(&GDataFileSystemProxy::OnReadDirectory,
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
index a0f8338..d2dec3c 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
@@ -125,12 +125,8 @@ struct SearchResultPair {
// Callback to GDataFileSystem::Search used in ContentSearch test.
// Verifies returned vector of results.
-//
-// |should_next_callback_quit_loop| is owned by ContentSearch test function,
-// and it is shared with |ContentSearchCallback|.
void DriveSearchCallback(
MessageLoop* message_loop,
- bool* should_next_callback_quit_loop,
base::PlatformFileError error,
scoped_ptr<std::vector<SearchResultInfo> > results) {
// Search feed contains 2 entries. One file (SubDirectory File 1.txt) and one
@@ -146,42 +142,7 @@ void DriveSearchCallback(
EXPECT_EQ(FilePath("drive/Directory 1"), results->at(1).path);
EXPECT_TRUE(results->at(1).is_directory);
- if (*should_next_callback_quit_loop) {
- message_loop->Quit();
- } else {
- *should_next_callback_quit_loop = true;
- }
-}
-
-// Another callback to GDataFileSystem::Search used in ContentSearch test.
-// Verifies that returned proto buffer contains entries specified in search
-// feed, and that treing file names are formatted like
-// "<resource_id>.<file_name>".
-//
-// |should_next_callback_quit_loop| is owned by ContentSearch test function,
-// and it is shared with |DriveSearchCallback|.
-void ContentSearchCallback(
- MessageLoop* message_loop,
- bool* should_next_callback_quit_loop,
- base::PlatformFileError error,
- bool /* hide_hosted_documents, */,
- scoped_ptr<GDataDirectoryProto> dir_proto) {
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
- ASSERT_TRUE(dir_proto.get());
-
- ASSERT_EQ(1, dir_proto->child_files_size());
- EXPECT_EQ("file:2_file_resouce_id.SubDirectory File 1.txt",
- dir_proto->child_files(0).gdata_entry().file_name());
-
- ASSERT_EQ(1, dir_proto->child_directories_size());
- EXPECT_EQ("folder:1_folder_resource_id.Directory 1",
- dir_proto->child_directories(0).gdata_entry().file_name());
-
- if (*should_next_callback_quit_loop) {
- message_loop->Quit();
- } else {
- *should_next_callback_quit_loop = true;
- }
+ message_loop->Quit();
}
// Action used to set mock expectations for GetDocuments.
@@ -3378,396 +3339,10 @@ TEST_F(GDataFileSystemTest, ContentSearch) {
EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _))
.Times(1);
- bool should_next_callback_quit_loop = false;
- SearchCallback search_callback = base::Bind(
- &DriveSearchCallback,
- &message_loop_,
- &should_next_callback_quit_loop);
- ReadDirectoryCallback callback = base::Bind(
- &ContentSearchCallback,
- &message_loop_,
- &should_next_callback_quit_loop);
+ SearchCallback callback = base::Bind(&DriveSearchCallback, &message_loop_);
- file_system_->Search("foo", search_callback, callback);
+ file_system_->Search("foo", callback);
message_loop_.Run(); // Wait to get our result
-
- const SearchResultPair kSearchResultPairs[] = {
- { "drive/.search/foo/file:2_file_resouce_id.SubDirectory File 1.txt",
- "drive/Directory 1/SubDirectory File 1.txt" },
- { "drive/.search/foo/folder:1_folder_resource_id.Directory 1",
- "drive/Directory 1" },
- { "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "SubDirectory File 1.txt",
- "drive/Directory 1/SubDirectory File 1.txt" }
- };
-
- for (size_t i = 0; i < arraysize(kSearchResultPairs); ++i) {
- FilePath search_file_path(FILE_PATH_LITERAL(
- kSearchResultPairs[i].search_path));
- FilePath real_file_path(FILE_PATH_LITERAL(
- kSearchResultPairs[i].real_path));
-
- GDataEntry* search_file_entry = FindEntry(search_file_path);
- ASSERT_TRUE(search_file_entry)
- << "Can't find " << search_file_path.value();
-
- GDataEntry* real_file_entry = FindEntry(real_file_path);
- ASSERT_TRUE(real_file_entry)
- << "Can't find " << real_file_path.value();
-
- EXPECT_EQ(search_file_entry, real_file_entry);
- }
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_Delete) {
- LoadRootFeedDocument("root_feed.json");
-
- EXPECT_CALL(*mock_doc_service_, DeleteDocument(_, _)).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1);
-
- FilePath search_file_path(FILE_PATH_LITERAL(
- "drive/.search/foo/file:2_file_resouce_id.SubDirectory File 1.txt"));
- FilePath real_file_path(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
-
- ASSERT_TRUE(FindEntry(real_file_path));
- ASSERT_TRUE(FindEntry(search_file_path));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Remove(search_file_path, false, callback);
- message_loop_.RunAllPending(); // Wait to get our result
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_FALSE(FindEntry(real_file_path));
- EXPECT_FALSE(FindEntry(search_file_path));
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_RenameResult) {
- LoadRootFeedDocument("root_feed.json");
-
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1);
-
- EXPECT_CALL(*mock_doc_service_, RenameResource(
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "SubDirectory File 1.txt.renamed", _))
- .Times(1);
-
- FilePath source_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/file:2_file_resouce_id.SubDirectory File 1.txt"));
- FilePath source_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
-
- FilePath renamed_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/"
- "file:2_file_resouce_id.SubDirectory File 1.txt.renamed"));
- FilePath renamed_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt.renamed"));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Move(source_path_search, renamed_path_search, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_FALSE(FindEntry(source_path_real));
- EXPECT_FALSE(FindEntry(source_path_search));
-
- EXPECT_TRUE(FindEntry(renamed_path_real));
- EXPECT_TRUE(FindEntry(renamed_path_search));
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_Move) {
- LoadRootFeedDocument("root_feed.json");
-
- // Setup directory observer mocks.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL(
- "drive/Directory 1/Sub Directory Folder")))))
- .Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1);
-
- // Setup documents service mocks.
- EXPECT_CALL(*mock_doc_service_, RenameResource(
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "SubDirectory File 1.txt.dest", _))
- .Times(1);
- EXPECT_CALL(*mock_doc_service_, RemoveResourceFromDirectory(
- Eq(GURL("https://1_folder_content_url/")),
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "file:2_file_resouce_id", _))
- .Times(1);
- EXPECT_CALL(*mock_doc_service_, AddResourceToDirectory(
- Eq(GURL("https://1_folder_content_url/")),
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), _))
- .Times(1);
-
- // Start the test.
- FilePath source_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "SubDirectory File 1.txt"));
- FilePath source_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
-
- FilePath destination_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "Sub Directory Folder/SubDirectory File 1.txt.dest"));
- FilePath destination_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/Sub Directory Folder/SubDirectory File 1.txt.dest"));
-
- ASSERT_TRUE(FindEntry(source_path_search));
- ASSERT_TRUE(FindEntry(source_path_real));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Move(source_path_search, destination_path_search, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_FALSE(FindEntry(source_path_search));
- EXPECT_FALSE(FindEntry(source_path_real));
-
- EXPECT_TRUE(FindEntry(destination_path_search));
- EXPECT_TRUE(FindEntry(destination_path_real));
-}
-
-// Move file to gdata file system from search result directory.
-TEST_F(GDataFileSystemTest, ContentSearch_MoveToGData) {
- LoadRootFeedDocument("root_feed.json");
-
- // Setup directory observer mocks.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL(
- "drive/Directory 1/Sub Directory Folder")))))
- .Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1);
-
- // Setup documents service mocks.
- EXPECT_CALL(*mock_doc_service_, RenameResource(
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "SubDirectory File 1.txt.dest", _))
- .Times(1);
- EXPECT_CALL(*mock_doc_service_, RemoveResourceFromDirectory(
- Eq(GURL("https://1_folder_content_url/")),
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "file:2_file_resouce_id", _))
- .Times(1);
- EXPECT_CALL(*mock_doc_service_, AddResourceToDirectory(
- Eq(GURL("https://1_folder_content_url/")),
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), _))
- .Times(1);
-
- // Start the test.
- FilePath source_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "SubDirectory File 1.txt"));
- FilePath source_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
-
- FilePath destination_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "Sub Directory Folder/SubDirectory File 1.txt.dest"));
- FilePath destination_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/Sub Directory Folder/SubDirectory File 1.txt.dest"));
-
- ASSERT_TRUE(FindEntry(source_path_search));
- ASSERT_TRUE(FindEntry(source_path_real));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Move(source_path_search, destination_path_real, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_FALSE(FindEntry(source_path_search));
- EXPECT_FALSE(FindEntry(source_path_real));
-
- EXPECT_TRUE(FindEntry(destination_path_search));
- EXPECT_TRUE(FindEntry(destination_path_real));
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_MoveToSearch) {
- LoadRootFeedDocument("root_feed.json");
-
- // Setup directory observer mocks.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL(
- "drive/Directory 1/Sub Directory Folder")))))
- .Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1);
-
- // Setup documents service mocks.
- EXPECT_CALL(*mock_doc_service_, RenameResource(
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "SubDirectory File 1.txt.dest", _))
- .Times(1);
- EXPECT_CALL(*mock_doc_service_, RemoveResourceFromDirectory(
- Eq(GURL("https://1_folder_content_url/")),
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")),
- "file:2_file_resouce_id", _))
- .Times(1);
- EXPECT_CALL(*mock_doc_service_, AddResourceToDirectory(
- Eq(GURL("https://1_folder_content_url/")),
- Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), _))
- .Times(1);
-
- // Statr the test.
- FilePath source_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "SubDirectory File 1.txt"));
- FilePath source_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
-
- FilePath destination_path_search(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "Sub Directory Folder/SubDirectory File 1.txt.dest"));
- FilePath destination_path_real(FILE_PATH_LITERAL(
- "drive/Directory 1/Sub Directory Folder/SubDirectory File 1.txt.dest"));
-
- ASSERT_TRUE(FindEntry(source_path_search));
- ASSERT_TRUE(FindEntry(source_path_real));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Move(source_path_real, destination_path_search, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_FALSE(FindEntry(source_path_search));
- EXPECT_FALSE(FindEntry(source_path_real));
-
- EXPECT_TRUE(FindEntry(destination_path_search));
- EXPECT_TRUE(FindEntry(destination_path_real));
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_CopyToSearchDirectory) {
- LoadRootFeedDocument("root_feed.json");
-
- FilePath src_file_path(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
- FilePath dest_file_path(FILE_PATH_LITERAL(
- "drive/.search/Directory 1"));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Copy(src_file_path, dest_file_path, callback);
- message_loop_.RunAllPending();
-
- EXPECT_NE(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_TRUE(FindEntry(src_file_path));
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_CopyToSearchResultDirectory) {
- LoadRootFeedDocument("root_feed.json");
-
- FilePath src_file_path(FILE_PATH_LITERAL(
- "drive/Directory 1/SubDirectory File 1.txt"));
- FilePath dest_file_path(FILE_PATH_LITERAL(
- "drive/.search/foo/Directory 1"));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->Copy(src_file_path, dest_file_path, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- callback_helper_->last_error_);
-
- EXPECT_TRUE(FindEntry(src_file_path));
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_CreateDirInSearchResultDirectory) {
- LoadRootFeedDocument("root_feed.json");
-
- FilePath dest_file_path(FILE_PATH_LITERAL(
- "drive/.search/foo/New Folder"));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->CreateDirectory(dest_file_path, false, false, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- callback_helper_->last_error_);
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_CreateDirInSearchDirectory) {
- LoadRootFeedDocument("root_feed.json");
-
- FilePath dest_file_path(FILE_PATH_LITERAL(
- "drive/.search/New Folder"));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->CreateDirectory(dest_file_path, false, false, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- callback_helper_->last_error_);
-}
-
-TEST_F(GDataFileSystemTest, ContentSearch_CreateDirectory) {
- LoadRootFeedDocument("root_feed.json");
-
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1);
- EXPECT_CALL(*mock_doc_service_, CreateDirectory(
- Eq(GURL("https://1_folder_content_url/")), "FolderNew", _)).Times(1);
-
- FilePath search_dir_path(FILE_PATH_LITERAL(
- "drive/.search/foo/folder:1_folder_resource_id.Directory 1/"
- "FolderNew"));
- FilePath real_dir_path(FILE_PATH_LITERAL("drive/Directory 1/FolderNew"));
-
- EXPECT_FALSE(FindEntry(search_dir_path));
- EXPECT_FALSE(FindEntry(real_dir_path));
-
- FileOperationCallback callback =
- base::Bind(&CallbackHelper::FileOperationCallback,
- callback_helper_.get());
-
- file_system_->CreateDirectory(search_dir_path, false, false, callback);
- message_loop_.RunAllPending();
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
-
- EXPECT_TRUE(FindEntry(search_dir_path));
- EXPECT_TRUE(FindEntry(real_dir_path));
}
TEST_F(GDataFileSystemTest, GetAvailableSpace) {
diff --git a/chrome/browser/chromeos/gdata/gdata_files.cc b/chrome/browser/chromeos/gdata/gdata_files.cc
index fbb4e7e..67e65dc 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.cc
+++ b/chrome/browser/chromeos/gdata/gdata_files.cc
@@ -396,7 +396,6 @@ void GDataDirectory::RemoveChildDirectories() {
GDataRootDirectory::GDataRootDirectory()
: ALLOW_THIS_IN_INITIALIZER_LIST(GDataDirectory(NULL, this)),
- fake_search_directory_(new GDataDirectory(NULL, NULL)),
largest_changestamp_(0), serialized_size_(0) {
title_ = kGDataRootDirectory;
SetFileNameFromTitle();
@@ -430,54 +429,6 @@ void GDataRootDirectory::RemoveEntryFromResourceMap(GDataEntry* entry) {
resource_map_.erase(entry->resource_id());
}
-bool GDataRootDirectory::ModifyFindEntryParamsForSearchPath(
- const FilePath& file_path,
- std::vector<FilePath::StringType>* components,
- GDataDirectory** current_dir,
- FilePath* directory_path) {
- DCHECK(current_dir);
- DCHECK(components);
- // |components| should contain at least 4 members.
- // "drive", ".search", query_name and query_result_name. Additionally,
- // if query result is a directory, it may contain subdirectories and files,
- // in which case the number of components may be bigger than 4.
- DCHECK_GT(components->size(), 3u);
- DCHECK(components->at(0) == "drive" && components->at(1) == ".search");
-
- FilePath::StringType resource_id;
- FilePath::StringType file_name;
- if (!util::ParseSearchFileName((*components)[3], &resource_id, &file_name))
- return false;
-
- GDataEntry* file_entry = GetEntryByResourceId(resource_id);
- if (!file_entry)
- return false;
-
- // We should continue search from the entry's parent dir (|current_dir|), so
- // we have to ammend |components| to be relative to the |current_dir|
- // (including the dir itself).
- // We continue the search with the entry's parent instead of the entry itself
- // to make sure that the returned file really has the name |file_name|. Note
- // that we may end up with finding an entry even if entry with |resource_id|
- // has a name different from |file_name|. This is intended, and enables us to
- // test that new file name is unique (in file manager) when renaming the
- // entry.
- DCHECK(file_entry->parent());
- *current_dir = file_entry->parent();
-
- if ((*current_dir)->parent()) {
- *directory_path = (*current_dir)->parent()->GetFilePath();
- } else {
- *directory_path = FilePath();
- }
-
- // Remove "drive/.search" from path.
- components->erase(components->begin(), components->begin() + 2);
- (*components)[0] = (*current_dir)->file_name();
- (*components)[1] = file_name;
- return true;
-}
-
void GDataRootDirectory::FindEntryByPath(const FilePath& file_path,
const FindEntryCallback& callback) {
// GDataFileSystem has already locked.
@@ -489,25 +440,6 @@ void GDataRootDirectory::FindEntryByPath(const FilePath& file_path,
GDataDirectory* current_dir = this;
FilePath directory_path;
- util::GDataSearchPathType path_type =
- util::GetSearchPathStatusForPathComponents(components);
-
- 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());
- return;
- }
-
- // If the path is under search path, we have to modify paremeters for finding
- // the entry.
- 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);
- return;
- }
- }
-
for (size_t i = 0; i < components.size() && current_dir; i++) {
directory_path = directory_path.Append(current_dir->file_name());
diff --git a/chrome/browser/chromeos/gdata/gdata_files.h b/chrome/browser/chromeos/gdata/gdata_files.h
index d954b21..ce73e27 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.h
+++ b/chrome/browser/chromeos/gdata/gdata_files.h
@@ -8,7 +8,6 @@
#include <map>
#include <string>
-#include <vector>
#include "base/callback.h"
#include "base/gtest_prod_util.h"
@@ -146,12 +145,6 @@ class GDataEntry {
// delta feeds.
bool is_deleted() const { return deleted_; }
- // True if the entry is not bound to any file system (i.e. doesn't have a root
- // directory set). E.g. |fake_search_directory| below.
- // NOTE: GDataRootDirectories will return true here, since they have
- // themselves as root directories.
- bool is_detached() const { return root_ == NULL; }
-
// Returns virtual file path representing this file system entry. This path
// corresponds to file path expected by public methods of GDataFileSyste
// class.
@@ -388,39 +381,8 @@ class GDataRootDirectory : public GDataDirectory {
void ToProto(GDataRootDirectoryProto* proto) const;
private:
- // Used in |FindEntryByPath| if the path that is being searched for is
- // pointing to a search result path. The find entry parameters should be
- // modified to point to the actual file system entry that is referenced by
- // virtual search path.
- // Search path is formatted: <search_result_path><search_result_child_path>.
- // <search_result_child_path> is used when search result is directory, and is
- // relative to search result path (id references some content inside search
- // result).
- // Search result file name will be formatted <resource_id>.<file_name>.
- // We can define "search result path references gdata entry" for gdata search
- // results by:
- // Entry that whose file name is <file_name>, and has the same parent as
- // the entry with resource id <resource_id>. This definition enables us to
- // test uniqueness of the proposed name when renaming gdata search result.
- //
- // For example, if drive/.search/foo/res_id.foo_name references
- // drive/result_parent/result, and the search path is
- // drive/.search/foo/res_ud.foo_name/foo_child, we'll set current dir to the
- // entry with path reulst_parent, and components to [result_parent, result,
- // foo_child].
- bool ModifyFindEntryParamsForSearchPath(
- const FilePath& file_path,
- std::vector<FilePath::StringType>* components,
- GDataDirectory** current_dir,
- FilePath* directory_path);
-
ResourceMap resource_map_;
- // Fake directory that will be returned when searching for content search
- // paths to make file manager happy when resolving paths. This directory
- // should never be used for file operations or storing file entries.
- scoped_ptr<GDataDirectory> fake_search_directory_;
-
base::Time last_serialized_;
int largest_changestamp_;
size_t serialized_size_;
diff --git a/chrome/browser/chromeos/gdata/gdata_util.cc b/chrome/browser/chromeos/gdata/gdata_util.cc
index fe24e5d..8309f90 100644
--- a/chrome/browser/chromeos/gdata/gdata_util.cc
+++ b/chrome/browser/chromeos/gdata/gdata_util.cc
@@ -50,10 +50,6 @@ const FilePath::CharType* kGDataMountPointPathComponents[] = {
"/", "special", "drive"
};
-const FilePath::CharType* kGDataSearchPathComponents[] = {
- "drive", ".search"
-};
-
const int kReadOnlyFilePermissions = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_EXCLUSIVE_READ |
@@ -244,53 +240,6 @@ bool IsUnderGDataMountPoint(const FilePath& path) {
GetGDataMountPointPath().IsParent(path);
}
-GDataSearchPathType GetSearchPathStatus(const FilePath& path) {
- std::vector<std::string> components;
- path.GetComponents(&components);
- return GetSearchPathStatusForPathComponents(components);
-}
-
-GDataSearchPathType GetSearchPathStatusForPathComponents(
- const std::vector<std::string>& path_components) {
- if (path_components.size() < arraysize(kGDataSearchPathComponents))
- return GDATA_SEARCH_PATH_INVALID;
-
- for (size_t i = 0; i < arraysize(kGDataSearchPathComponents); i++) {
- if (path_components[i] != kGDataSearchPathComponents[i])
- return GDATA_SEARCH_PATH_INVALID;
- }
-
- switch (path_components.size()) {
- case 2:
- return GDATA_SEARCH_PATH_ROOT;
- case 3:
- return GDATA_SEARCH_PATH_QUERY;
- case 4:
- return GDATA_SEARCH_PATH_RESULT;
- default:
- return GDATA_SEARCH_PATH_RESULT_CHILD;
- }
-}
-
-bool ParseSearchFileName(const std::string& search_file_name,
- std::string* resource_id,
- std::string* original_file_name) {
- DCHECK(resource_id);
- DCHECK(original_file_name);
-
- *resource_id = "";
- *original_file_name = "";
-
- size_t dot_index = search_file_name.find('.');
- if (dot_index == std::string::npos)
- return false;
-
- *resource_id = search_file_name.substr(0, dot_index);
- if (search_file_name.length() - 1 > dot_index)
- *original_file_name = search_file_name.substr(dot_index + 1);
- return (!resource_id->empty() && !original_file_name->empty());
-}
-
FilePath ExtractGDataPath(const FilePath& path) {
if (!IsUnderGDataMountPoint(path))
return FilePath();
diff --git a/chrome/browser/chromeos/gdata/gdata_util.h b/chrome/browser/chromeos/gdata/gdata_util.h
index 7ce9393..4d4ce65 100644
--- a/chrome/browser/chromeos/gdata/gdata_util.h
+++ b/chrome/browser/chromeos/gdata/gdata_util.h
@@ -19,23 +19,6 @@ class Profile;
namespace gdata {
namespace util {
-// Search path is a path used to display gdata content search results.
-// All results are displayed under virtual directory "drive/.search", in which
-// each query is given its own directory for displaying results.
-enum GDataSearchPathType {
- // Not a search path.
- GDATA_SEARCH_PATH_INVALID,
- // drive/.search.
- GDATA_SEARCH_PATH_ROOT,
- // Path that defines search query (drive/.search/foo).
- GDATA_SEARCH_PATH_QUERY,
- // Path given to a search result (drive/.search/foo/foo_found).
- // The file name will be formatted: "resource_id.file_name".
- GDATA_SEARCH_PATH_RESULT,
- // If search result is directory, it may contain some children.
- GDATA_SEARCH_PATH_RESULT_CHILD
-};
-
// Path constants
extern const char kMountedArchiveFileExtension[];
extern const char kWildCard[];
@@ -62,22 +45,6 @@ void ModifyGDataFileResourceUrl(Profile* profile,
// Returns true if the given path is under the GData mount point.
bool IsUnderGDataMountPoint(const FilePath& path);
-// Checks if the path is under (virtual) gdata search directory, and returns its
-// search status.
-GDataSearchPathType GetSearchPathStatus(const FilePath& path);
-
-// Checks if the path is under (virtual) gdata earch directory, and returns its
-// search status.
-GDataSearchPathType GetSearchPathStatusForPathComponents(
- const std::vector<std::string>& path_components);
-
-// Gets resource id and original file name from the search file name.
-// Search file name is formatted as: <resource_id>.<original_file_name>.
-// If the path is not search path, the behaviour is not defined.
-bool ParseSearchFileName(const std::string& search_file_name,
- std::string* resource_id,
- std::string* original_file_name);
-
// Extracts the GData path from the given path located under the GData mount
// point. Returns an empty path if |path| is not under the GData mount point.
// Examples: ExtractGDatPath("/special/drive/foo.txt") => "drive/foo.txt"
diff --git a/chrome/browser/chromeos/gdata/mock_gdata_file_system.h b/chrome/browser/chromeos/gdata/mock_gdata_file_system.h
index 74d3768..6954af4 100644
--- a/chrome/browser/chromeos/gdata/mock_gdata_file_system.h
+++ b/chrome/browser/chromeos/gdata/mock_gdata_file_system.h
@@ -29,9 +29,8 @@ class MockGDataFileSystem : public GDataFileSystemInterface {
MOCK_METHOD2(FindEntryByResourceId,
void(const std::string& resource_id,
const FindEntryCallback& callback));
- MOCK_METHOD3(Search, void(const std::string& search_query,
- const SearchCallback& search_callback,
- const ReadDirectoryCallback& callback));
+ MOCK_METHOD2(Search, void(const std::string& search_query,
+ const SearchCallback& callback));
MOCK_METHOD3(TransferFileFromRemoteToLocal,
void(const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,