| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_FILESYSTEM_FILE_IMPL_H_ | 5 #ifndef COMPONENTS_FILESYSTEM_FILE_IMPL_H_ |
| 6 #define COMPONENTS_FILESYSTEM_FILE_IMPL_H_ | 6 #define COMPONENTS_FILESYSTEM_FILE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/files/file.h" |
| 8 #include "base/files/scoped_file.h" | 9 #include "base/files/scoped_file.h" |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "components/filesystem/public/interfaces/directory.mojom.h" | 11 #include "components/filesystem/public/interfaces/directory.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/interface_request.h" | 12 #include "mojo/public/cpp/bindings/interface_request.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 | 14 |
| 15 namespace base { |
| 16 class FilePath; |
| 17 } |
| 18 |
| 14 namespace filesystem { | 19 namespace filesystem { |
| 15 | 20 |
| 16 class FileImpl : public File { | 21 class FileImpl : public File { |
| 17 public: | 22 public: |
| 18 // TODO(vtl): Will need more for, e.g., |Reopen()|. | 23 FileImpl(mojo::InterfaceRequest<File> request, |
| 19 FileImpl(mojo::InterfaceRequest<File> request, base::ScopedFD file_fd); | 24 const base::FilePath& path, |
| 25 uint32 flags); |
| 26 FileImpl(mojo::InterfaceRequest<File> request, base::File file); |
| 20 ~FileImpl() override; | 27 ~FileImpl() override; |
| 21 | 28 |
| 22 // |File| implementation: | 29 // |File| implementation: |
| 23 void Close(const CloseCallback& callback) override; | 30 void Close(const CloseCallback& callback) override; |
| 24 void Read(uint32_t num_bytes_to_read, | 31 void Read(uint32_t num_bytes_to_read, |
| 25 int64_t offset, | 32 int64_t offset, |
| 26 Whence whence, | 33 Whence whence, |
| 27 const ReadCallback& callback) override; | 34 const ReadCallback& callback) override; |
| 28 void Write(mojo::Array<uint8_t> bytes_to_write, | 35 void Write(mojo::Array<uint8_t> bytes_to_write, |
| 29 int64_t offset, | 36 int64_t offset, |
| 30 Whence whence, | 37 Whence whence, |
| 31 const WriteCallback& callback) override; | 38 const WriteCallback& callback) override; |
| 32 void ReadToStream(mojo::ScopedDataPipeProducerHandle source, | |
| 33 int64_t offset, | |
| 34 Whence whence, | |
| 35 int64_t num_bytes_to_read, | |
| 36 const ReadToStreamCallback& callback) override; | |
| 37 void WriteFromStream(mojo::ScopedDataPipeConsumerHandle sink, | |
| 38 int64_t offset, | |
| 39 Whence whence, | |
| 40 const WriteFromStreamCallback& callback) override; | |
| 41 void Tell(const TellCallback& callback) override; | 39 void Tell(const TellCallback& callback) override; |
| 42 void Seek(int64_t offset, | 40 void Seek(int64_t offset, |
| 43 Whence whence, | 41 Whence whence, |
| 44 const SeekCallback& callback) override; | 42 const SeekCallback& callback) override; |
| 45 void Stat(const StatCallback& callback) override; | 43 void Stat(const StatCallback& callback) override; |
| 46 void Truncate(int64_t size, const TruncateCallback& callback) override; | 44 void Truncate(int64_t size, const TruncateCallback& callback) override; |
| 47 void Touch(TimespecOrNowPtr atime, | 45 void Touch(TimespecOrNowPtr atime, |
| 48 TimespecOrNowPtr mtime, | 46 TimespecOrNowPtr mtime, |
| 49 const TouchCallback& callback) override; | 47 const TouchCallback& callback) override; |
| 50 void Dup(mojo::InterfaceRequest<File> file, | 48 void Dup(mojo::InterfaceRequest<File> file, |
| 51 const DupCallback& callback) override; | 49 const DupCallback& callback) override; |
| 52 void Reopen(mojo::InterfaceRequest<File> file, | |
| 53 uint32_t open_flags, | |
| 54 const ReopenCallback& callback) override; | |
| 55 void AsBuffer(const AsBufferCallback& callback) override; | |
| 56 void Ioctl(uint32_t request, | |
| 57 mojo::Array<uint32_t> in_values, | |
| 58 const IoctlCallback& callback) override; | |
| 59 | 50 |
| 60 private: | 51 private: |
| 61 mojo::StrongBinding<File> binding_; | 52 mojo::StrongBinding<File> binding_; |
| 62 base::ScopedFD file_fd_; | 53 base::File file_; |
| 63 | 54 |
| 64 DISALLOW_COPY_AND_ASSIGN(FileImpl); | 55 DISALLOW_COPY_AND_ASSIGN(FileImpl); |
| 65 }; | 56 }; |
| 66 | 57 |
| 67 } // namespace filesystem | 58 } // namespace filesystem |
| 68 | 59 |
| 69 #endif // COMPONENTS_FILESYSTEM_FILE_IMPL_H_ | 60 #endif // COMPONENTS_FILESYSTEM_FILE_IMPL_H_ |
| OLD | NEW |