diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/filesystem/BUILD.gn | 37 | ||||
-rw-r--r-- | components/filesystem/directory_unittest.cc (renamed from components/filesystem/directory_impl_unittest.cc) | 0 | ||||
-rw-r--r-- | components/filesystem/file_unittest.cc (renamed from components/filesystem/file_impl_unittest.cc) | 2 | ||||
-rw-r--r-- | components/filesystem/files_test_base.cc | 2 | ||||
-rw-r--r-- | components/filesystem/main.cc | 13 | ||||
-rw-r--r-- | components/filesystem/posix/directory_posix.cc (renamed from components/filesystem/directory_impl.cc) | 56 | ||||
-rw-r--r-- | components/filesystem/posix/directory_posix.h (renamed from components/filesystem/directory_impl.h) | 18 | ||||
-rw-r--r-- | components/filesystem/posix/file_posix.cc (renamed from components/filesystem/file_impl.cc) | 83 | ||||
-rw-r--r-- | components/filesystem/posix/file_posix.h (renamed from components/filesystem/file_impl.h) | 14 | ||||
-rw-r--r-- | components/filesystem/posix/file_system_posix.cc (renamed from components/filesystem/file_system_impl.cc) | 24 | ||||
-rw-r--r-- | components/filesystem/posix/file_system_posix.h | 43 | ||||
-rw-r--r-- | components/filesystem/posix/shared_posix.cc (renamed from components/filesystem/shared_impl.cc) | 2 | ||||
-rw-r--r-- | components/filesystem/posix/shared_posix.h (renamed from components/filesystem/shared_impl.h) | 6 | ||||
-rw-r--r-- | components/filesystem/win/file_system_win.cc | 37 | ||||
-rw-r--r-- | components/filesystem/win/file_system_win.h (renamed from components/filesystem/file_system_impl.h) | 18 |
15 files changed, 232 insertions, 123 deletions
diff --git a/components/filesystem/BUILD.gn b/components/filesystem/BUILD.gn index 55dd7e7..9d02401 100644 --- a/components/filesystem/BUILD.gn +++ b/components/filesystem/BUILD.gn @@ -6,21 +6,36 @@ import("//third_party/mojo/src/mojo/public/mojo_application.gni") mojo_native_application("filesystem") { sources = [ - "directory_impl.cc", - "directory_impl.h", - "file_impl.cc", - "file_impl.h", - "file_system_impl.cc", - "file_system_impl.h", "futimens.h", - "futimens_android.cc", "main.cc", - "shared_impl.cc", - "shared_impl.h", "util.cc", "util.h", ] + if (is_android) { + sources += [ "futimens_android.cc" ] + } + + if (is_posix) { + sources += [ + "posix/directory_posix.cc", + "posix/directory_posix.h", + "posix/file_posix.cc", + "posix/file_posix.h", + "posix/file_system_posix.cc", + "posix/file_system_posix.h", + "posix/shared_posix.cc", + "posix/shared_posix.h", + ] + } + + if (is_win) { + sources += [ + "win/file_system_win.cc", + "win/file_system_win.h", + ] + } + deps = [ "//base", "//components/filesystem/public/interfaces", @@ -38,8 +53,8 @@ mojo_native_application("apptests") { testonly = true sources = [ - "directory_impl_unittest.cc", - "file_impl_unittest.cc", + "directory_unittest.cc", + "file_unittest.cc", "files_test_base.cc", "files_test_base.h", ] diff --git a/components/filesystem/directory_impl_unittest.cc b/components/filesystem/directory_unittest.cc index c702295..c702295 100644 --- a/components/filesystem/directory_impl_unittest.cc +++ b/components/filesystem/directory_unittest.cc diff --git a/components/filesystem/file_impl_unittest.cc b/components/filesystem/file_unittest.cc index 543f6ee..bfdfb39 100644 --- a/components/filesystem/file_impl_unittest.cc +++ b/components/filesystem/file_unittest.cc @@ -152,7 +152,7 @@ TEST_F(FileImplTest, OpenExclusive) { FilePtr file; error = ERROR_INTERNAL; directory->OpenFile("temp_file", GetProxy(&file), - kOpenFlagWrite | kOpenFlagCreate |kOpenFlagExclusive, + kOpenFlagWrite | kOpenFlagCreate | kOpenFlagExclusive, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingMethodCall()); EXPECT_EQ(ERROR_OK, error); diff --git a/components/filesystem/files_test_base.cc b/components/filesystem/files_test_base.cc index b9d39dc..6c7de97 100644 --- a/components/filesystem/files_test_base.cc +++ b/components/filesystem/files_test_base.cc @@ -20,7 +20,7 @@ void FilesTestBase::SetUp() { ApplicationTestBase::SetUp(); mojo::URLRequestPtr request(mojo::URLRequest::New()); - request->url = mojo::String::From("mojo:files"); + request->url = mojo::String::From("mojo:filesystem"); application_impl()->ConnectToService(request.Pass(), &files_); } diff --git a/components/filesystem/main.cc b/components/filesystem/main.cc index 4bb58d5..68c8b74 100644 --- a/components/filesystem/main.cc +++ b/components/filesystem/main.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/macros.h" -#include "components/filesystem/file_system_impl.h" #include "components/filesystem/public/interfaces/file_system.mojom.h" #include "mojo/application/public/cpp/application_connection.h" #include "mojo/application/public/cpp/application_delegate.h" @@ -11,6 +10,10 @@ #include "mojo/application/public/cpp/interface_factory.h" #include "mojo/public/c/system/main.h" +#if defined(OS_POSIX) +#include "components/filesystem/posix/file_system_posix.h" +#endif + namespace filesystem { class FilesApp : public mojo::ApplicationDelegate, @@ -30,7 +33,13 @@ class FilesApp : public mojo::ApplicationDelegate, // |InterfaceFactory<Files>| implementation: void Create(mojo::ApplicationConnection* connection, mojo::InterfaceRequest<FileSystem> request) override { - new FileSystemImpl(connection, request.Pass()); +#if defined(OS_POSIX) + new FileSystemPosix(connection, request.Pass()); +#elif defined(OS_WIN) + new FileSystemWin(connection, request.Pass()); +#else +#error "Only Posix and Windows are valid file systems right now." +#endif } DISALLOW_COPY_AND_ASSIGN(FilesApp); diff --git a/components/filesystem/directory_impl.cc b/components/filesystem/posix/directory_posix.cc index 085ded1..7364762 100644 --- a/components/filesystem/directory_impl.cc +++ b/components/filesystem/posix/directory_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/filesystem/directory_impl.h" +#include "components/filesystem/posix/directory_posix.h" #include <dirent.h> #include <errno.h> @@ -17,8 +17,8 @@ #include "base/memory/scoped_ptr.h" #include "base/posix/eintr_wrapper.h" #include "build/build_config.h" -#include "components/filesystem/file_impl.h" -#include "components/filesystem/shared_impl.h" +#include "components/filesystem/posix/file_posix.h" +#include "components/filesystem/posix/shared_posix.h" #include "components/filesystem/util.h" namespace filesystem { @@ -33,19 +33,19 @@ using ScopedDIR = scoped_ptr<DIR, DIRDeleter>; } // namespace -DirectoryImpl::DirectoryImpl(mojo::InterfaceRequest<Directory> request, - base::ScopedFD dir_fd, - scoped_ptr<base::ScopedTempDir> temp_dir) +DirectoryPosix::DirectoryPosix(mojo::InterfaceRequest<Directory> request, + base::ScopedFD dir_fd, + scoped_ptr<base::ScopedTempDir> temp_dir) : binding_(this, request.Pass()), dir_fd_(dir_fd.Pass()), temp_dir_(temp_dir.Pass()) { DCHECK(dir_fd_.is_valid()); } -DirectoryImpl::~DirectoryImpl() { +DirectoryPosix::~DirectoryPosix() { } -void DirectoryImpl::Read(const ReadCallback& callback) { +void DirectoryPosix::Read(const ReadCallback& callback) { static const size_t kMaxReadCount = 1000; DCHECK(dir_fd_.is_valid()); @@ -109,23 +109,23 @@ void DirectoryImpl::Read(const ReadCallback& callback) { callback.Run(ERROR_OK, result.Pass()); } -void DirectoryImpl::Stat(const StatCallback& callback) { +void DirectoryPosix::Stat(const StatCallback& callback) { DCHECK(dir_fd_.is_valid()); StatFD(dir_fd_.get(), FILE_TYPE_DIRECTORY, callback); } -void DirectoryImpl::Touch(TimespecOrNowPtr atime, - TimespecOrNowPtr mtime, - const TouchCallback& callback) { +void DirectoryPosix::Touch(TimespecOrNowPtr atime, + TimespecOrNowPtr mtime, + const TouchCallback& callback) { DCHECK(dir_fd_.is_valid()); TouchFD(dir_fd_.get(), atime.Pass(), mtime.Pass(), callback); } // TODO(vtl): Move the implementation to a thread pool. -void DirectoryImpl::OpenFile(const mojo::String& path, - mojo::InterfaceRequest<File> file, - uint32_t open_flags, - const OpenFileCallback& callback) { +void DirectoryPosix::OpenFile(const mojo::String& path, + mojo::InterfaceRequest<File> file, + uint32_t open_flags, + const OpenFileCallback& callback) { DCHECK(!path.is_null()); DCHECK(dir_fd_.is_valid()); @@ -163,14 +163,14 @@ void DirectoryImpl::OpenFile(const mojo::String& path, } if (file.is_pending()) - new FileImpl(file.Pass(), file_fd.Pass()); + new FilePosix(file.Pass(), file_fd.Pass()); callback.Run(ERROR_OK); } -void DirectoryImpl::OpenDirectory(const mojo::String& path, - mojo::InterfaceRequest<Directory> directory, - uint32_t open_flags, - const OpenDirectoryCallback& callback) { +void DirectoryPosix::OpenDirectory(const mojo::String& path, + mojo::InterfaceRequest<Directory> directory, + uint32_t open_flags, + const OpenDirectoryCallback& callback) { DCHECK(!path.is_null()); DCHECK(dir_fd_.is_valid()); @@ -212,13 +212,13 @@ void DirectoryImpl::OpenDirectory(const mojo::String& path, } if (directory.is_pending()) - new DirectoryImpl(directory.Pass(), new_dir_fd.Pass(), nullptr); + new DirectoryPosix(directory.Pass(), new_dir_fd.Pass(), nullptr); callback.Run(ERROR_OK); } -void DirectoryImpl::Rename(const mojo::String& path, - const mojo::String& new_path, - const RenameCallback& callback) { +void DirectoryPosix::Rename(const mojo::String& path, + const mojo::String& new_path, + const RenameCallback& callback) { DCHECK(!path.is_null()); DCHECK(!new_path.is_null()); DCHECK(dir_fd_.is_valid()); @@ -242,9 +242,9 @@ void DirectoryImpl::Rename(const mojo::String& path, callback.Run(ERROR_OK); } -void DirectoryImpl::Delete(const mojo::String& path, - uint32_t delete_flags, - const DeleteCallback& callback) { +void DirectoryPosix::Delete(const mojo::String& path, + uint32_t delete_flags, + const DeleteCallback& callback) { DCHECK(!path.is_null()); DCHECK(dir_fd_.is_valid()); diff --git a/components/filesystem/directory_impl.h b/components/filesystem/posix/directory_posix.h index f06ebc2..d45356c 100644 --- a/components/filesystem/directory_impl.h +++ b/components/filesystem/posix/directory_posix.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ -#define COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ +#ifndef COMPONENTS_FILESYSTEM_POSIX_DIRECTORY_POSIX_H_ +#define COMPONENTS_FILESYSTEM_POSIX_DIRECTORY_POSIX_H_ #include "base/files/scoped_file.h" #include "base/macros.h" @@ -18,14 +18,14 @@ class ScopedTempDir; namespace filesystem { -class DirectoryImpl : public Directory { +class DirectoryPosix : public Directory { public: // Set |temp_dir| only if there's a temporary directory that should be deleted // when this object is destroyed. - DirectoryImpl(mojo::InterfaceRequest<Directory> request, - base::ScopedFD dir_fd, - scoped_ptr<base::ScopedTempDir> temp_dir); - ~DirectoryImpl() override; + DirectoryPosix(mojo::InterfaceRequest<Directory> request, + base::ScopedFD dir_fd, + scoped_ptr<base::ScopedTempDir> temp_dir); + ~DirectoryPosix() override; // |Directory| implementation: void Read(const ReadCallback& callback) override; @@ -53,9 +53,9 @@ class DirectoryImpl : public Directory { base::ScopedFD dir_fd_; scoped_ptr<base::ScopedTempDir> temp_dir_; - DISALLOW_COPY_AND_ASSIGN(DirectoryImpl); + DISALLOW_COPY_AND_ASSIGN(DirectoryPosix); }; } // namespace filesystem -#endif // COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ +#endif // COMPONENTS_FILESYSTEM_POSIX_DIRECTORY_POSIX_H_ diff --git a/components/filesystem/file_impl.cc b/components/filesystem/posix/file_posix.cc index bb524e6..fab20a4 100644 --- a/components/filesystem/file_impl.cc +++ b/components/filesystem/posix/file_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/filesystem/file_impl.h" +#include "components/filesystem/posix/file_posix.h" #include <errno.h> #include <fcntl.h> @@ -15,7 +15,7 @@ #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" -#include "components/filesystem/shared_impl.h" +#include "components/filesystem/posix/shared_posix.h" #include "components/filesystem/util.h" static_assert(sizeof(off_t) <= sizeof(int64_t), "off_t too big"); @@ -25,15 +25,16 @@ namespace filesystem { const size_t kMaxReadSize = 1 * 1024 * 1024; // 1 MB. -FileImpl::FileImpl(mojo::InterfaceRequest<File> request, base::ScopedFD file_fd) +FilePosix::FilePosix(mojo::InterfaceRequest<File> request, + base::ScopedFD file_fd) : binding_(this, request.Pass()), file_fd_(file_fd.Pass()) { DCHECK(file_fd_.is_valid()); } -FileImpl::~FileImpl() { +FilePosix::~FilePosix() { } -void FileImpl::Close(const CloseCallback& callback) { +void FilePosix::Close(const CloseCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -58,10 +59,10 @@ void FileImpl::Close(const CloseCallback& callback) { } // TODO(vtl): Move the implementation to a thread pool. -void FileImpl::Read(uint32_t num_bytes_to_read, - int64_t offset, - Whence whence, - const ReadCallback& callback) { +void FilePosix::Read(uint32_t num_bytes_to_read, + int64_t offset, + Whence whence, + const ReadCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED, mojo::Array<uint8_t>()); return; @@ -107,10 +108,10 @@ void FileImpl::Read(uint32_t num_bytes_to_read, } // TODO(vtl): Move the implementation to a thread pool. -void FileImpl::Write(mojo::Array<uint8_t> bytes_to_write, - int64_t offset, - Whence whence, - const WriteCallback& callback) { +void FilePosix::Write(mojo::Array<uint8_t> bytes_to_write, + int64_t offset, + Whence whence, + const WriteCallback& callback) { DCHECK(!bytes_to_write.is_null()); if (!file_fd_.is_valid()) { @@ -162,11 +163,11 @@ void FileImpl::Write(mojo::Array<uint8_t> bytes_to_write, callback.Run(ERROR_OK, static_cast<uint32_t>(num_bytes_written)); } -void FileImpl::ReadToStream(mojo::ScopedDataPipeProducerHandle source, - int64_t offset, - Whence whence, - int64_t num_bytes_to_read, - const ReadToStreamCallback& callback) { +void FilePosix::ReadToStream(mojo::ScopedDataPipeProducerHandle source, + int64_t offset, + Whence whence, + int64_t num_bytes_to_read, + const ReadToStreamCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -185,10 +186,10 @@ void FileImpl::ReadToStream(mojo::ScopedDataPipeProducerHandle source, callback.Run(ERROR_UNIMPLEMENTED); } -void FileImpl::WriteFromStream(mojo::ScopedDataPipeConsumerHandle sink, - int64_t offset, - Whence whence, - const WriteFromStreamCallback& callback) { +void FilePosix::WriteFromStream(mojo::ScopedDataPipeConsumerHandle sink, + int64_t offset, + Whence whence, + const WriteFromStreamCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -207,13 +208,13 @@ void FileImpl::WriteFromStream(mojo::ScopedDataPipeConsumerHandle sink, callback.Run(ERROR_UNIMPLEMENTED); } -void FileImpl::Tell(const TellCallback& callback) { +void FilePosix::Tell(const TellCallback& callback) { Seek(0, WHENCE_FROM_CURRENT, callback); } -void FileImpl::Seek(int64_t offset, - Whence whence, - const SeekCallback& callback) { +void FilePosix::Seek(int64_t offset, + Whence whence, + const SeekCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED, 0); return; @@ -237,7 +238,7 @@ void FileImpl::Seek(int64_t offset, callback.Run(ERROR_OK, static_cast<int64>(position)); } -void FileImpl::Stat(const StatCallback& callback) { +void FilePosix::Stat(const StatCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED, nullptr); return; @@ -245,7 +246,7 @@ void FileImpl::Stat(const StatCallback& callback) { StatFD(file_fd_.get(), FILE_TYPE_REGULAR_FILE, callback); } -void FileImpl::Truncate(int64_t size, const TruncateCallback& callback) { +void FilePosix::Truncate(int64_t size, const TruncateCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -267,9 +268,9 @@ void FileImpl::Truncate(int64_t size, const TruncateCallback& callback) { callback.Run(ERROR_OK); } -void FileImpl::Touch(TimespecOrNowPtr atime, - TimespecOrNowPtr mtime, - const TouchCallback& callback) { +void FilePosix::Touch(TimespecOrNowPtr atime, + TimespecOrNowPtr mtime, + const TouchCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -277,8 +278,8 @@ void FileImpl::Touch(TimespecOrNowPtr atime, TouchFD(file_fd_.get(), atime.Pass(), mtime.Pass(), callback); } -void FileImpl::Dup(mojo::InterfaceRequest<File> file, - const DupCallback& callback) { +void FilePosix::Dup(mojo::InterfaceRequest<File> file, + const DupCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -290,13 +291,13 @@ void FileImpl::Dup(mojo::InterfaceRequest<File> file, return; } - new FileImpl(file.Pass(), file_fd.Pass()); + new FilePosix(file.Pass(), file_fd.Pass()); callback.Run(ERROR_OK); } -void FileImpl::Reopen(mojo::InterfaceRequest<File> file, - uint32_t open_flags, - const ReopenCallback& callback) { +void FilePosix::Reopen(mojo::InterfaceRequest<File> file, + uint32_t open_flags, + const ReopenCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED); return; @@ -307,7 +308,7 @@ void FileImpl::Reopen(mojo::InterfaceRequest<File> file, callback.Run(ERROR_UNIMPLEMENTED); } -void FileImpl::AsBuffer(const AsBufferCallback& callback) { +void FilePosix::AsBuffer(const AsBufferCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED, mojo::ScopedSharedBufferHandle()); return; @@ -318,9 +319,9 @@ void FileImpl::AsBuffer(const AsBufferCallback& callback) { callback.Run(ERROR_UNIMPLEMENTED, mojo::ScopedSharedBufferHandle()); } -void FileImpl::Ioctl(uint32_t request, - mojo::Array<uint32_t> in_values, - const IoctlCallback& callback) { +void FilePosix::Ioctl(uint32_t request, + mojo::Array<uint32_t> in_values, + const IoctlCallback& callback) { if (!file_fd_.is_valid()) { callback.Run(ERROR_CLOSED, mojo::Array<uint32_t>()); return; diff --git a/components/filesystem/file_impl.h b/components/filesystem/posix/file_posix.h index 32eb730..417a216 100644 --- a/components/filesystem/file_impl.h +++ b/components/filesystem/posix/file_posix.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_FILESYSTEM_FILE_IMPL_H_ -#define COMPONENTS_FILESYSTEM_FILE_IMPL_H_ +#ifndef COMPONENTS_FILESYSTEM_POSIX_FILE_POSIX_H_ +#define COMPONENTS_FILESYSTEM_POSIX_FILE_POSIX_H_ #include "base/files/scoped_file.h" #include "base/macros.h" @@ -13,11 +13,11 @@ namespace filesystem { -class FileImpl : public File { +class FilePosix : public File { public: // TODO(vtl): Will need more for, e.g., |Reopen()|. - FileImpl(mojo::InterfaceRequest<File> request, base::ScopedFD file_fd); - ~FileImpl() override; + FilePosix(mojo::InterfaceRequest<File> request, base::ScopedFD file_fd); + ~FilePosix() override; // |File| implementation: void Close(const CloseCallback& callback) override; @@ -61,9 +61,9 @@ class FileImpl : public File { mojo::StrongBinding<File> binding_; base::ScopedFD file_fd_; - DISALLOW_COPY_AND_ASSIGN(FileImpl); + DISALLOW_COPY_AND_ASSIGN(FilePosix); }; } // namespace filesystem -#endif // COMPONENTS_FILESYSTEM_FILE_IMPL_H_ +#endif // COMPONENTS_FILESYSTEM_POSIX_FILE_POSIX_H_ diff --git a/components/filesystem/file_system_impl.cc b/components/filesystem/posix/file_system_posix.cc index 1ce5d25..3c5f06d 100644 --- a/components/filesystem/file_system_impl.cc +++ b/components/filesystem/posix/file_system_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/filesystem/file_system_impl.h" +#include "components/filesystem/posix/file_system_posix.h" #include <fcntl.h> #include <stdlib.h> @@ -16,7 +16,8 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/posix/eintr_wrapper.h" -#include "components/filesystem/directory_impl.h" +#include "components/filesystem/posix/directory_posix.h" +#include "mojo/application/public/cpp/application_connection.h" namespace filesystem { @@ -50,18 +51,19 @@ base::ScopedFD OpenMojoDebugDirectory() { } // namespace -FileSystemImpl::FileSystemImpl(mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<FileSystem> request) - : binding_(this, request.Pass()) { - // TODO(vtl): record other app's URL +FileSystemPosix::FileSystemPosix(mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<FileSystem> request) + : remote_application_url_(connection->GetRemoteApplicationURL()), + binding_(this, request.Pass()) { } -FileSystemImpl::~FileSystemImpl() { +FileSystemPosix::~FileSystemPosix() { } -void FileSystemImpl::OpenFileSystem(const mojo::String& file_system, - mojo::InterfaceRequest<Directory> directory, - const OpenFileSystemCallback& callback) { +void FileSystemPosix::OpenFileSystem( + const mojo::String& file_system, + mojo::InterfaceRequest<Directory> directory, + const OpenFileSystemCallback& callback) { base::ScopedFD dir_fd; // Set only if the |DirectoryImpl| will own a temporary directory. scoped_ptr<base::ScopedTempDir> temp_dir; @@ -87,7 +89,7 @@ void FileSystemImpl::OpenFileSystem(const mojo::String& file_system, return; } - new DirectoryImpl(directory.Pass(), dir_fd.Pass(), temp_dir.Pass()); + new DirectoryPosix(directory.Pass(), dir_fd.Pass(), temp_dir.Pass()); callback.Run(ERROR_OK); } diff --git a/components/filesystem/posix/file_system_posix.h b/components/filesystem/posix/file_system_posix.h new file mode 100644 index 0000000..9093f66 --- /dev/null +++ b/components/filesystem/posix/file_system_posix.h @@ -0,0 +1,43 @@ +// Copyright 2015 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 COMPONENTS_FILESYSTEM_POSIX_FILE_SYSTEM_POSIX_H_ +#define COMPONENTS_FILESYSTEM_POSIX_FILE_SYSTEM_POSIX_H_ + +#include "base/macros.h" +#include "components/filesystem/public/interfaces/file_system.mojom.h" +#include "mojo/public/cpp/bindings/interface_request.h" +#include "mojo/public/cpp/bindings/strong_binding.h" + +namespace mojo { +class ApplicationConnection; +} + +namespace filesystem { + +class FileSystemPosix : public FileSystem { + public: + FileSystemPosix(mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<FileSystem> request); + ~FileSystemPosix() override; + + // |Files| implementation: + // We provide a "private" temporary file system as the default. In Debug + // builds, we also provide access to a common file system named "debug" + // (stored under ~/MojoDebug). + void OpenFileSystem(const mojo::String& file_system, + mojo::InterfaceRequest<Directory> directory, + const OpenFileSystemCallback& callback) override; + + private: + const std::string remote_application_url_; + + mojo::StrongBinding<FileSystem> binding_; + + DISALLOW_COPY_AND_ASSIGN(FileSystemPosix); +}; + +} // namespace filesystem + +#endif // COMPONENTS_FILESYSTEM_POSIX_FILE_SYSTEM_POSIX_H_ diff --git a/components/filesystem/shared_impl.cc b/components/filesystem/posix/shared_posix.cc index d1c7f8f..983dec6 100644 --- a/components/filesystem/shared_impl.cc +++ b/components/filesystem/posix/shared_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/filesystem/shared_impl.h" +#include "components/filesystem/posix/shared_posix.h" #include <errno.h> #include <sys/stat.h> diff --git a/components/filesystem/shared_impl.h b/components/filesystem/posix/shared_posix.h index 5dcf68d..d4e0b8b 100644 --- a/components/filesystem/shared_impl.h +++ b/components/filesystem/posix/shared_posix.h @@ -5,8 +5,8 @@ // Shared implementation of things common between |DirectoryImpl| and // |FileImpl|. -#ifndef COMPONENTS_FILESYSTEM_SHARED_IMPL_H_ -#define COMPONENTS_FILESYSTEM_SHARED_IMPL_H_ +#ifndef COMPONENTS_FILESYSTEM_POSIX_SHARED_POSIX_H_ +#define COMPONENTS_FILESYSTEM_POSIX_SHARED_POSIX_H_ #include "components/filesystem/public/interfaces/types.mojom.h" #include "mojo/public/cpp/bindings/callback.h" @@ -28,4 +28,4 @@ void TouchFD(int fd, } // namespace filesystem -#endif // COMPONENTS_FILESYSTEM_SHARED_IMPL_H_ +#endif // COMPONENTS_FILESYSTEM_POSIX_SHARED_POSIX_H_ diff --git a/components/filesystem/win/file_system_win.cc b/components/filesystem/win/file_system_win.cc new file mode 100644 index 0000000..36e44a5 --- /dev/null +++ b/components/filesystem/win/file_system_win.cc @@ -0,0 +1,37 @@ +// Copyright 2015 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 "components/filesystem/win/file_system_win.h" + +#include "base/files/file_path.h" +#include "base/files/scoped_file.h" +#include "base/files/scoped_temp_dir.h" +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" +#include "base/posix/eintr_wrapper.h" +#include "components/filesystem/posix/directory_posix.h" +#include "mojo/application/public/cpp/application_connection.h" + +namespace filesystem { + +FileSystemWin::FileSystemWin(mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<FileSystem> request) + : remote_application_url_(connection->GetRemoteApplicationURL()), + binding_(this, request.Pass()) { +} + +FileSystemWin::~FileSystemWin() { +} + +void FileSystemWin::OpenFileSystem( + const mojo::String& file_system, + mojo::InterfaceRequest<Directory> directory, + const OpenFileSystemCallback& callback) { + // TODO(erg): Fill this out. + NOTIMPLEMENTED(); + callback.Run(ERROR_UNIMPLEMENTED); +} + +} // namespace filesystem + diff --git a/components/filesystem/file_system_impl.h b/components/filesystem/win/file_system_win.h index 9d8266d..bc9c978 100644 --- a/components/filesystem/file_system_impl.h +++ b/components/filesystem/win/file_system_win.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ -#define COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ +#ifndef COMPONENTS_FILESYSTEM_WIN_FILE_SYSTEM_WIN_H_ +#define COMPONENTS_FILESYSTEM_WIN_FILE_SYSTEM_WIN_H_ #include "base/macros.h" #include "components/filesystem/public/interfaces/file_system.mojom.h" @@ -16,11 +16,11 @@ class ApplicationConnection; namespace filesystem { -class FileSystemImpl : public FileSystem { +class FileSystemWin : public FileSystem { public: - FileSystemImpl(mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<FileSystem> request); - ~FileSystemImpl() override; + FileSystemWin(mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<FileSystem> request); + ~FileSystemWin() override; // |Files| implementation: // We provide a "private" temporary file system as the default. In Debug @@ -31,11 +31,13 @@ class FileSystemImpl : public FileSystem { const OpenFileSystemCallback& callback) override; private: + const std::string remote_application_url_; + mojo::StrongBinding<FileSystem> binding_; - DISALLOW_COPY_AND_ASSIGN(FileSystemImpl); + DISALLOW_COPY_AND_ASSIGN(FileSystemWin); }; } // namespace filesystem -#endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ +#endif // COMPONENTS_FILESYSTEM_WIN_FILE_SYSTEM_WIN_H_ |