Convert DirectoryEntry to mojom
Convert uses of storage::DirectoryEntry to filesystem::mojom::DirectoryEntry. Convert previous use of mojo struct to new field types as described below. This struct has two fields that were actually slightly changed: - |name| was StringType, which is platform dependent wstring on Windows and string on others, changed to FilePath which is a NativeStruct in mojo and takes care of the platform specific. - |is_directory| converted to an mojo enum |type| thus usage changed to compare |type| with enum values. To comply with presubmit allowed //components/filesystem as DEPS for //content and //storage. This is part of File System API mojofication as per the following Design Doc: https://docs.google.com/document/d/16e7PbljOpkn9riFPsIyONVfiAyNUPztfBHBfov5W6v4 Bug: 787281 Change-Id: I254e3266a93a03074dd94ccd018e5ac5c95e7021 Reviewed-on: https://chromium-review.googlesource.com/936963 Commit-Queue: Luciano Pacheco (SYD) <lucmult@chromium.org> Reviewed-by: Victor Costan <pwnall@chromium.org> Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org> Reviewed-by: Tatsuhisa Yamaguchi <yamaguchi@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Taiju Tsuiki <tzik@chromium.org> Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Reviewed-by: Hidehiko Abe <hidehiko@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Cr-Commit-Position: refs/heads/master@{#546433}
This commit is contained in:

committed by
Commit Bot

parent
7379d186db
commit
99533e87a4
chrome/browser
chromeos
arc
drive
file_system_provider
fileapi
smb_client
extensions
api
developer_private
media_galleries
chromeos
fileapi
mac
win
sync_file_system
drive_backend
components/services
filesystem
leveldb
content
storage
DEPS
browser
BUILD.gn
fileapi
async_file_util.hasync_file_util_adapter.cccopy_or_move_operation_delegate_unittest.ccdragged_file_util_unittest.ccfile_system_dir_url_request_job.ccfile_system_dir_url_request_job.hfile_system_operation.hfile_system_operation_impl_unittest.ccfile_system_operation_runner.ccfile_system_operation_runner.hobfuscated_file_util_unittest.ccrecursive_operation_delegate.cc
common
@ -14,11 +14,11 @@
|
||||
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
|
||||
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "storage/browser/blob/shareable_file_reference.h"
|
||||
#include "storage/browser/fileapi/file_system_operation_context.h"
|
||||
#include "storage/browser/fileapi/file_system_url.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@ -43,10 +43,12 @@ void OnReadDirectoryOnUIThread(
|
||||
|
||||
storage::AsyncFileUtil::EntryList entries;
|
||||
entries.reserve(files.size());
|
||||
for (const auto& file : files)
|
||||
entries.emplace_back(file.name, file.is_directory
|
||||
? storage::DirectoryEntry::DIRECTORY
|
||||
: storage::DirectoryEntry::FILE);
|
||||
for (const auto& file : files) {
|
||||
entries.emplace_back(base::FilePath(file.name),
|
||||
file.is_directory
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::BindOnce(std::move(callback), result, entries,
|
||||
|
@ -22,12 +22,10 @@
|
||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||
#include "content/public/test/test_browser_thread_bundle.h"
|
||||
#include "storage/browser/fileapi/watcher_manager.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
using ChangeType = arc::ArcDocumentsProviderRoot::ChangeType;
|
||||
using storage::DirectoryEntry;
|
||||
using Document = arc::FakeFileSystemInstance::Document;
|
||||
using EntryList = storage::AsyncFileUtil::EntryList;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
@ -16,9 +18,9 @@
|
||||
#include "components/drive/drive.pb.h"
|
||||
#include "components/drive/file_errors.h"
|
||||
#include "components/drive/resource_entry_conversion.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "storage/browser/fileapi/file_system_url.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@ -74,17 +76,15 @@ void RunReadDirectoryCallbackWithEntries(
|
||||
std::unique_ptr<ResourceEntryVector> resource_entries) {
|
||||
DCHECK(resource_entries);
|
||||
|
||||
std::vector<storage::DirectoryEntry> entries;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries;
|
||||
// Convert drive files to File API's directory entry.
|
||||
entries.reserve(resource_entries->size());
|
||||
for (size_t i = 0; i < resource_entries->size(); ++i) {
|
||||
const ResourceEntry& resource_entry = (*resource_entries)[i];
|
||||
storage::DirectoryEntry entry;
|
||||
entry.name = resource_entry.base_name();
|
||||
|
||||
const PlatformFileInfoProto& file_info = resource_entry.file_info();
|
||||
entry.is_directory = file_info.is_directory();
|
||||
entries.push_back(entry);
|
||||
entries.emplace_back(base::FilePath(resource_entry.base_name()),
|
||||
resource_entry.file_info().is_directory()
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
|
||||
callback.Run(base::File::FILE_OK, entries, true /*has_more*/);
|
||||
@ -94,7 +94,7 @@ void RunReadDirectoryCallbackWithEntries(
|
||||
void RunReadDirectoryCallbackOnCompletion(const ReadDirectoryCallback& callback,
|
||||
FileError error) {
|
||||
callback.Run(FileErrorToBaseFileError(error),
|
||||
std::vector<storage::DirectoryEntry>(),
|
||||
std::vector<filesystem::mojom::DirectoryEntry>(),
|
||||
false /*has_more*/);
|
||||
}
|
||||
|
||||
@ -361,7 +361,6 @@ void TouchFile(const base::FilePath& file_path,
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
file_system->TouchFile(file_path, last_access_time, last_modified_time,
|
||||
base::Bind(&RunStatusCallbackByFileError, callback));
|
||||
|
||||
}
|
||||
|
||||
} // namespace fileapi_internal
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "base/callback_forward.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "components/drive/file_errors.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/blob/scoped_file.h"
|
||||
|
||||
namespace base {
|
||||
@ -52,7 +53,7 @@ typedef base::Callback<
|
||||
const base::File::Info& file_info)> GetFileInfoCallback;
|
||||
typedef base::RepeatingCallback<void(
|
||||
base::File::Error result,
|
||||
std::vector<storage::DirectoryEntry> file_list,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> file_list,
|
||||
bool has_more)>
|
||||
ReadDirectoryCallback;
|
||||
typedef base::Callback<void(base::File::Error result,
|
||||
|
@ -6,10 +6,12 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
|
||||
namespace chromeos {
|
||||
@ -158,10 +160,11 @@ AbortCallback FakeProvidedFileSystem::ReadDirectory(
|
||||
const base::FilePath file_path = it->first;
|
||||
if (file_path == directory_path || directory_path.IsParent(file_path)) {
|
||||
const EntryMetadata* const metadata = it->second->metadata.get();
|
||||
entry_list.push_back(storage::DirectoryEntry(
|
||||
*metadata->name, *metadata->is_directory
|
||||
? storage::DirectoryEntry::DIRECTORY
|
||||
: storage::DirectoryEntry::FILE));
|
||||
entry_list.emplace_back(
|
||||
base::FilePath(*metadata->name),
|
||||
*metadata->is_directory
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h"
|
||||
#include "chrome/common/extensions/api/file_system_provider.h"
|
||||
#include "chrome/common/extensions/api/file_system_provider_internal.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
|
||||
namespace chromeos {
|
||||
namespace file_system_provider {
|
||||
@ -38,11 +39,10 @@ bool ConvertRequestValueToEntryList(std::unique_ptr<RequestValue> value,
|
||||
return false;
|
||||
}
|
||||
|
||||
storage::DirectoryEntry output_entry;
|
||||
output_entry.is_directory = *entry_metadata.is_directory;
|
||||
output_entry.name = *entry_metadata.name;
|
||||
|
||||
output->push_back(output_entry);
|
||||
output->emplace_back(base::FilePath(*entry_metadata.name),
|
||||
*entry_metadata.is_directory
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "chrome/common/extensions/api/file_system_provider.h"
|
||||
#include "chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h"
|
||||
#include "chrome/common/extensions/api/file_system_provider_internal.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "extensions/browser/event_router.h"
|
||||
#include "storage/browser/fileapi/async_file_util.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -208,9 +209,9 @@ TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess) {
|
||||
EXPECT_EQ(base::File::FILE_OK, event->result());
|
||||
|
||||
ASSERT_EQ(1u, event->entry_list().size());
|
||||
const storage::DirectoryEntry entry = event->entry_list()[0];
|
||||
EXPECT_FALSE(entry.is_directory);
|
||||
EXPECT_EQ("blueberries.txt", entry.name);
|
||||
const filesystem::mojom::DirectoryEntry entry = event->entry_list()[0];
|
||||
EXPECT_EQ(entry.type, filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
EXPECT_EQ("blueberries.txt", entry.name.value());
|
||||
}
|
||||
|
||||
TEST_F(FileSystemProviderOperationsReadDirectoryTest,
|
||||
|
@ -126,7 +126,7 @@ void RecentDownloadSource::OnReadDirectory(
|
||||
|
||||
for (const auto& entry : entries) {
|
||||
base::FilePath subpath = path.Append(entry.name);
|
||||
if (entry.is_directory) {
|
||||
if (entry.type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
ScanDirectory(subpath);
|
||||
} else {
|
||||
storage::FileSystemURL url = BuildDownloadsURL(subpath);
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "chrome/browser/chromeos/smb_client/smb_file_system.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
@ -12,6 +14,7 @@
|
||||
#include "chrome/browser/chromeos/file_system_provider/service.h"
|
||||
#include "chromeos/dbus/dbus_thread_manager.h"
|
||||
#include "chromeos/dbus/smb_provider_client.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
|
||||
namespace chromeos {
|
||||
@ -68,9 +71,9 @@ namespace smb_client {
|
||||
|
||||
namespace {
|
||||
|
||||
storage::DirectoryEntry::DirectoryEntryType MapEntryType(bool is_directory) {
|
||||
return is_directory ? storage::DirectoryEntry::DIRECTORY
|
||||
: storage::DirectoryEntry::FILE;
|
||||
filesystem::mojom::FsFileType MapEntryType(bool is_directory) {
|
||||
return is_directory ? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE;
|
||||
}
|
||||
|
||||
constexpr size_t kTaskQueueCapacity = 2;
|
||||
@ -481,7 +484,8 @@ void SmbFileSystem::HandleRequestReadDirectoryCallback(
|
||||
|
||||
// Loop through the entries and send when the desired batch size is hit.
|
||||
for (const smbprovider::DirectoryEntryProto& entry : entries.entries()) {
|
||||
entry_list.emplace_back(entry.name(), MapEntryType(entry.is_directory()));
|
||||
entry_list.emplace_back(base::FilePath(entry.name()),
|
||||
MapEntryType(entry.is_directory()));
|
||||
|
||||
if (entry_list.size() == batch_size) {
|
||||
callback.Run(base::File::FILE_OK, entry_list, true /* has_more */);
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
@ -1381,7 +1383,7 @@ void DeveloperPrivateLoadDirectoryFunction::ReadDirectoryByFileSystemAPICb(
|
||||
pending_copy_operations_count_ += file_list.size();
|
||||
|
||||
for (size_t i = 0; i < file_list.size(); ++i) {
|
||||
if (file_list[i].is_directory) {
|
||||
if (file_list[i].type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
ReadDirectoryByFileSystemAPI(project_path.Append(file_list[i].name),
|
||||
destination_path.Append(file_list[i].name));
|
||||
continue;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/media_galleries/chromeos/mtp_device_task_helper_map_service.h"
|
||||
#include "chrome/browser/media_galleries/chromeos/snapshot_file_details.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "third_party/cros_system_api/dbus/service_constants.h"
|
||||
|
||||
@ -1589,14 +1590,16 @@ void MTPDeviceDelegateImplLinux::OnDidReadDirectory(
|
||||
|
||||
storage::AsyncFileUtil::EntryList file_list;
|
||||
for (const auto& mtp_entry : mtp_entries) {
|
||||
storage::DirectoryEntry entry;
|
||||
entry.name = mtp_entry.name;
|
||||
entry.is_directory = mtp_entry.file_info.is_directory;
|
||||
filesystem::mojom::DirectoryEntry entry;
|
||||
entry.name = base::FilePath(mtp_entry.name);
|
||||
entry.type = mtp_entry.file_info.is_directory
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE;
|
||||
file_list.push_back(entry);
|
||||
|
||||
// Refresh the in memory tree.
|
||||
dir_node->EnsureChildExists(entry.name, mtp_entry.file_id);
|
||||
child_nodes_seen_.insert(entry.name);
|
||||
dir_node->EnsureChildExists(entry.name.value(), mtp_entry.file_id);
|
||||
child_nodes_seen_.insert(entry.name.value());
|
||||
|
||||
// Add to |file_info_cache_|.
|
||||
file_info_cache_[dir_path.Append(entry.name)] = mtp_entry;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.h"
|
||||
#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
|
||||
#include "chrome/browser/media_galleries/fileapi/readahead_file_stream_reader.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "storage/browser/blob/shareable_file_reference.h"
|
||||
#include "storage/browser/fileapi/file_stream_reader.h"
|
||||
@ -261,8 +262,9 @@ DeviceMediaAsyncFileUtil::MediaPathFilterWrapper::FilterMediaEntries(
|
||||
const AsyncFileUtil::EntryList& file_list) {
|
||||
AsyncFileUtil::EntryList results;
|
||||
for (size_t i = 0; i < file_list.size(); ++i) {
|
||||
const storage::DirectoryEntry& entry = file_list[i];
|
||||
if (entry.is_directory || CheckFilePath(base::FilePath(entry.name))) {
|
||||
const filesystem::mojom::DirectoryEntry& entry = file_list[i];
|
||||
if (entry.type == filesystem::mojom::FsFileType::DIRECTORY ||
|
||||
CheckFilePath(entry.name)) {
|
||||
results.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "chrome/browser/media_galleries/fileapi/media_path_filter.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/mime_sniffer.h"
|
||||
@ -567,11 +568,10 @@ base::File::Error NativeMediaFileUtil::ReadDirectorySync(
|
||||
if (!info.IsDirectory() && !media_path_filter_->Match(enum_path))
|
||||
continue;
|
||||
|
||||
storage::DirectoryEntry entry;
|
||||
entry.is_directory = info.IsDirectory();
|
||||
entry.name = enum_path.BaseName().value();
|
||||
|
||||
file_list->push_back(entry);
|
||||
file_list->emplace_back(enum_path.BaseName(),
|
||||
info.IsDirectory()
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
|
||||
return base::File::FILE_OK;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
@ -94,9 +95,8 @@ void DidReadDirectory(std::set<base::FilePath::StringType>* content,
|
||||
bool has_more) {
|
||||
EXPECT_TRUE(!*completed);
|
||||
*completed = !has_more;
|
||||
for (FileEntryList::const_iterator itr = file_list.begin();
|
||||
itr != file_list.end(); ++itr)
|
||||
EXPECT_TRUE(content->insert(itr->name).second);
|
||||
for (const auto& entry : file_list)
|
||||
EXPECT_TRUE(content->insert(entry.name.value()).second);
|
||||
}
|
||||
|
||||
void PopulateDirectoryWithTestCases(const base::FilePath& dir,
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/macros.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "components/storage_monitor/image_capture_device.h"
|
||||
#include "components/storage_monitor/image_capture_device_manager.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@ -464,10 +465,10 @@ void MTPDeviceDelegateImplMac::NotifyReadDir() {
|
||||
base::FilePath relative_path;
|
||||
read_path.AppendRelativePath(file_paths_[i], &relative_path);
|
||||
base::File::Info info = file_info_[file_paths_[i].value()];
|
||||
storage::DirectoryEntry entry;
|
||||
entry.name = relative_path.value();
|
||||
entry.is_directory = info.is_directory;
|
||||
entry_list.push_back(entry);
|
||||
entry_list.emplace_back(
|
||||
std::move(relative_path),
|
||||
info.is_directory ? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
|
||||
if (found_path) {
|
||||
|
@ -381,11 +381,11 @@ TEST_F(MTPDeviceDelegateImplMacTest, TestGetFileInfo) {
|
||||
EXPECT_EQ(base::File::FILE_OK, ReadDir(base::FilePath(kDevicePath)));
|
||||
|
||||
ASSERT_EQ(2U, file_list_.size());
|
||||
EXPECT_FALSE(file_list_[0].is_directory);
|
||||
EXPECT_EQ("name1", file_list_[0].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[0].type);
|
||||
EXPECT_EQ("name1", file_list_[0].name.value());
|
||||
|
||||
EXPECT_FALSE(file_list_[1].is_directory);
|
||||
EXPECT_EQ("name2", file_list_[1].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[1].type);
|
||||
EXPECT_EQ("name2", file_list_[1].name.value());
|
||||
}
|
||||
|
||||
TEST_F(MTPDeviceDelegateImplMacTest, TestDirectoriesAndSorting) {
|
||||
@ -410,13 +410,13 @@ TEST_F(MTPDeviceDelegateImplMacTest, TestDirectoriesAndSorting) {
|
||||
EXPECT_EQ(base::File::FILE_OK, ReadDir(base::FilePath(kDevicePath)));
|
||||
|
||||
ASSERT_EQ(4U, file_list_.size());
|
||||
EXPECT_EQ("dir1", file_list_[0].name);
|
||||
EXPECT_EQ("dir2", file_list_[1].name);
|
||||
EXPECT_FALSE(file_list_[2].is_directory);
|
||||
EXPECT_EQ("name1", file_list_[2].name);
|
||||
EXPECT_EQ("dir1", file_list_[0].name.value());
|
||||
EXPECT_EQ("dir2", file_list_[1].name.value());
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[2].type);
|
||||
EXPECT_EQ("name1", file_list_[2].name.value());
|
||||
|
||||
EXPECT_FALSE(file_list_[3].is_directory);
|
||||
EXPECT_EQ("name2", file_list_[3].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[3].type);
|
||||
EXPECT_EQ("name2", file_list_[3].name.value());
|
||||
}
|
||||
|
||||
TEST_F(MTPDeviceDelegateImplMacTest, SubDirectories) {
|
||||
@ -459,33 +459,33 @@ TEST_F(MTPDeviceDelegateImplMacTest, SubDirectories) {
|
||||
|
||||
EXPECT_EQ(base::File::FILE_OK, ReadDir(base::FilePath(kDevicePath)));
|
||||
ASSERT_EQ(3U, file_list_.size());
|
||||
EXPECT_TRUE(file_list_[0].is_directory);
|
||||
EXPECT_EQ("dir1", file_list_[0].name);
|
||||
EXPECT_TRUE(file_list_[1].is_directory);
|
||||
EXPECT_EQ("dir2", file_list_[1].name);
|
||||
EXPECT_FALSE(file_list_[2].is_directory);
|
||||
EXPECT_EQ("name4", file_list_[2].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::DIRECTORY, file_list_[0].type);
|
||||
EXPECT_EQ("dir1", file_list_[0].name.value());
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::DIRECTORY, file_list_[1].type);
|
||||
EXPECT_EQ("dir2", file_list_[1].name.value());
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[2].type);
|
||||
EXPECT_EQ("name4", file_list_[2].name.value());
|
||||
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
ReadDir(base::FilePath(kDevicePath).Append("dir1")));
|
||||
ASSERT_EQ(1U, file_list_.size());
|
||||
EXPECT_FALSE(file_list_[0].is_directory);
|
||||
EXPECT_EQ("name1", file_list_[0].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[0].type);
|
||||
EXPECT_EQ("name1", file_list_[0].name.value());
|
||||
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
ReadDir(base::FilePath(kDevicePath).Append("dir2")));
|
||||
ASSERT_EQ(2U, file_list_.size());
|
||||
EXPECT_FALSE(file_list_[0].is_directory);
|
||||
EXPECT_EQ("name2", file_list_[0].name);
|
||||
EXPECT_TRUE(file_list_[1].is_directory);
|
||||
EXPECT_EQ("subdir", file_list_[1].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[0].type);
|
||||
EXPECT_EQ("name2", file_list_[0].name.value());
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::DIRECTORY, file_list_[1].type);
|
||||
EXPECT_EQ("subdir", file_list_[1].name.value());
|
||||
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
ReadDir(base::FilePath(kDevicePath)
|
||||
.Append("dir2").Append("subdir")));
|
||||
ASSERT_EQ(1U, file_list_.size());
|
||||
EXPECT_FALSE(file_list_[0].is_directory);
|
||||
EXPECT_EQ("name3", file_list_[0].name);
|
||||
EXPECT_EQ(filesystem::mojom::FsFileType::REGULAR_FILE, file_list_[0].type);
|
||||
EXPECT_EQ("name3", file_list_[0].name.value());
|
||||
|
||||
EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND,
|
||||
ReadDir(base::FilePath(kDevicePath)
|
||||
@ -517,7 +517,7 @@ TEST_F(MTPDeviceDelegateImplMacTest, TestDownload) {
|
||||
|
||||
EXPECT_EQ(base::File::FILE_OK, ReadDir(base::FilePath(kDevicePath)));
|
||||
ASSERT_EQ(1U, file_list_.size());
|
||||
ASSERT_EQ("filename", file_list_[0].name);
|
||||
ASSERT_EQ("filename", file_list_[0].name.value());
|
||||
|
||||
EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND,
|
||||
DownloadFile(base::FilePath("/ic:id/nonexist"),
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "chrome/browser/media_galleries/win/mtp_device_operations_util.h"
|
||||
#include "chrome/browser/media_galleries/win/portable_device_map_service.h"
|
||||
#include "chrome/browser/media_galleries/win/snapshot_file_details.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "components/storage_monitor/storage_monitor.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "storage/common/fileapi/file_system_util.h"
|
||||
@ -202,10 +203,10 @@ base::File::Error ReadDirectoryOnBlockingPoolThread(
|
||||
return error;
|
||||
|
||||
while (!(current = file_enum->Next()).empty()) {
|
||||
storage::DirectoryEntry entry;
|
||||
entry.is_directory = file_enum->IsDirectory();
|
||||
entry.name = storage::VirtualPath::BaseName(current).value();
|
||||
entries->push_back(entry);
|
||||
entries->emplace_back(storage::VirtualPath::BaseName(current),
|
||||
file_enum->IsDirectory()
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "components/drive/drive_uploader.h"
|
||||
#include "components/drive/service/fake_drive_service.h"
|
||||
#include "components/drive/service/test_util.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/public/test/test_browser_thread.h"
|
||||
#include "content/public/test/test_browser_thread_bundle.h"
|
||||
#include "content/public/test/test_utils.h"
|
||||
@ -457,10 +458,7 @@ class DriveBackendSyncTest : public testing::Test,
|
||||
FileEntryList local_entries;
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
file_system->ReadDirectory(url, &local_entries));
|
||||
for (FileEntryList::iterator itr = local_entries.begin();
|
||||
itr != local_entries.end();
|
||||
++itr) {
|
||||
const storage::DirectoryEntry& local_entry = *itr;
|
||||
for (const auto& local_entry : local_entries) {
|
||||
storage::FileSystemURL entry_url(
|
||||
CreateURL(app_id, path.Append(local_entry.name)));
|
||||
std::string title =
|
||||
@ -470,7 +468,7 @@ class DriveBackendSyncTest : public testing::Test,
|
||||
ASSERT_TRUE(base::ContainsKey(remote_entry_by_title, title));
|
||||
const google_apis::FileResource& remote_entry =
|
||||
*remote_entry_by_title[title];
|
||||
if (local_entry.is_directory) {
|
||||
if (local_entry.type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
ASSERT_TRUE(remote_entry.IsDirectory());
|
||||
VerifyConsistencyForFolder(app_id, entry_url.path(),
|
||||
remote_entry.file_id(),
|
||||
@ -519,11 +517,10 @@ class DriveBackendSyncTest : public testing::Test,
|
||||
FileEntryList entries;
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
file_system->ReadDirectory(url, &entries));
|
||||
for (FileEntryList::iterator itr = entries.begin();
|
||||
itr != entries.end(); ++itr) {
|
||||
for (const auto& entry : entries) {
|
||||
++result;
|
||||
if (itr->is_directory)
|
||||
folders.push(url.path().Append(itr->name));
|
||||
if (entry.type == filesystem::mojom::FsFileType::DIRECTORY)
|
||||
folders.push(url.path().Append(entry.name));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ void DirectoryImpl::Read(ReadCallback callback) {
|
||||
mojom::DirectoryEntryPtr entry = mojom::DirectoryEntry::New();
|
||||
entry->type = info.IsDirectory() ? mojom::FsFileType::DIRECTORY
|
||||
: mojom::FsFileType::REGULAR_FILE;
|
||||
entry->name = info.GetName().AsUTF8Unsafe();
|
||||
entry->name = info.GetName();
|
||||
entries.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ TEST_F(DirectoryImplTest, Read) {
|
||||
for (size_t i = 0; i < directory_contents->size(); i++) {
|
||||
auto& item = directory_contents.value()[i];
|
||||
ASSERT_TRUE(item);
|
||||
auto it = expected_contents.find(item->name);
|
||||
auto it = expected_contents.find(item->name.AsUTF8Unsafe());
|
||||
ASSERT_TRUE(it != expected_contents.end());
|
||||
EXPECT_EQ(it->second, item->type);
|
||||
expected_contents.erase(it);
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
module filesystem.mojom;
|
||||
|
||||
import "mojo/public/mojom/base/file_path.mojom";
|
||||
|
||||
// Used to explain the meaning of an offset within a file. These values line up
|
||||
// exactly with base::File.
|
||||
enum Whence {
|
||||
@ -72,8 +74,12 @@ enum FsFileType {
|
||||
|
||||
// Describes a directory entry (i.e., a single member of a directory).
|
||||
struct DirectoryEntry {
|
||||
// It contains only the entry name, i.e.: /path/to/a/file would be just
|
||||
// "file". TODO(https://crbug/779196): Use Basename type when available.
|
||||
mojo_base.mojom.FilePath name;
|
||||
|
||||
// Type of a given entry.
|
||||
FsFileType type;
|
||||
string name;
|
||||
};
|
||||
|
||||
// Deletion flags:
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "mojo/public/cpp/bindings/interface_request.h"
|
||||
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
|
||||
@ -238,7 +239,8 @@ void LevelDBMojoProxy::GetChildrenImpl(OpaqueDir* dir,
|
||||
|
||||
if (directory_contents.has_value()) {
|
||||
for (size_t i = 0; i < directory_contents->size(); ++i)
|
||||
out_contents->push_back(directory_contents.value()[i]->name);
|
||||
out_contents->push_back(
|
||||
directory_contents.value()[i]->name.AsUTF8Unsafe());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ include_rules = [
|
||||
# as autofill or extensions, and chrome implementation details such as
|
||||
# settings, packaging details, installation or crash reporting.
|
||||
|
||||
"+components/services/filesystem",
|
||||
|
||||
"+crypto",
|
||||
"+grit/blink_resources.h",
|
||||
"+grit/content_strings.h",
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/time/time.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/browser/bad_message.h"
|
||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||
#include "content/browser/child_process_security_policy_impl.h"
|
||||
@ -37,7 +38,6 @@
|
||||
#include "storage/browser/fileapi/file_permission_policy.h"
|
||||
#include "storage/browser/fileapi/file_system_context.h"
|
||||
#include "storage/browser/fileapi/isolated_context.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
#include "storage/common/fileapi/file_system_info.h"
|
||||
#include "storage/common/fileapi/file_system_types.h"
|
||||
#include "storage/common/fileapi/file_system_util.h"
|
||||
@ -502,7 +502,7 @@ void FileAPIMessageFilter::DidGetMetadataForStreaming(
|
||||
void FileAPIMessageFilter::DidReadDirectory(
|
||||
int request_id,
|
||||
base::File::Error result,
|
||||
std::vector<storage::DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool has_more) {
|
||||
if (result == base::File::FILE_OK) {
|
||||
if (!entries.empty() || !has_more)
|
||||
|
@ -9,8 +9,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/containers/hash_tables.h"
|
||||
@ -18,6 +20,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/shared_memory.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/browser/streams/stream.h"
|
||||
#include "content/browser/streams/stream_context.h"
|
||||
#include "content/common/content_export.h"
|
||||
@ -36,7 +39,6 @@ class Time;
|
||||
namespace storage {
|
||||
class FileSystemURL;
|
||||
class FileSystemOperationRunner;
|
||||
struct DirectoryEntry;
|
||||
struct FileSystemInfo;
|
||||
}
|
||||
|
||||
@ -127,7 +129,7 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter {
|
||||
const base::File::Info& info);
|
||||
void DidReadDirectory(int request_id,
|
||||
base::File::Error result,
|
||||
std::vector<storage::DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool has_more);
|
||||
void DidWrite(int request_id,
|
||||
base::File::Error result,
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/compiler_specific.h"
|
||||
@ -181,21 +182,23 @@ void PluginPrivateDataByOriginChecker::OnDirectoryRead(
|
||||
storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil(
|
||||
storage::kFileSystemTypePluginPrivate);
|
||||
for (const auto& file : file_list) {
|
||||
DVLOG(3) << __func__ << " file: " << file.name;
|
||||
DCHECK(!file.is_directory); // Nested directories not implemented.
|
||||
DVLOG(3) << __func__ << " file: " << file.name.value();
|
||||
// Nested directories not implemented.
|
||||
DCHECK_NE(file.type, filesystem::mojom::FsFileType::DIRECTORY);
|
||||
|
||||
std::unique_ptr<storage::FileSystemOperationContext> operation_context =
|
||||
std::make_unique<storage::FileSystemOperationContext>(
|
||||
filesystem_context_);
|
||||
storage::FileSystemURL file_url = filesystem_context_->CrackURL(
|
||||
GURL(root + StringTypeToString(file.name)));
|
||||
GURL(root + StringTypeToString(file.name.value())));
|
||||
IncrementTaskCount();
|
||||
file_util->GetFileInfo(
|
||||
std::move(operation_context), file_url,
|
||||
storage::FileSystemOperation::GET_METADATA_FIELD_SIZE |
|
||||
storage::FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED,
|
||||
base::Bind(&PluginPrivateDataByOriginChecker::OnFileInfo,
|
||||
base::Unretained(this), StringTypeToString(file.name)));
|
||||
base::Unretained(this),
|
||||
StringTypeToString(file.name.value())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/files/file_util.h"
|
||||
@ -236,8 +237,9 @@ void PepperInternalFileRefBackend::ReadDirectoryComplete(
|
||||
dir_path += '/';
|
||||
|
||||
for (const auto& it : *accumulated_file_list) {
|
||||
file_types.push_back(it.is_directory ? PP_FILETYPE_DIRECTORY
|
||||
: PP_FILETYPE_REGULAR);
|
||||
file_types.push_back(it.type == filesystem::mojom::FsFileType::DIRECTORY
|
||||
? PP_FILETYPE_DIRECTORY
|
||||
: PP_FILETYPE_REGULAR);
|
||||
|
||||
ppapi::FileRefCreateInfo info;
|
||||
info.file_system_type = fs_type_;
|
||||
|
@ -328,6 +328,7 @@ source_set("common") {
|
||||
"//build/util:webkit_version",
|
||||
"//cc/ipc",
|
||||
"//components/discardable_memory/common",
|
||||
"//components/services/filesystem/public/interfaces",
|
||||
"//components/tracing",
|
||||
"//components/tracing:startup_tracing",
|
||||
"//components/viz/service",
|
||||
|
@ -9,9 +9,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
#include "storage/common/fileapi/file_system_info.h"
|
||||
#include "storage/common/fileapi/file_system_types.h"
|
||||
#include "storage/common/quota/quota_limit_type.h"
|
||||
@ -21,9 +24,9 @@
|
||||
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
|
||||
#define IPC_MESSAGE_START FileSystemMsgStart
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(storage::DirectoryEntry)
|
||||
IPC_STRUCT_TRAITS_BEGIN(filesystem::mojom::DirectoryEntry)
|
||||
IPC_STRUCT_TRAITS_MEMBER(name)
|
||||
IPC_STRUCT_TRAITS_MEMBER(is_directory)
|
||||
IPC_STRUCT_TRAITS_MEMBER(type)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(storage::FileSystemInfo)
|
||||
@ -32,6 +35,8 @@ IPC_STRUCT_TRAITS_BEGIN(storage::FileSystemInfo)
|
||||
IPC_STRUCT_TRAITS_MEMBER(mount_type)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(filesystem::mojom::FsFileType,
|
||||
filesystem::mojom::FsFileType::DIRECTORY)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(storage::FileSystemType,
|
||||
storage::FileSystemType::kFileSystemTypeLast)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(storage::QuotaLimitType, storage::kQuotaLimitTypeLast)
|
||||
@ -59,10 +64,11 @@ IPC_MESSAGE_CONTROL3(FileSystemMsg_DidCreateSnapshotFile,
|
||||
int /* request_id */,
|
||||
base::File::Info,
|
||||
base::FilePath /* true platform path */)
|
||||
IPC_MESSAGE_CONTROL3(FileSystemMsg_DidReadDirectory,
|
||||
int /* request_id */,
|
||||
std::vector<storage::DirectoryEntry> /* entries */,
|
||||
bool /* has_more */)
|
||||
IPC_MESSAGE_CONTROL3(
|
||||
FileSystemMsg_DidReadDirectory,
|
||||
int /* request_id */,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> /* entries */,
|
||||
bool /* has_more */)
|
||||
IPC_MESSAGE_CONTROL3(FileSystemMsg_DidWrite,
|
||||
int /* request_id */,
|
||||
int64_t /* byte count */,
|
||||
|
@ -5,12 +5,14 @@
|
||||
#include "content/renderer/fileapi/file_system_dispatcher.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/process/process.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/child/child_thread_impl.h"
|
||||
#include "content/common/fileapi/file_system_messages.h"
|
||||
#include "storage/common/fileapi/file_system_info.h"
|
||||
@ -19,15 +21,6 @@ namespace content {
|
||||
|
||||
class FileSystemDispatcher::CallbackDispatcher {
|
||||
public:
|
||||
typedef CallbackDispatcher self;
|
||||
typedef FileSystemDispatcher::StatusCallback StatusCallback;
|
||||
typedef FileSystemDispatcher::MetadataCallback MetadataCallback;
|
||||
typedef FileSystemDispatcher::ReadDirectoryCallback ReadDirectoryCallback;
|
||||
typedef FileSystemDispatcher::OpenFileSystemCallback OpenFileSystemCallback;
|
||||
typedef FileSystemDispatcher::ResolveURLCallback ResolveURLCallback;
|
||||
typedef FileSystemDispatcher::WriteCallback WriteCallback;
|
||||
typedef FileSystemDispatcher::OpenFileCallback OpenFileCallback;
|
||||
|
||||
static std::unique_ptr<CallbackDispatcher> Create(
|
||||
const StatusCallback& callback) {
|
||||
auto dispatcher = base::WrapUnique(new CallbackDispatcher);
|
||||
@ -86,9 +79,7 @@ class FileSystemDispatcher::CallbackDispatcher {
|
||||
|
||||
~CallbackDispatcher() {}
|
||||
|
||||
void DidSucceed() {
|
||||
status_callback_.Run(base::File::FILE_OK);
|
||||
}
|
||||
void DidSucceed() { status_callback_.Run(base::File::FILE_OK); }
|
||||
|
||||
void DidFail(base::File::Error error_code) {
|
||||
error_callback_.Run(error_code);
|
||||
@ -106,8 +97,9 @@ class FileSystemDispatcher::CallbackDispatcher {
|
||||
snapshot_callback_.Run(file_info, platform_path, request_id);
|
||||
}
|
||||
|
||||
void DidReadDirectory(const std::vector<storage::DirectoryEntry>& entries,
|
||||
bool has_more) {
|
||||
void DidReadDirectory(
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries,
|
||||
bool has_more) {
|
||||
directory_callback_.Run(entries, has_more);
|
||||
}
|
||||
|
||||
@ -376,7 +368,7 @@ void FileSystemDispatcher::OnDidCreateSnapshotFile(
|
||||
|
||||
void FileSystemDispatcher::OnDidReadDirectory(
|
||||
int request_id,
|
||||
const std::vector<storage::DirectoryEntry>& entries,
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries,
|
||||
bool has_more) {
|
||||
CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
|
||||
DCHECK(dispatcher);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -14,6 +15,7 @@
|
||||
#include "base/containers/id_map.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/process/process.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "ipc/ipc_listener.h"
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
#include "storage/common/fileapi/file_system_types.h"
|
||||
@ -24,7 +26,6 @@ class FilePath;
|
||||
}
|
||||
|
||||
namespace storage {
|
||||
struct DirectoryEntry;
|
||||
struct FileSystemInfo;
|
||||
}
|
||||
|
||||
@ -38,21 +39,24 @@ namespace content {
|
||||
class FileSystemDispatcher : public IPC::Listener {
|
||||
public:
|
||||
typedef base::Callback<void(base::File::Error error)> StatusCallback;
|
||||
typedef base::Callback<void(const base::File::Info& file_info)>
|
||||
MetadataCallback;
|
||||
typedef base::Callback<void(const base::File::Info& file_info,
|
||||
const base::FilePath& platform_path,
|
||||
int request_id)>
|
||||
CreateSnapshotFileCallback;
|
||||
|
||||
typedef base::Callback<void(
|
||||
const base::File::Info& file_info)> MetadataCallback;
|
||||
typedef base::Callback<void(
|
||||
const base::File::Info& file_info,
|
||||
const base::FilePath& platform_path,
|
||||
int request_id)> CreateSnapshotFileCallback;
|
||||
typedef base::Callback<
|
||||
void(const std::vector<storage::DirectoryEntry>& entries, bool has_more)>
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries,
|
||||
bool has_more)>
|
||||
ReadDirectoryCallback;
|
||||
typedef base::Callback<void(
|
||||
const std::string& name,
|
||||
const GURL& root)> OpenFileSystemCallback;
|
||||
typedef base::Callback<void(const std::string& name, const GURL& root)>
|
||||
OpenFileSystemCallback;
|
||||
typedef base::Callback<void(const storage::FileSystemInfo& info,
|
||||
const base::FilePath& file_path,
|
||||
bool is_directory)> ResolveURLCallback;
|
||||
bool is_directory)>
|
||||
ResolveURLCallback;
|
||||
|
||||
typedef base::Callback<void(int64_t bytes, bool complete)> WriteCallback;
|
||||
typedef base::Callback<void(base::PlatformFile file,
|
||||
int file_open_id,
|
||||
@ -78,9 +82,7 @@ class FileSystemDispatcher : public IPC::Listener {
|
||||
void Copy(const GURL& src_path,
|
||||
const GURL& dest_path,
|
||||
const StatusCallback& callback);
|
||||
void Remove(const GURL& path,
|
||||
bool recursive,
|
||||
const StatusCallback& callback);
|
||||
void Remove(const GURL& path, bool recursive, const StatusCallback& callback);
|
||||
void ReadMetadata(const GURL& path,
|
||||
const MetadataCallback& success_callback,
|
||||
const StatusCallback& error_callback);
|
||||
@ -107,8 +109,7 @@ class FileSystemDispatcher : public IPC::Listener {
|
||||
int* request_id_out,
|
||||
const WriteCallback& success_callback,
|
||||
const StatusCallback& error_callback);
|
||||
void Cancel(int request_id_to_cancel,
|
||||
const StatusCallback& callback);
|
||||
void Cancel(int request_id_to_cancel, const StatusCallback& callback);
|
||||
void TouchFile(const GURL& file_path,
|
||||
const base::Time& last_access_time,
|
||||
const base::Time& last_modified_time,
|
||||
@ -138,9 +139,10 @@ class FileSystemDispatcher : public IPC::Listener {
|
||||
void OnDidCreateSnapshotFile(int request_id,
|
||||
const base::File::Info& file_info,
|
||||
const base::FilePath& platform_path);
|
||||
void OnDidReadDirectory(int request_id,
|
||||
const std::vector<storage::DirectoryEntry>& entries,
|
||||
bool has_more);
|
||||
void OnDidReadDirectory(
|
||||
int request_id,
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries,
|
||||
bool has_more);
|
||||
void OnDidFail(int request_id, base::File::Error error_code);
|
||||
void OnDidWrite(int request_id, int64_t bytes, bool complete);
|
||||
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include "content/renderer/fileapi/webfilesystem_impl.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/lazy_instance.h"
|
||||
@ -15,12 +17,12 @@
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/thread_local.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "content/common/fileapi/file_system_messages.h"
|
||||
#include "content/renderer/file_info_util.h"
|
||||
#include "content/renderer/fileapi/file_system_dispatcher.h"
|
||||
#include "content/renderer/fileapi/webfilewriter_impl.h"
|
||||
#include "content/renderer/render_thread_impl.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
#include "storage/common/fileapi/file_system_util.h"
|
||||
#include "third_party/WebKit/public/platform/FilePathConversion.h"
|
||||
#include "third_party/WebKit/public/platform/WebFileInfo.h"
|
||||
@ -137,14 +139,16 @@ void DidReadMetadata(const base::File::Info& file_info,
|
||||
callbacks->DidReadMetadata(web_file_info);
|
||||
}
|
||||
|
||||
void DidReadDirectory(const std::vector<storage::DirectoryEntry>& entries,
|
||||
bool has_more,
|
||||
WebFileSystemCallbacks* callbacks) {
|
||||
void DidReadDirectory(
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries,
|
||||
bool has_more,
|
||||
WebFileSystemCallbacks* callbacks) {
|
||||
WebVector<WebFileSystemEntry> file_system_entries(entries.size());
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
file_system_entries[i].name =
|
||||
blink::FilePathToWebString(base::FilePath(entries[i].name));
|
||||
file_system_entries[i].is_directory = entries[i].is_directory;
|
||||
file_system_entries[i].is_directory =
|
||||
entries[i].type == filesystem::mojom::FsFileType::DIRECTORY;
|
||||
}
|
||||
callbacks->DidReadDirectory(file_system_entries, has_more);
|
||||
}
|
||||
@ -279,7 +283,7 @@ void ReadDirectoryCallbackAdapter(
|
||||
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
||||
int callbacks_id,
|
||||
WaitableCallbackResults* waitable_results,
|
||||
const std::vector<storage::DirectoryEntry>& entries,
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries,
|
||||
bool has_more) {
|
||||
CallbackFileSystemCallbacks(
|
||||
task_runner, callbacks_id, waitable_results,
|
||||
|
@ -1,11 +1,12 @@
|
||||
include_rules = [
|
||||
"+components/services/filesystem",
|
||||
"+mojo",
|
||||
"+net",
|
||||
"+services/network/public/cpp",
|
||||
"+services/network/public/mojom",
|
||||
"+sql",
|
||||
"+third_party/leveldatabase",
|
||||
"+third_party/sqlite",
|
||||
"+third_party/WebKit/public/mojom",
|
||||
"+third_party/WebKit/public/platform",
|
||||
"+third_party/leveldatabase",
|
||||
"+third_party/sqlite",
|
||||
]
|
||||
|
@ -208,6 +208,7 @@ component("browser") {
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"//components/services/filesystem/public/interfaces",
|
||||
"//storage/common",
|
||||
]
|
||||
deps = [
|
||||
@ -305,6 +306,7 @@ source_set("unittests") {
|
||||
":browser",
|
||||
":test_support",
|
||||
"//base/test:test_support",
|
||||
"//components/services/filesystem/public/interfaces",
|
||||
"//mojo/common",
|
||||
"//mojo/edk",
|
||||
"//net:test_support",
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "base/files/file.h"
|
||||
#include "base/files/file_util_proxy.h"
|
||||
#include "base/macros.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/fileapi/file_system_operation.h"
|
||||
#include "storage/browser/storage_browser_export.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
|
||||
namespace base {
|
||||
class Time;
|
||||
@ -65,7 +65,7 @@ class AsyncFileUtil {
|
||||
base::Callback<void(base::File::Error result,
|
||||
const base::File::Info& file_info)>;
|
||||
|
||||
using EntryList = std::vector<DirectoryEntry>;
|
||||
using EntryList = std::vector<filesystem::mojom::DirectoryEntry>;
|
||||
using ReadDirectoryCallback = base::RepeatingCallback<
|
||||
void(base::File::Error result, EntryList file_list, bool has_more)>;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/blob/shareable_file_reference.h"
|
||||
#include "storage/browser/fileapi/file_system_context.h"
|
||||
#include "storage/browser/fileapi/file_system_file_util.h"
|
||||
@ -102,7 +103,7 @@ void ReadDirectoryHelper(FileSystemFileUtil* file_util,
|
||||
if (error == base::File::FILE_OK && !file_info.is_directory)
|
||||
error = base::File::FILE_ERROR_NOT_A_DIRECTORY;
|
||||
|
||||
std::vector<DirectoryEntry> entries;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries;
|
||||
if (error != base::File::FILE_OK) {
|
||||
origin_runner->PostTask(FROM_HERE, base::BindOnce(callback, error, entries,
|
||||
false /* has_more */));
|
||||
@ -119,10 +120,10 @@ void ReadDirectoryHelper(FileSystemFileUtil* file_util,
|
||||
|
||||
base::FilePath current;
|
||||
while (!(current = file_enum->Next()).empty()) {
|
||||
DirectoryEntry entry;
|
||||
entry.is_directory = file_enum->IsDirectory();
|
||||
entry.name = VirtualPath::BaseName(current).value();
|
||||
entries.push_back(entry);
|
||||
entries.emplace_back(VirtualPath::BaseName(current),
|
||||
file_enum->IsDirectory()
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
|
||||
if (entries.size() == kResultChunkSize) {
|
||||
origin_runner->PostTask(
|
||||
|
@ -4,8 +4,11 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/containers/queue.h"
|
||||
@ -19,6 +22,7 @@
|
||||
#include "base/stl_util.h"
|
||||
#include "base/test/scoped_task_environment.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/fileapi/copy_or_move_file_validator.h"
|
||||
#include "storage/browser/fileapi/copy_or_move_operation_delegate.h"
|
||||
#include "storage/browser/fileapi/file_stream_reader.h"
|
||||
@ -335,7 +339,7 @@ class CopyOrMoveOperationTestHelper {
|
||||
root.virtual_path().AppendRelativePath(url.virtual_path(), &relative);
|
||||
relative = relative.NormalizePathSeparators();
|
||||
ASSERT_TRUE(base::ContainsKey(test_case_map, relative));
|
||||
if (entries[i].is_directory) {
|
||||
if (entries[i].type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
EXPECT_TRUE(test_case_map[relative]->is_directory);
|
||||
directories.push(url);
|
||||
} else {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/time/time.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/fileapi/dragged_file_util.h"
|
||||
#include "storage/browser/fileapi/file_system_context.h"
|
||||
#include "storage/browser/fileapi/file_system_operation_context.h"
|
||||
@ -210,9 +211,9 @@ class DraggedFileUtilTest : public testing::Test {
|
||||
AsyncFileTestHelper::ReadDirectory(
|
||||
file_system_context(), dir, &entries));
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
FileSystemURL url = GetEntryURL(file_system_context(),
|
||||
dir, entries[i].name);
|
||||
if (entries[i].is_directory) {
|
||||
FileSystemURL url =
|
||||
GetEntryURL(file_system_context(), dir, entries[i].name.value());
|
||||
if (entries[i].type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
directories.push(url);
|
||||
continue;
|
||||
}
|
||||
@ -229,11 +230,11 @@ class DraggedFileUtilTest : public testing::Test {
|
||||
AsyncFileTestHelper::ReadDirectory(
|
||||
file_system_context(), dir, &entries));
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
FileSystemURL url2 = GetEntryURL(file_system_context(),
|
||||
dir, entries[i].name);
|
||||
FileSystemURL url2 =
|
||||
GetEntryURL(file_system_context(), dir, entries[i].name.value());
|
||||
FileSystemURL url1 = GetOtherURL(file_system_context(),
|
||||
root2, root1, url2);
|
||||
if (entries[i].is_directory) {
|
||||
if (entries[i].type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
directories.push(url2);
|
||||
EXPECT_EQ(IsDirectoryEmpty(file_system_context(), url1),
|
||||
IsDirectoryEmpty(file_system_context(), url2));
|
||||
@ -360,7 +361,8 @@ TEST_F(DraggedFileUtilTest, ReadDirectoryTest) {
|
||||
<< ": " << test_case.path);
|
||||
|
||||
// Read entries in the directory to construct the expected results map.
|
||||
typedef std::map<base::FilePath::StringType, storage::DirectoryEntry>
|
||||
typedef std::map<base::FilePath::StringType,
|
||||
filesystem::mojom::DirectoryEntry>
|
||||
EntryMap;
|
||||
EntryMap expected_entry_map;
|
||||
|
||||
@ -371,10 +373,13 @@ TEST_F(DraggedFileUtilTest, ReadDirectoryTest) {
|
||||
base::FilePath current;
|
||||
while (!(current = file_enum.Next()).empty()) {
|
||||
base::FileEnumerator::FileInfo file_info = file_enum.GetInfo();
|
||||
storage::DirectoryEntry entry;
|
||||
entry.is_directory = file_info.IsDirectory();
|
||||
entry.name = current.BaseName().value();
|
||||
expected_entry_map[entry.name] = entry;
|
||||
filesystem::mojom::DirectoryEntry entry;
|
||||
entry.type = file_info.IsDirectory()
|
||||
? filesystem::mojom::FsFileType::DIRECTORY
|
||||
: filesystem::mojom::FsFileType::REGULAR_FILE;
|
||||
|
||||
entry.name = current.BaseName();
|
||||
expected_entry_map[entry.name.value()] = entry;
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_FUCHSIA)
|
||||
// Creates a symlink for each file/directory.
|
||||
@ -396,11 +401,11 @@ TEST_F(DraggedFileUtilTest, ReadDirectoryTest) {
|
||||
|
||||
EXPECT_EQ(expected_entry_map.size(), entries.size());
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
const storage::DirectoryEntry& entry = entries[i];
|
||||
EntryMap::iterator found = expected_entry_map.find(entry.name);
|
||||
const filesystem::mojom::DirectoryEntry& entry = entries[i];
|
||||
EntryMap::iterator found = expected_entry_map.find(entry.name.value());
|
||||
EXPECT_TRUE(found != expected_entry_map.end());
|
||||
EXPECT_EQ(found->second.name, entry.name);
|
||||
EXPECT_EQ(found->second.is_directory, entry.is_directory);
|
||||
EXPECT_EQ(found->second.type, entry.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,12 +445,12 @@ TEST_F(DraggedFileUtilTest, CopyOutFileTest) {
|
||||
AsyncFileTestHelper::ReadDirectory(file_system_context(),
|
||||
dir, &entries));
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
FileSystemURL src_url = GetEntryURL(file_system_context(),
|
||||
dir, entries[i].name);
|
||||
FileSystemURL src_url =
|
||||
GetEntryURL(file_system_context(), dir, entries[i].name.value());
|
||||
FileSystemURL dest_url = GetOtherURL(file_system_context(),
|
||||
src_root, dest_root, src_url);
|
||||
|
||||
if (entries[i].is_directory) {
|
||||
if (entries[i].type == filesystem::mojom::FsFileType::DIRECTORY) {
|
||||
ASSERT_EQ(base::File::FILE_OK,
|
||||
AsyncFileTestHelper::CreateDirectory(file_system_context(),
|
||||
dest_url));
|
||||
@ -475,10 +480,10 @@ TEST_F(DraggedFileUtilTest, CopyOutDirectoryTest) {
|
||||
AsyncFileTestHelper::ReadDirectory(file_system_context(),
|
||||
src_root, &entries));
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
if (!entries[i].is_directory)
|
||||
if (entries[i].type != filesystem::mojom::FsFileType::DIRECTORY)
|
||||
continue;
|
||||
FileSystemURL src_url = GetEntryURL(file_system_context(),
|
||||
src_root, entries[i].name);
|
||||
FileSystemURL src_url =
|
||||
GetEntryURL(file_system_context(), src_root, entries[i].name.value());
|
||||
FileSystemURL dest_url = GetOtherURL(file_system_context(),
|
||||
src_root, dest_root, src_url);
|
||||
SCOPED_TRACE(testing::Message() << "Testing file copy "
|
||||
|
@ -17,12 +17,12 @@
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/time/time.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "net/base/directory_listing.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
#include "storage/browser/fileapi/file_system_context.h"
|
||||
#include "storage/browser/fileapi/file_system_operation_runner.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
#include "storage/common/fileapi/file_system_util.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
@ -93,8 +93,7 @@ void FileSystemDirURLRequestJob::StartAsync() {
|
||||
if (url_.is_valid() && VirtualPath::IsRootPath(url_.virtual_path())) {
|
||||
// Return an empty directory if the filesystem root is queried.
|
||||
DidReadDirectory(base::File::FILE_OK,
|
||||
std::vector<DirectoryEntry>(),
|
||||
false);
|
||||
std::vector<filesystem::mojom::DirectoryEntry>(), false);
|
||||
return;
|
||||
}
|
||||
NotifyStartError(URLRequestStatus::FromError(net::ERR_FILE_NOT_FOUND));
|
||||
@ -116,7 +115,7 @@ void FileSystemDirURLRequestJob::DidAttemptAutoMount(base::File::Error result) {
|
||||
|
||||
void FileSystemDirURLRequestJob::DidReadDirectory(
|
||||
base::File::Error result,
|
||||
std::vector<DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool has_more) {
|
||||
if (result != base::File::FILE_OK) {
|
||||
int rv = net::ERR_FILE_NOT_FOUND;
|
||||
@ -152,7 +151,7 @@ void FileSystemDirURLRequestJob::DidReadDirectory(
|
||||
}
|
||||
|
||||
void FileSystemDirURLRequestJob::GetMetadata(size_t index) {
|
||||
const DirectoryEntry& entry = entries_[index];
|
||||
const filesystem::mojom::DirectoryEntry& entry = entries_[index];
|
||||
const FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL(
|
||||
url_.origin(), url_.type(),
|
||||
url_.path().Append(base::FilePath(entry.name)));
|
||||
@ -178,11 +177,12 @@ void FileSystemDirURLRequestJob::DidGetMetadata(
|
||||
if (!request_)
|
||||
return;
|
||||
|
||||
const DirectoryEntry& entry = entries_[index];
|
||||
const filesystem::mojom::DirectoryEntry& entry = entries_[index];
|
||||
const base::string16& name = base::FilePath(entry.name).LossyDisplayName();
|
||||
data_.append(net::GetDirectoryListingEntry(name, std::string(),
|
||||
entry.is_directory, file_info.size,
|
||||
file_info.last_modified));
|
||||
data_.append(net::GetDirectoryListingEntry(
|
||||
name, std::string(),
|
||||
entry.type == filesystem::mojom::FsFileType::DIRECTORY, file_info.size,
|
||||
file_info.last_modified));
|
||||
|
||||
if (index < entries_.size() - 1) {
|
||||
GetMetadata(index + 1);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "net/url_request/url_request_job.h"
|
||||
#include "storage/browser/fileapi/file_system_url.h"
|
||||
#include "storage/browser/storage_browser_export.h"
|
||||
@ -21,7 +22,6 @@
|
||||
namespace storage {
|
||||
|
||||
class FileSystemContext;
|
||||
struct DirectoryEntry;
|
||||
|
||||
// A request job that handles reading filesystem: URLs for directories.
|
||||
class STORAGE_EXPORT FileSystemDirURLRequestJob : public net::URLRequestJob {
|
||||
@ -51,7 +51,7 @@ class STORAGE_EXPORT FileSystemDirURLRequestJob : public net::URLRequestJob {
|
||||
void StartAsync();
|
||||
void DidAttemptAutoMount(base::File::Error result);
|
||||
void DidReadDirectory(base::File::Error result,
|
||||
std::vector<DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool has_more);
|
||||
|
||||
// Reads metadata for the |index|-th entry in the directory. Must be called
|
||||
@ -61,7 +61,7 @@ class STORAGE_EXPORT FileSystemDirURLRequestJob : public net::URLRequestJob {
|
||||
base::File::Error result,
|
||||
const base::File::Info& file_info);
|
||||
|
||||
std::vector<DirectoryEntry> entries_;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries_;
|
||||
std::string data_;
|
||||
FileSystemURL url_;
|
||||
const std::string storage_domain_;
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "base/files/file.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/process/process.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/fileapi/file_system_operation_context.h"
|
||||
#include "storage/browser/storage_browser_export.h"
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
|
||||
namespace base {
|
||||
class Time;
|
||||
@ -83,7 +83,7 @@ class FileSystemOperation {
|
||||
OpenFileCallback;
|
||||
|
||||
// Used for ReadDirectoryCallback.
|
||||
typedef std::vector<DirectoryEntry> FileEntryList;
|
||||
typedef std::vector<filesystem::mojom::DirectoryEntry> FileEntryList;
|
||||
|
||||
// Used for ReadDirectory(). |result| is the return code of the operation,
|
||||
// |file_list| is the list of files read, and |has_more| is true if some files
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
@ -21,6 +23,7 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/test/scoped_task_environment.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/blob/shareable_file_reference.h"
|
||||
#include "storage/browser/fileapi/file_system_context.h"
|
||||
#include "storage/browser/fileapi/file_system_file_util.h"
|
||||
@ -94,7 +97,7 @@ class FileSystemOperationImplTest
|
||||
|
||||
const base::File::Info& info() const { return info_; }
|
||||
const base::FilePath& path() const { return path_; }
|
||||
const std::vector<storage::DirectoryEntry>& entries() const {
|
||||
const std::vector<filesystem::mojom::DirectoryEntry>& entries() const {
|
||||
return entries_;
|
||||
}
|
||||
|
||||
@ -217,7 +220,7 @@ class FileSystemOperationImplTest
|
||||
void DidReadDirectory(base::RepeatingClosure closure,
|
||||
base::File::Error* status,
|
||||
base::File::Error actual,
|
||||
std::vector<storage::DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool /* has_more */) {
|
||||
entries_ = std::move(entries);
|
||||
*status = actual;
|
||||
@ -477,7 +480,7 @@ class FileSystemOperationImplTest
|
||||
// For post-operation status.
|
||||
base::File::Info info_;
|
||||
base::FilePath path_;
|
||||
std::vector<storage::DirectoryEntry> entries_;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries_;
|
||||
scoped_refptr<ShareableFileReference> shareable_file_ref_;
|
||||
|
||||
storage::MockFileChangeObserver change_observer_;
|
||||
@ -1019,10 +1022,10 @@ TEST_F(FileSystemOperationImplTest, TestReadDirSuccess) {
|
||||
EXPECT_EQ(2u, entries().size());
|
||||
|
||||
for (size_t i = 0; i < entries().size(); ++i) {
|
||||
if (entries()[i].is_directory)
|
||||
EXPECT_EQ(FILE_PATH_LITERAL("child_dir"), entries()[i].name);
|
||||
if (entries()[i].type == filesystem::mojom::FsFileType::DIRECTORY)
|
||||
EXPECT_EQ(FILE_PATH_LITERAL("child_dir"), entries()[i].name.value());
|
||||
else
|
||||
EXPECT_EQ(FILE_PATH_LITERAL("child_file"), entries()[i].name);
|
||||
EXPECT_EQ(FILE_PATH_LITERAL("child_file"), entries()[i].name.value());
|
||||
}
|
||||
EXPECT_EQ(1, quota_manager_proxy()->notify_storage_accessed_count());
|
||||
EXPECT_TRUE(change_observer()->HasNoChange());
|
||||
|
@ -228,7 +228,7 @@ OperationID FileSystemOperationRunner::ReadDirectory(
|
||||
BeginOperation(std::move(operation), scope.AsWeakPtr());
|
||||
if (!operation_raw) {
|
||||
DidReadDirectory(handle, std::move(callback), error,
|
||||
std::vector<DirectoryEntry>(), false);
|
||||
std::vector<filesystem::mojom::DirectoryEntry>(), false);
|
||||
return handle.id;
|
||||
}
|
||||
PrepareForRead(handle.id, url);
|
||||
@ -588,7 +588,7 @@ void FileSystemOperationRunner::DidReadDirectory(
|
||||
const OperationHandle& handle,
|
||||
const ReadDirectoryCallback& callback,
|
||||
base::File::Error rv,
|
||||
std::vector<DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool has_more) {
|
||||
if (handle.scope) {
|
||||
finished_operations_.insert(handle.id);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "base/containers/id_map.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/blob/blob_data_handle.h"
|
||||
#include "storage/browser/fileapi/file_system_operation.h"
|
||||
#include "storage/browser/fileapi/file_system_url.h"
|
||||
@ -269,7 +270,7 @@ class STORAGE_EXPORT FileSystemOperationRunner
|
||||
void DidReadDirectory(const OperationHandle& handle,
|
||||
const ReadDirectoryCallback& callback,
|
||||
base::File::Error rv,
|
||||
std::vector<DirectoryEntry> entries,
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries,
|
||||
bool has_more);
|
||||
void DidWrite(const OperationHandle& handle,
|
||||
const WriteCallback& callback,
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "base/test/scoped_task_environment.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/services/filesystem/public/interfaces/types.mojom.h"
|
||||
#include "storage/browser/fileapi/external_mount_points.h"
|
||||
#include "storage/browser/fileapi/file_system_backend.h"
|
||||
#include "storage/browser/fileapi/file_system_context.h"
|
||||
@ -457,7 +458,7 @@ class ObfuscatedFileUtilTest : public testing::Test {
|
||||
std::set<base::FilePath::StringType>* files,
|
||||
std::set<base::FilePath::StringType>* directories) {
|
||||
std::unique_ptr<FileSystemOperationContext> context;
|
||||
std::vector<storage::DirectoryEntry> entries;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries;
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
AsyncFileTestHelper::ReadDirectory(file_system_context(),
|
||||
root_url, &entries));
|
||||
@ -499,27 +500,27 @@ class ObfuscatedFileUtilTest : public testing::Test {
|
||||
FillTestDirectory(root_url, &files, &directories);
|
||||
|
||||
std::unique_ptr<FileSystemOperationContext> context;
|
||||
std::vector<storage::DirectoryEntry> entries;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries;
|
||||
context.reset(NewContext(NULL));
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
AsyncFileTestHelper::ReadDirectory(
|
||||
file_system_context(), root_url, &entries));
|
||||
std::vector<storage::DirectoryEntry>::iterator entry_iter;
|
||||
std::vector<filesystem::mojom::DirectoryEntry>::iterator entry_iter;
|
||||
EXPECT_EQ(files.size() + directories.size(), entries.size());
|
||||
EXPECT_TRUE(change_observer()->HasNoChange());
|
||||
for (entry_iter = entries.begin(); entry_iter != entries.end();
|
||||
++entry_iter) {
|
||||
const storage::DirectoryEntry& entry = *entry_iter;
|
||||
const filesystem::mojom::DirectoryEntry& entry = *entry_iter;
|
||||
std::set<base::FilePath::StringType>::iterator iter =
|
||||
files.find(entry.name);
|
||||
files.find(entry.name.value());
|
||||
if (iter != files.end()) {
|
||||
EXPECT_FALSE(entry.is_directory);
|
||||
EXPECT_EQ(entry.type, filesystem::mojom::FsFileType::REGULAR_FILE);
|
||||
files.erase(iter);
|
||||
continue;
|
||||
}
|
||||
iter = directories.find(entry.name);
|
||||
iter = directories.find(entry.name.value());
|
||||
EXPECT_FALSE(directories.end() == iter);
|
||||
EXPECT_TRUE(entry.is_directory);
|
||||
EXPECT_EQ(entry.type, filesystem::mojom::FsFileType::DIRECTORY);
|
||||
directories.erase(iter);
|
||||
}
|
||||
}
|
||||
@ -1233,7 +1234,7 @@ TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) {
|
||||
ofu()->EnsureFileExists(context.get(), url, &created));
|
||||
ASSERT_TRUE(created);
|
||||
|
||||
std::vector<storage::DirectoryEntry> entries;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries;
|
||||
EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY,
|
||||
AsyncFileTestHelper::ReadDirectory(file_system_context(), url,
|
||||
&entries));
|
||||
@ -1811,7 +1812,7 @@ TEST_F(ObfuscatedFileUtilTest, TestIncompleteDirectoryReading) {
|
||||
EXPECT_TRUE(created);
|
||||
}
|
||||
|
||||
std::vector<storage::DirectoryEntry> entries;
|
||||
std::vector<filesystem::mojom::DirectoryEntry> entries;
|
||||
EXPECT_EQ(base::File::FILE_OK,
|
||||
AsyncFileTestHelper::ReadDirectory(
|
||||
file_system_context(), empty_path, &entries));
|
||||
|
@ -118,7 +118,7 @@ void RecursiveOperationDelegate::DidReadDirectory(const FileSystemURL& parent,
|
||||
parent.origin(),
|
||||
parent.mount_type(),
|
||||
parent.virtual_path().Append(entries[i].name));
|
||||
if (entries[i].is_directory)
|
||||
if (entries[i].type == filesystem::mojom::FsFileType::DIRECTORY)
|
||||
pending_directory_stack_.top().push(url);
|
||||
else
|
||||
pending_files_.push(url);
|
||||
|
@ -15,8 +15,6 @@ component("common") {
|
||||
"database/database_connections.h",
|
||||
"database/database_identifier.cc",
|
||||
"database/database_identifier.h",
|
||||
"fileapi/directory_entry.cc",
|
||||
"fileapi/directory_entry.h",
|
||||
"fileapi/file_system_info.cc",
|
||||
"fileapi/file_system_info.h",
|
||||
"fileapi/file_system_mount_option.h",
|
||||
@ -38,6 +36,7 @@ component("common") {
|
||||
defines = [ "STORAGE_COMMON_IMPLEMENTATION" ]
|
||||
|
||||
public_deps = [
|
||||
"//components/services/filesystem/public/interfaces",
|
||||
"//services/network/public/mojom",
|
||||
"//third_party/WebKit/public:blink_headers",
|
||||
]
|
||||
|
@ -1,15 +0,0 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "storage/common/fileapi/directory_entry.h"
|
||||
|
||||
namespace storage {
|
||||
|
||||
DirectoryEntry::DirectoryEntry() : is_directory(false) {}
|
||||
|
||||
DirectoryEntry::DirectoryEntry(const std::string& name, DirectoryEntryType type)
|
||||
: name(base::FilePath::FromUTF8Unsafe(name).value()),
|
||||
is_directory(type == DIRECTORY) {}
|
||||
|
||||
} // namespace storage
|
@ -1,32 +0,0 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef STORAGE_COMMON_FILEAPI_DIRECTORY_ENTRY_H_
|
||||
#define STORAGE_COMMON_FILEAPI_DIRECTORY_ENTRY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/time/time.h"
|
||||
#include "storage/common/storage_common_export.h"
|
||||
|
||||
namespace storage {
|
||||
|
||||
// Holds metadata for file or directory entry.
|
||||
struct STORAGE_COMMON_EXPORT DirectoryEntry {
|
||||
enum DirectoryEntryType {
|
||||
FILE,
|
||||
DIRECTORY,
|
||||
};
|
||||
|
||||
DirectoryEntry();
|
||||
DirectoryEntry(const std::string& name, DirectoryEntryType type);
|
||||
|
||||
base::FilePath::StringType name;
|
||||
bool is_directory;
|
||||
};
|
||||
|
||||
} // namespace storage
|
||||
|
||||
#endif // STORAGE_COMMON_FILEAPI_DIRECTORY_ENTRY_H_
|
Reference in New Issue
Block a user