Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: components/filesystem/directory_impl.h

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/filesystem/shared_temp_dir.h"
17 #include "mojo/public/cpp/bindings/interface_request.h" 17 #include "mojo/public/cpp/bindings/interface_request.h"
18 #include "mojo/public/cpp/bindings/strong_binding.h"
19 18
20 namespace filesystem { 19 namespace filesystem {
21 20
22 class LockTable; 21 class LockTable;
23 22
24 class DirectoryImpl : public mojom::Directory { 23 class DirectoryImpl : public mojom::Directory {
25 public: 24 public:
26 // Set |temp_dir| only if there's a temporary directory that should be deleted 25 // Set |temp_dir| only if there's a temporary directory that should be deleted
27 // when this object is destroyed. 26 // when this object is destroyed.
28 DirectoryImpl(mojo::InterfaceRequest<mojom::Directory> request, 27 DirectoryImpl(base::FilePath directory_path,
29 base::FilePath directory_path,
30 scoped_refptr<SharedTempDir> temp_dir, 28 scoped_refptr<SharedTempDir> temp_dir,
31 scoped_refptr<LockTable> lock_table); 29 scoped_refptr<LockTable> lock_table);
32 ~DirectoryImpl() override; 30 ~DirectoryImpl() override;
33 31
34 void set_connection_error_handler(const base::Closure& error_handler) {
35 binding_.set_connection_error_handler(error_handler);
36 }
37
38 // |Directory| implementation: 32 // |Directory| implementation:
39 void Read(const ReadCallback& callback) override; 33 void Read(const ReadCallback& callback) override;
40 void OpenFile(const mojo::String& path, 34 void OpenFile(const mojo::String& path,
41 mojo::InterfaceRequest<mojom::File> file, 35 mojom::FileRequest file,
42 uint32_t open_flags, 36 uint32_t open_flags,
43 const OpenFileCallback& callback) override; 37 const OpenFileCallback& callback) override;
44 void OpenFileHandle(const mojo::String& path, 38 void OpenFileHandle(const mojo::String& path,
45 uint32_t open_flags, 39 uint32_t open_flags,
46 const OpenFileHandleCallback& callback) override; 40 const OpenFileHandleCallback& callback) override;
47 void OpenFileHandles(mojo::Array<mojom::FileOpenDetailsPtr> details, 41 void OpenFileHandles(mojo::Array<mojom::FileOpenDetailsPtr> details,
48 const OpenFileHandlesCallback& callback) override; 42 const OpenFileHandlesCallback& callback) override;
49 void OpenDirectory(const mojo::String& path, 43 void OpenDirectory(const mojo::String& path,
50 mojo::InterfaceRequest<mojom::Directory> directory, 44 mojom::DirectoryRequest directory,
51 uint32_t open_flags, 45 uint32_t open_flags,
52 const OpenDirectoryCallback& callback) override; 46 const OpenDirectoryCallback& callback) override;
53 void Rename(const mojo::String& path, 47 void Rename(const mojo::String& path,
54 const mojo::String& new_path, 48 const mojo::String& new_path,
55 const RenameCallback& callback) override; 49 const RenameCallback& callback) override;
56 void Delete(const mojo::String& path, 50 void Delete(const mojo::String& path,
57 uint32_t delete_flags, 51 uint32_t delete_flags,
58 const DeleteCallback& callback) override; 52 const DeleteCallback& callback) override;
59 void Exists(const mojo::String& path, 53 void Exists(const mojo::String& path,
60 const ExistsCallback& callback) override; 54 const ExistsCallback& callback) override;
61 void IsWritable(const mojo::String& path, 55 void IsWritable(const mojo::String& path,
62 const IsWritableCallback& callback) override; 56 const IsWritableCallback& callback) override;
63 void Flush(const FlushCallback& callback) override; 57 void Flush(const FlushCallback& callback) override;
64 void StatFile(const mojo::String& path, 58 void StatFile(const mojo::String& path,
65 const StatFileCallback& callback) override; 59 const StatFileCallback& callback) override;
66 void Clone(mojo::InterfaceRequest<mojom::Directory> directory) override; 60 void Clone(mojom::DirectoryRequest directory) override;
67 void ReadEntireFile(const mojo::String& path, 61 void ReadEntireFile(const mojo::String& path,
68 const ReadEntireFileCallback& callback) override; 62 const ReadEntireFileCallback& callback) override;
69 void WriteFile(const mojo::String& path, 63 void WriteFile(const mojo::String& path,
70 mojo::Array<uint8_t> data, 64 mojo::Array<uint8_t> data,
71 const WriteFileCallback& callback) override; 65 const WriteFileCallback& callback) override;
72 66
73 private: 67 private:
74 mojo::ScopedHandle OpenFileHandleImpl(const mojo::String& raw_path, 68 mojo::ScopedHandle OpenFileHandleImpl(const mojo::String& raw_path,
75 uint32_t open_flags, 69 uint32_t open_flags,
76 mojom::FileError* error); 70 mojom::FileError* error);
77 71
78 mojo::StrongBinding<mojom::Directory> binding_;
79 base::FilePath directory_path_; 72 base::FilePath directory_path_;
80 scoped_refptr<SharedTempDir> temp_dir_; 73 scoped_refptr<SharedTempDir> temp_dir_;
81 scoped_refptr<LockTable> lock_table_; 74 scoped_refptr<LockTable> lock_table_;
82 75
83 DISALLOW_COPY_AND_ASSIGN(DirectoryImpl); 76 DISALLOW_COPY_AND_ASSIGN(DirectoryImpl);
84 }; 77 };
85 78
86 } // namespace filesystem 79 } // namespace filesystem
87 80
88 #endif // COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_ 81 #endif // COMPONENTS_FILESYSTEM_DIRECTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698