diff options
Diffstat (limited to 'chromium/components/filesystem')
18 files changed, 95 insertions, 117 deletions
diff --git a/chromium/components/filesystem/directory_impl.cc b/chromium/components/filesystem/directory_impl.cc index 745bcf66aac..64114de9348 100644 --- a/chromium/components/filesystem/directory_impl.cc +++ b/chromium/components/filesystem/directory_impl.cc @@ -11,13 +11,12 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "components/filesystem/file_impl.h" #include "components/filesystem/lock_table.h" #include "components/filesystem/util.h" -#include "mojo/common/common_type_converters.h" #include "mojo/public/cpp/bindings/strong_binding.h" -#include "mojo/public/cpp/system/platform_handle.h" namespace filesystem { @@ -92,9 +91,9 @@ void DirectoryImpl::OpenFile(const std::string& raw_path, void DirectoryImpl::OpenFileHandle(const std::string& raw_path, uint32_t open_flags, const OpenFileHandleCallback& callback) { - mojom::FileError error = mojom::FileError::OK; - mojo::ScopedHandle handle = OpenFileHandleImpl(raw_path, open_flags, &error); - callback.Run(error, std::move(handle)); + base::File file = OpenFileHandleImpl(raw_path, open_flags); + mojom::FileError error = GetError(file); + callback.Run(error, std::move(file)); } void DirectoryImpl::OpenFileHandles( @@ -105,8 +104,8 @@ void DirectoryImpl::OpenFileHandles( for (const auto& detail : details) { mojom::FileOpenResultPtr result(mojom::FileOpenResult::New()); result->path = detail->path; - result->file_handle = - OpenFileHandleImpl(detail->path, detail->open_flags, &result->error); + result->file_handle = OpenFileHandleImpl(detail->path, detail->open_flags); + result->error = GetError(result->file_handle); results[i++] = std::move(result); } callback.Run(std::move(results)); @@ -224,7 +223,8 @@ void DirectoryImpl::IsWritable(const std::string& raw_path, } void DirectoryImpl::Flush(const FlushCallback& callback) { - base::File file(directory_path_, base::File::FLAG_READ); + base::File file(directory_path_, + base::File::FLAG_OPEN | base::File::FLAG_READ); if (!file.IsValid()) { callback.Run(GetError(file)); return; @@ -290,14 +290,14 @@ void DirectoryImpl::ReadEntireFile(const std::string& raw_path, return; } - std::string contents; + std::vector<uint8_t> contents; const int kBufferSize = 1 << 16; std::unique_ptr<char[]> buf(new char[kBufferSize]); int len; while ((len = base_file.ReadAtCurrentPos(buf.get(), kBufferSize)) > 0) - contents.append(buf.get(), len); + contents.insert(contents.end(), buf.get(), buf.get() + len); - callback.Run(mojom::FileError::OK, mojo::Array<uint8_t>::From(contents)); + callback.Run(mojom::FileError::OK, contents); } void DirectoryImpl::WriteFile(const std::string& raw_path, @@ -335,31 +335,21 @@ void DirectoryImpl::WriteFile(const std::string& raw_path, callback.Run(mojom::FileError::OK); } -mojo::ScopedHandle DirectoryImpl::OpenFileHandleImpl( - const std::string& raw_path, - uint32_t open_flags, - mojom::FileError* error) { +base::File DirectoryImpl::OpenFileHandleImpl(const std::string& raw_path, + uint32_t open_flags) { base::FilePath path; - *error = ValidatePath(raw_path, directory_path_, &path); - if (*error != mojom::FileError::OK) - return mojo::ScopedHandle(); + mojom::FileError error = ValidatePath(raw_path, directory_path_, &path); + if (error != mojom::FileError::OK) + return base::File(static_cast<base::File::Error>(error)); if (base::DirectoryExists(path)) { // We must not return directories as files. In the file abstraction, we // can fetch raw file descriptors over mojo pipes, and passing a file // descriptor to a directory is a sandbox escape on Windows. - *error = mojom::FileError::NOT_A_FILE; - return mojo::ScopedHandle(); - } - - base::File base_file(path, open_flags); - if (!base_file.IsValid()) { - *error = GetError(base_file); - return mojo::ScopedHandle(); + return base::File(base::File::FILE_ERROR_NOT_A_FILE); } - *error = mojom::FileError::OK; - return mojo::WrapPlatformFile(base_file.TakePlatformFile()); + return base::File(path, open_flags); } } // namespace filesystem diff --git a/chromium/components/filesystem/directory_impl.h b/chromium/components/filesystem/directory_impl.h index 9f1a141de49..e226b78508e 100644 --- a/chromium/components/filesystem/directory_impl.h +++ b/chromium/components/filesystem/directory_impl.h @@ -64,9 +64,8 @@ class DirectoryImpl : public mojom::Directory { const WriteFileCallback& callback) override; private: - mojo::ScopedHandle OpenFileHandleImpl(const std::string& raw_path, - uint32_t open_flags, - mojom::FileError* error); + base::File OpenFileHandleImpl(const std::string& raw_path, + uint32_t open_flags); base::FilePath directory_path_; scoped_refptr<SharedTempDir> temp_dir_; diff --git a/chromium/components/filesystem/directory_impl_unittest.cc b/chromium/components/filesystem/directory_impl_unittest.cc index 836d21ae39c..38410a2f765 100644 --- a/chromium/components/filesystem/directory_impl_unittest.cc +++ b/chromium/components/filesystem/directory_impl_unittest.cc @@ -10,13 +10,14 @@ #include "base/macros.h" #include "components/filesystem/files_test_base.h" -#include "mojo/common/common_type_converters.h" namespace filesystem { namespace { using DirectoryImplTest = FilesTestBase; +constexpr char kData[] = "one two three"; + TEST_F(DirectoryImplTest, Read) { mojom::DirectoryPtr directory; GetTemporaryRoot(&directory); @@ -135,7 +136,7 @@ TEST_F(DirectoryImplTest, CantOpenDirectoriesAsFiles) { mojom::DirectoryPtr my_file_directory; error = mojom::FileError::FAILED; bool handled = directory->OpenDirectory( - "my_file", GetProxy(&my_file_directory), + "my_file", MakeRequest(&my_file_directory), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -146,7 +147,7 @@ TEST_F(DirectoryImplTest, CantOpenDirectoriesAsFiles) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_A_FILE, error); @@ -162,17 +163,16 @@ TEST_F(DirectoryImplTest, Clone) { mojom::DirectoryPtr directory; GetTemporaryRoot(&directory); - directory->Clone(GetProxy(&clone_one)); - directory->Clone(GetProxy(&clone_two)); + directory->Clone(MakeRequest(&clone_one)); + directory->Clone(MakeRequest(&clone_two)); // Original temporary directory goes out of scope here; shouldn't be // deleted since it has clones. } - std::string data("one two three"); + std::vector<uint8_t> data(kData, kData + strlen(kData)); { - bool handled = - clone_one->WriteFile("data", mojo::Array<uint8_t>::From(data), &error); + bool handled = clone_one->WriteFile("data", data, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -183,8 +183,7 @@ TEST_F(DirectoryImplTest, Clone) { ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); - EXPECT_EQ(data, - mojo::Array<uint8_t>(std::move(file_contents)).To<std::string>()); + EXPECT_EQ(data, file_contents); } } @@ -193,10 +192,9 @@ TEST_F(DirectoryImplTest, WriteFileReadFile) { GetTemporaryRoot(&directory); mojom::FileError error; - std::string data("one two three"); + std::vector<uint8_t> data(kData, kData + strlen(kData)); { - bool handled = - directory->WriteFile("data", mojo::Array<uint8_t>::From(data), &error); + bool handled = directory->WriteFile("data", data, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -207,8 +205,7 @@ TEST_F(DirectoryImplTest, WriteFileReadFile) { ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); - EXPECT_EQ(data, - mojo::Array<uint8_t>(std::move(file_contents)).To<std::string>()); + EXPECT_EQ(data, file_contents); } } @@ -236,7 +233,7 @@ TEST_F(DirectoryImplTest, CantReadEntireFileOnADirectory) { mojom::DirectoryPtr my_file_directory; error = mojom::FileError::FAILED; bool handled = directory->OpenDirectory( - "my_dir", GetProxy(&my_file_directory), + "my_dir", MakeRequest(&my_file_directory), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -261,21 +258,32 @@ TEST_F(DirectoryImplTest, CantWriteFileOnADirectory) { mojom::DirectoryPtr my_file_directory; error = mojom::FileError::FAILED; bool handled = directory->OpenDirectory( - "my_dir", GetProxy(&my_file_directory), + "my_dir", MakeRequest(&my_file_directory), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } { - std::string data("one two three"); - bool handled = directory->WriteFile( - "my_dir", mojo::Array<uint8_t>::From(data), &error); + std::vector<uint8_t> data(kData, kData + strlen(kData)); + bool handled = directory->WriteFile("my_dir", data, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_A_FILE, error); } } +TEST_F(DirectoryImplTest, Flush) { + mojom::DirectoryPtr directory; + GetTemporaryRoot(&directory); + mojom::FileError error; + + { + bool handled = directory->Flush(&error); + ASSERT_TRUE(handled); + EXPECT_EQ(mojom::FileError::OK, error); + } +} + // TODO(vtl): Test delete flags. } // namespace diff --git a/chromium/components/filesystem/file_impl.cc b/chromium/components/filesystem/file_impl.cc index 25a76f3d26b..a2c024f3922 100644 --- a/chromium/components/filesystem/file_impl.cc +++ b/chromium/components/filesystem/file_impl.cc @@ -12,19 +12,17 @@ #include "base/files/file_path.h" #include "base/files/scoped_file.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "components/filesystem/lock_table.h" #include "components/filesystem/shared_temp_dir.h" #include "components/filesystem/util.h" -#include "mojo/common/common_type_converters.h" #include "mojo/public/cpp/bindings/strong_binding.h" -#include "mojo/public/cpp/system/platform_handle.h" static_assert(sizeof(off_t) <= sizeof(int64_t), "off_t too big"); static_assert(sizeof(size_t) >= sizeof(uint32_t), "size_t too small"); using base::Time; -using mojo::ScopedHandle; namespace filesystem { namespace { @@ -327,19 +325,19 @@ void FileImpl::Unlock(const UnlockCallback& callback) { void FileImpl::AsHandle(const AsHandleCallback& callback) { if (!file_.IsValid()) { - callback.Run(GetError(file_), ScopedHandle()); + callback.Run(GetError(file_), base::File()); return; } base::File new_file = file_.Duplicate(); if (!new_file.IsValid()) { - callback.Run(GetError(new_file), ScopedHandle()); + callback.Run(GetError(new_file), base::File()); return; } base::File::Info info; if (!new_file.GetInfo(&info)) { - callback.Run(mojom::FileError::FAILED, ScopedHandle()); + callback.Run(mojom::FileError::FAILED, base::File()); return; } @@ -348,12 +346,11 @@ void FileImpl::AsHandle(const AsHandleCallback& callback) { // passing a file descriptor to a directory is a sandbox escape on Windows, // we should be absolutely paranoid. if (info.is_directory) { - callback.Run(mojom::FileError::NOT_A_FILE, ScopedHandle()); + callback.Run(mojom::FileError::NOT_A_FILE, base::File()); return; } - callback.Run(mojom::FileError::OK, - mojo::WrapPlatformFile(new_file.TakePlatformFile())); + callback.Run(mojom::FileError::OK, std::move(new_file)); } } // namespace filesystem diff --git a/chromium/components/filesystem/file_impl_unittest.cc b/chromium/components/filesystem/file_impl_unittest.cc index 81544b488c4..492c243c647 100644 --- a/chromium/components/filesystem/file_impl_unittest.cc +++ b/chromium/components/filesystem/file_impl_unittest.cc @@ -11,7 +11,6 @@ #include "components/filesystem/files_test_base.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/type_converter.h" -#include "mojo/public/cpp/system/platform_handle.h" namespace filesystem { namespace { @@ -29,7 +28,7 @@ TEST_F(FileImplTest, CreateWriteCloseRenameOpenRead) { mojom::FilePtr file; error = mojom::FileError::FAILED; handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -67,7 +66,7 @@ TEST_F(FileImplTest, CreateWriteCloseRenameOpenRead) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("your_file", GetProxy(&file), + directory->OpenFile("your_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -105,7 +104,7 @@ TEST_F(FileImplTest, CantWriteInReadMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -131,7 +130,7 @@ TEST_F(FileImplTest, CantWriteInReadMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -164,7 +163,7 @@ TEST_F(FileImplTest, OpenInAppendMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -196,7 +195,7 @@ TEST_F(FileImplTest, OpenInAppendMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagAppend | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -230,7 +229,7 @@ TEST_F(FileImplTest, OpenInAppendMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -260,7 +259,7 @@ TEST_F(FileImplTest, OpenInTruncateMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -292,7 +291,7 @@ TEST_F(FileImplTest, OpenInTruncateMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file), + "my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagOpenTruncated, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -326,7 +325,7 @@ TEST_F(FileImplTest, OpenInTruncateMode) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -357,7 +356,7 @@ TEST_F(FileImplTest, StatTouch) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -428,7 +427,7 @@ TEST_F(FileImplTest, TellSeek) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -514,7 +513,7 @@ TEST_F(FileImplTest, Dup) { mojom::FilePtr file1; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file1), + "my_file", MakeRequest(&file1), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -538,7 +537,7 @@ TEST_F(FileImplTest, Dup) { // Dup it. mojom::FilePtr file2; error = mojom::FileError::FAILED; - handled = file1->Dup(GetProxy(&file2), &error); + handled = file1->Dup(MakeRequest(&file2), &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -608,7 +607,7 @@ TEST_F(FileImplTest, Truncate) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file), + directory->OpenFile("my_file", MakeRequest(&file), mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -658,26 +657,18 @@ TEST_F(FileImplTest, AsHandle) { mojom::FilePtr file1; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file1), + "my_file", MakeRequest(&file1), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); - // Fetch the handle + // Fetch the file. error = mojom::FileError::FAILED; - mojo::ScopedHandle handle; - handled = file1->AsHandle(&error, &handle); + base::File raw_file; + handled = file1->AsHandle(&error, &raw_file); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); - // Pull a file descriptor out of the scoped handle. - base::PlatformFile platform_file; - MojoResult unwrap_result = mojo::UnwrapPlatformFile(std::move(handle), - &platform_file); - EXPECT_EQ(MOJO_RESULT_OK, unwrap_result); - - // Pass this raw file descriptor to a base::File. - base::File raw_file(platform_file); ASSERT_TRUE(raw_file.IsValid()); EXPECT_EQ(5, raw_file.WriteAtCurrentPos("hello", 5)); } @@ -687,7 +678,7 @@ TEST_F(FileImplTest, AsHandle) { mojom::FilePtr file2; error = mojom::FileError::FAILED; bool handled = - directory->OpenFile("my_file", GetProxy(&file2), + directory->OpenFile("my_file", MakeRequest(&file2), mojom::kFlagRead | mojom::kFlagOpen, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -717,7 +708,7 @@ TEST_F(FileImplTest, SimpleLockUnlock) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file), + "my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -744,7 +735,7 @@ TEST_F(FileImplTest, CantDoubleLock) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file), + "my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -772,7 +763,7 @@ TEST_F(FileImplTest, ClosingFileClearsLock) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file), + "my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagOpenAlways, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); @@ -789,7 +780,7 @@ TEST_F(FileImplTest, ClosingFileClearsLock) { mojom::FilePtr file; error = mojom::FileError::FAILED; bool handled = directory->OpenFile( - "my_file", GetProxy(&file), + "my_file", MakeRequest(&file), mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagOpenAlways, &error); ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); diff --git a/chromium/components/filesystem/file_system_app.cc b/chromium/components/filesystem/file_system_app.cc index ac41d092048..dd1d24b0108 100644 --- a/chromium/components/filesystem/file_system_app.cc +++ b/chromium/components/filesystem/file_system_app.cc @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" +#include "base/memory/ptr_util.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "services/service_manager/public/cpp/connection.h" #include "services/service_manager/public/cpp/connector.h" diff --git a/chromium/components/filesystem/file_system_app.h b/chromium/components/filesystem/file_system_app.h index 53ea98d976c..b3f399d8df0 100644 --- a/chromium/components/filesystem/file_system_app.h +++ b/chromium/components/filesystem/file_system_app.h @@ -14,10 +14,6 @@ #include "services/service_manager/public/cpp/service.h" #include "services/tracing/public/cpp/provider.h" -namespace mojo { -class Connector; -} - namespace filesystem { class FileSystemApp diff --git a/chromium/components/filesystem/file_system_impl.cc b/chromium/components/filesystem/file_system_impl.cc index 1fbed03db25..138524d5394 100644 --- a/chromium/components/filesystem/file_system_impl.cc +++ b/chromium/components/filesystem/file_system_impl.cc @@ -14,6 +14,7 @@ #include "base/files/scoped_file.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "components/filesystem/directory_impl.h" #include "components/filesystem/lock_table.h" diff --git a/chromium/components/filesystem/file_system_impl.h b/chromium/components/filesystem/file_system_impl.h index 573fd31b4e8..7f41b357804 100644 --- a/chromium/components/filesystem/file_system_impl.h +++ b/chromium/components/filesystem/file_system_impl.h @@ -20,7 +20,6 @@ class Identity; } namespace filesystem { -class FileSystemApp; class LockTable; diff --git a/chromium/components/filesystem/files_test_base.cc b/chromium/components/filesystem/files_test_base.cc index 7be764b85ff..facb600b2e1 100644 --- a/chromium/components/filesystem/files_test_base.cc +++ b/chromium/components/filesystem/files_test_base.cc @@ -21,12 +21,12 @@ FilesTestBase::~FilesTestBase() { void FilesTestBase::SetUp() { ServiceTest::SetUp(); - connector()->ConnectToInterface("filesystem", &files_); + connector()->BindInterface("filesystem", &files_); } void FilesTestBase::GetTemporaryRoot(mojom::DirectoryPtr* directory) { mojom::FileError error = mojom::FileError::FAILED; - bool handled = files()->OpenTempDirectory(GetProxy(directory), &error); + bool handled = files()->OpenTempDirectory(MakeRequest(directory), &error); ASSERT_TRUE(handled); ASSERT_EQ(mojom::FileError::OK, error); } diff --git a/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc b/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc index 0a5d66091f6..25cf238d629 100644 --- a/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc +++ b/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc @@ -23,7 +23,6 @@ #include "base/time/default_clock.h" #include "base/values.h" #include "components/prefs/pref_filter.h" -#include "mojo/common/common_type_converters.h" namespace filesystem { @@ -48,7 +47,7 @@ FilesystemJsonPrefStore::ReadResult::~ReadResult() {} namespace { PersistentPrefStore::PrefReadError HandleReadErrors(const base::Value* value) { - if (!value->IsType(base::Value::TYPE_DICTIONARY)) + if (!value->IsType(base::Value::Type::DICTIONARY)) return PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; return PersistentPrefStore::PREF_READ_ERROR_NONE; } @@ -334,10 +333,10 @@ void FilesystemJsonPrefStore::PerformWrite() { void FilesystemJsonPrefStore::OpenFilesystem(base::Closure callback) { filesystem::mojom::FileSystemClientPtr client; - binding_.Bind(GetProxy(&client)); + binding_.Bind(MakeRequest(&client)); filesystem_->OpenFileSystem( - "origin", GetProxy(&directory_), std::move(client), + "origin", MakeRequest(&directory_), std::move(client), base::Bind(&FilesystemJsonPrefStore::OnOpenFilesystem, AsWeakPtr(), callback)); } @@ -366,8 +365,7 @@ void FilesystemJsonPrefStore::OnTempFileWriteStart() { serializer.Serialize(*prefs_); directory_->WriteFile( - "tmp", - mojo::Array<uint8_t>::From(output), + "tmp", std::vector<uint8_t>(output.begin(), output.end()), Bind(&FilesystemJsonPrefStore::OnTempFileWrite, AsWeakPtr())); } diff --git a/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h b/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h index d52b0ec1c2f..ed04ae2b5e6 100644 --- a/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h +++ b/chromium/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h @@ -31,9 +31,7 @@ class PrefFilter; namespace base { -class Clock; class DictionaryValue; -class FilePath; class JsonPrefStoreLossyWriteTest; class Value; } diff --git a/chromium/components/filesystem/public/cpp/prefs/pref_service_factory.cc b/chromium/components/filesystem/public/cpp/prefs/pref_service_factory.cc index a1374783eec..e9ca2b95226 100644 --- a/chromium/components/filesystem/public/cpp/prefs/pref_service_factory.cc +++ b/chromium/components/filesystem/public/cpp/prefs/pref_service_factory.cc @@ -27,7 +27,7 @@ std::unique_ptr<PrefService> CreatePrefService( service_manager::Connector* connector, PrefRegistry* pref_registry) { filesystem::mojom::FileSystemPtr filesystem; - connector->ConnectToInterface("filesystem", &filesystem); + connector->BindInterface("filesystem", &filesystem); scoped_refptr<FilesystemJsonPrefStore> user_prefs = new FilesystemJsonPrefStore("preferences.json", std::move(filesystem), diff --git a/chromium/components/filesystem/public/interfaces/BUILD.gn b/chromium/components/filesystem/public/interfaces/BUILD.gn index a1ef7b67574..b65d3a797eb 100644 --- a/chromium/components/filesystem/public/interfaces/BUILD.gn +++ b/chromium/components/filesystem/public/interfaces/BUILD.gn @@ -11,4 +11,7 @@ mojom("interfaces") { "file_system.mojom", "types.mojom", ] + public_deps = [ + "//mojo/common:common_custom_types", + ] } diff --git a/chromium/components/filesystem/public/interfaces/directory.mojom b/chromium/components/filesystem/public/interfaces/directory.mojom index 104a62f5528..ac3370e8e45 100644 --- a/chromium/components/filesystem/public/interfaces/directory.mojom +++ b/chromium/components/filesystem/public/interfaces/directory.mojom @@ -6,6 +6,7 @@ module filesystem.mojom; import "components/filesystem/public/interfaces/file.mojom"; import "components/filesystem/public/interfaces/types.mojom"; +import "mojo/common/file.mojom"; struct FileOpenDetails { string path; @@ -15,7 +16,7 @@ struct FileOpenDetails { struct FileOpenResult { string path; FileError error; - handle file_handle; + mojo.common.mojom.File? file_handle; }; // This interface provides access to a directory in a "file system", providing @@ -46,7 +47,7 @@ interface Directory { // native file descriptor wrapped in a MojoHandle. [Sync] OpenFileHandle(string path, uint32 open_flags) - => (FileError error, handle file_handle); + => (FileError error, mojo.common.mojom.File? file_handle); // Like OpenFileHandle, but opens multiple files. [Sync] diff --git a/chromium/components/filesystem/public/interfaces/file.mojom b/chromium/components/filesystem/public/interfaces/file.mojom index 05bce45cbf2..9a4a515c749 100644 --- a/chromium/components/filesystem/public/interfaces/file.mojom +++ b/chromium/components/filesystem/public/interfaces/file.mojom @@ -10,6 +10,7 @@ module filesystem.mojom; import "components/filesystem/public/interfaces/types.mojom"; +import "mojo/common/file.mojom"; // TODO(vtl): Write comments. interface File { @@ -84,5 +85,5 @@ interface File { // Returns a handle to the file for raw access. [Sync] - AsHandle() => (FileError error, handle file_handle); + AsHandle() => (FileError error, mojo.common.mojom.File? file_handle); }; diff --git a/chromium/components/filesystem/util.cc b/chromium/components/filesystem/util.cc index d9257cc0b2d..ecd3fc61c0e 100644 --- a/chromium/components/filesystem/util.cc +++ b/chromium/components/filesystem/util.cc @@ -14,7 +14,6 @@ #include "base/logging.h" #include "base/strings/string_util.h" #include "build/build_config.h" -#include "mojo/public/cpp/bindings/string.h" #if defined(OS_WIN) #include "base/strings/utf_string_conversions.h" diff --git a/chromium/components/filesystem/util.h b/chromium/components/filesystem/util.h index b00fcf56f0d..70fe7e744f9 100644 --- a/chromium/components/filesystem/util.h +++ b/chromium/components/filesystem/util.h @@ -10,10 +10,6 @@ #include "base/files/file.h" #include "components/filesystem/public/interfaces/types.mojom.h" -namespace mojo { -class String; -} - namespace filesystem { // Validation functions (typically used to check arguments; they return |
