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_SYSTEM_IMPL_H_ | 5 #ifndef COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ |
6 #define COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ | 6 #define COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "components/filesystem/public/interfaces/file_system.mojom.h" | 9 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/strong_binding.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class FilePath; | 14 class FilePath; |
15 } | 15 } |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 class Connection; | 18 class Connection; |
19 } | 19 } |
20 | 20 |
21 namespace filesystem { | 21 namespace filesystem { |
22 class FileSystemApp; | 22 class FileSystemApp; |
23 | 23 |
24 class LockTable; | 24 class LockTable; |
25 | 25 |
26 class FileSystemImpl : public FileSystem { | 26 class FileSystemImpl : public FileSystem { |
27 public: | 27 public: |
28 FileSystemImpl(mojo::Connection* connection, | 28 FileSystemImpl(FileSystemApp* app, |
| 29 mojo::Connection* connection, |
29 mojo::InterfaceRequest<FileSystem> request, | 30 mojo::InterfaceRequest<FileSystem> request, |
30 LockTable* lock_table); | 31 LockTable* lock_table); |
31 ~FileSystemImpl() override; | 32 ~FileSystemImpl() override; |
32 | 33 |
33 // |Files| implementation: | 34 // |Files| implementation: |
34 | 35 |
35 // Current valid values for |file_system| are "temp" for a temporary | 36 // Current valid values for |file_system| are "temp" for a temporary |
36 // filesystem and "origin" for a persistent filesystem bound to the origin of | 37 // filesystem and "origin" for a persistent filesystem bound to the origin of |
37 // the URL of the caller. | 38 // the URL of the caller. |
38 void OpenFileSystem(const mojo::String& file_system, | 39 void OpenFileSystem(const mojo::String& file_system, |
39 mojo::InterfaceRequest<Directory> directory, | 40 mojo::InterfaceRequest<Directory> directory, |
40 FileSystemClientPtr client, | 41 FileSystemClientPtr client, |
41 const OpenFileSystemCallback& callback) override; | 42 const OpenFileSystemCallback& callback) override; |
42 | 43 |
43 private: | 44 private: |
44 // Gets the system specific toplevel profile directory. | 45 // Gets the system specific toplevel profile directory. |
45 base::FilePath GetSystemProfileDir() const; | 46 base::FilePath GetSystemProfileDir() const; |
46 | 47 |
47 // Takes the origin string from |remote_application_url_|. | 48 // Takes the origin string from |remote_application_url_|. |
48 std::string GetOriginFromRemoteApplicationURL() const; | 49 std::string GetOriginFromRemoteApplicationURL() const; |
49 | 50 |
50 // Sanitizes |origin| so it is an acceptable filesystem name. | 51 // Sanitizes |origin| so it is an acceptable filesystem name. |
51 void BuildSanitizedOrigin(const std::string& origin, | 52 void BuildSanitizedOrigin(const std::string& origin, |
52 std::string* sanitized_origin); | 53 std::string* sanitized_origin); |
53 | 54 |
| 55 FileSystemApp* app_; |
54 const std::string remote_application_url_; | 56 const std::string remote_application_url_; |
55 mojo::StrongBinding<FileSystem> binding_; | 57 mojo::StrongBinding<FileSystem> binding_; |
56 LockTable* lock_table_; | 58 LockTable* lock_table_; |
57 | 59 |
58 DISALLOW_COPY_AND_ASSIGN(FileSystemImpl); | 60 DISALLOW_COPY_AND_ASSIGN(FileSystemImpl); |
59 }; | 61 }; |
60 | 62 |
61 } // namespace filesystem | 63 } // namespace filesystem |
62 | 64 |
63 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ | 65 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ |
OLD | NEW |