| 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_DIRECTORY_IMPL_H_ | 5 #ifndef COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ |
| 6 #define COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ | 6 #define COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "components/filesystem/public/interfaces/directory.mojom.h" | 15 #include "components/filesystem/public/interfaces/directory.mojom.h" |
| 16 #include "components/filesystem/shared_temp_dir.h" |
| 16 #include "mojo/public/cpp/bindings/interface_request.h" | 17 #include "mojo/public/cpp/bindings/interface_request.h" |
| 17 #include "mojo/public/cpp/bindings/strong_binding.h" | 18 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 18 | 19 |
| 19 namespace base { | |
| 20 class ScopedTempDir; | |
| 21 } // namespace base | |
| 22 | |
| 23 namespace filesystem { | 20 namespace filesystem { |
| 24 | 21 |
| 25 class LockTable; | 22 class LockTable; |
| 26 | 23 |
| 27 class DirectoryImpl : public Directory { | 24 class DirectoryImpl : public Directory { |
| 28 public: | 25 public: |
| 29 // Set |temp_dir| only if there's a temporary directory that should be deleted | 26 // Set |temp_dir| only if there's a temporary directory that should be deleted |
| 30 // when this object is destroyed. | 27 // when this object is destroyed. |
| 31 DirectoryImpl(mojo::InterfaceRequest<Directory> request, | 28 DirectoryImpl(mojo::InterfaceRequest<Directory> request, |
| 32 base::FilePath directory_path, | 29 base::FilePath directory_path, |
| 33 std::unique_ptr<base::ScopedTempDir> temp_dir, | 30 scoped_refptr<SharedTempDir> temp_dir, |
| 34 scoped_refptr<LockTable> lock_table); | 31 scoped_refptr<LockTable> lock_table); |
| 35 ~DirectoryImpl() override; | 32 ~DirectoryImpl() override; |
| 36 | 33 |
| 37 void set_connection_error_handler(const mojo::Closure& error_handler) { | 34 void set_connection_error_handler(const mojo::Closure& error_handler) { |
| 38 binding_.set_connection_error_handler(error_handler); | 35 binding_.set_connection_error_handler(error_handler); |
| 39 } | 36 } |
| 40 | 37 |
| 41 // |Directory| implementation: | 38 // |Directory| implementation: |
| 42 void Read(const ReadCallback& callback) override; | 39 void Read(const ReadCallback& callback) override; |
| 43 void OpenFile(const mojo::String& path, | 40 void OpenFile(const mojo::String& path, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 57 void Delete(const mojo::String& path, | 54 void Delete(const mojo::String& path, |
| 58 uint32_t delete_flags, | 55 uint32_t delete_flags, |
| 59 const DeleteCallback& callback) override; | 56 const DeleteCallback& callback) override; |
| 60 void Exists(const mojo::String& path, | 57 void Exists(const mojo::String& path, |
| 61 const ExistsCallback& callback) override; | 58 const ExistsCallback& callback) override; |
| 62 void IsWritable(const mojo::String& path, | 59 void IsWritable(const mojo::String& path, |
| 63 const IsWritableCallback& callback) override; | 60 const IsWritableCallback& callback) override; |
| 64 void Flush(const FlushCallback& callback) override; | 61 void Flush(const FlushCallback& callback) override; |
| 65 void StatFile(const mojo::String& path, | 62 void StatFile(const mojo::String& path, |
| 66 const StatFileCallback& callback) override; | 63 const StatFileCallback& callback) override; |
| 64 void Clone(mojo::InterfaceRequest<Directory> directory) override; |
| 67 void ReadEntireFile(const mojo::String& path, | 65 void ReadEntireFile(const mojo::String& path, |
| 68 const ReadEntireFileCallback& callback) override; | 66 const ReadEntireFileCallback& callback) override; |
| 69 void WriteFile(const mojo::String& path, | 67 void WriteFile(const mojo::String& path, |
| 70 mojo::Array<uint8_t> data, | 68 mojo::Array<uint8_t> data, |
| 71 const WriteFileCallback& callback) override; | 69 const WriteFileCallback& callback) override; |
| 72 | 70 |
| 73 private: | 71 private: |
| 74 mojo::StrongBinding<Directory> binding_; | 72 mojo::StrongBinding<Directory> binding_; |
| 75 base::FilePath directory_path_; | 73 base::FilePath directory_path_; |
| 76 std::unique_ptr<base::ScopedTempDir> temp_dir_; | 74 scoped_refptr<SharedTempDir> temp_dir_; |
| 77 scoped_refptr<LockTable> lock_table_; | 75 scoped_refptr<LockTable> lock_table_; |
| 78 | 76 |
| 79 DISALLOW_COPY_AND_ASSIGN(DirectoryImpl); | 77 DISALLOW_COPY_AND_ASSIGN(DirectoryImpl); |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 } // namespace filesystem | 80 } // namespace filesystem |
| 83 | 81 |
| 84 #endif // COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ | 82 #endif // COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ |
| OLD | NEW |