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