| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/filesystem/public/interfaces/directory.mojom.h" | 13 #include "components/filesystem/public/interfaces/directory.mojom.h" |
| 14 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 15 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 16 | 15 |
| 17 namespace base { | 16 namespace base { |
| 18 class FilePath; | 17 class FilePath; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace filesystem { | 20 namespace filesystem { |
| 22 | 21 |
| 23 class LockTable; | 22 class LockTable; |
| 24 class SharedTempDir; | 23 class SharedTempDir; |
| 25 | 24 |
| 26 class FileImpl : public mojom::File { | 25 class FileImpl : public mojom::File { |
| 27 public: | 26 public: |
| 28 FileImpl(mojo::InterfaceRequest<mojom::File> request, | 27 FileImpl(const base::FilePath& path, |
| 29 const base::FilePath& path, | |
| 30 uint32_t flags, | 28 uint32_t flags, |
| 31 scoped_refptr<SharedTempDir> temp_dir, | 29 scoped_refptr<SharedTempDir> temp_dir, |
| 32 scoped_refptr<LockTable> lock_table); | 30 scoped_refptr<LockTable> lock_table); |
| 33 FileImpl(mojo::InterfaceRequest<mojom::File> request, | 31 FileImpl(const base::FilePath& path, |
| 34 const base::FilePath& path, | |
| 35 base::File file, | 32 base::File file, |
| 36 scoped_refptr<SharedTempDir> temp_dir, | 33 scoped_refptr<SharedTempDir> temp_dir, |
| 37 scoped_refptr<LockTable> lock_table); | 34 scoped_refptr<LockTable> lock_table); |
| 38 ~FileImpl() override; | 35 ~FileImpl() override; |
| 39 | 36 |
| 40 // Returns whether the underlying file handle is valid. | 37 // Returns whether the underlying file handle is valid. |
| 41 bool IsValid() const; | 38 bool IsValid() const; |
| 42 | 39 |
| 43 // Attempts to perform the native operating system's locking operations on | 40 // Attempts to perform the native operating system's locking operations on |
| 44 // the internal mojom::File handle | 41 // the internal mojom::File handle |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 const WriteCallback& callback) override; | 56 const WriteCallback& callback) override; |
| 60 void Tell(const TellCallback& callback) override; | 57 void Tell(const TellCallback& callback) override; |
| 61 void Seek(int64_t offset, | 58 void Seek(int64_t offset, |
| 62 mojom::Whence whence, | 59 mojom::Whence whence, |
| 63 const SeekCallback& callback) override; | 60 const SeekCallback& callback) override; |
| 64 void Stat(const StatCallback& callback) override; | 61 void Stat(const StatCallback& callback) override; |
| 65 void Truncate(int64_t size, const TruncateCallback& callback) override; | 62 void Truncate(int64_t size, const TruncateCallback& callback) override; |
| 66 void Touch(mojom::TimespecOrNowPtr atime, | 63 void Touch(mojom::TimespecOrNowPtr atime, |
| 67 mojom::TimespecOrNowPtr mtime, | 64 mojom::TimespecOrNowPtr mtime, |
| 68 const TouchCallback& callback) override; | 65 const TouchCallback& callback) override; |
| 69 void Dup(mojo::InterfaceRequest<mojom::File> file, | 66 void Dup(mojom::FileRequest file, const DupCallback& callback) override; |
| 70 const DupCallback& callback) override; | |
| 71 void Flush(const FlushCallback& callback) override; | 67 void Flush(const FlushCallback& callback) override; |
| 72 void Lock(const LockCallback& callback) override; | 68 void Lock(const LockCallback& callback) override; |
| 73 void Unlock(const UnlockCallback& callback) override; | 69 void Unlock(const UnlockCallback& callback) override; |
| 74 void AsHandle(const AsHandleCallback& callback) override; | 70 void AsHandle(const AsHandleCallback& callback) override; |
| 75 | 71 |
| 76 private: | 72 private: |
| 77 mojo::StrongBinding<mojom::File> binding_; | |
| 78 base::File file_; | 73 base::File file_; |
| 79 base::FilePath path_; | 74 base::FilePath path_; |
| 80 scoped_refptr<SharedTempDir> temp_dir_; | 75 scoped_refptr<SharedTempDir> temp_dir_; |
| 81 scoped_refptr<LockTable> lock_table_; | 76 scoped_refptr<LockTable> lock_table_; |
| 82 | 77 |
| 83 DISALLOW_COPY_AND_ASSIGN(FileImpl); | 78 DISALLOW_COPY_AND_ASSIGN(FileImpl); |
| 84 }; | 79 }; |
| 85 | 80 |
| 86 } // namespace filesystem | 81 } // namespace filesystem |
| 87 | 82 |
| 88 #endif // COMPONENTS_FILESYSTEM_FILE_IMPL_H_ | 83 #endif // COMPONENTS_FILESYSTEM_FILE_IMPL_H_ |
| OLD | NEW |