| 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 { | |
| 14 class FilePath; | |
| 15 } | |
| 16 | |
| 17 namespace mojo { | 13 namespace mojo { |
| 18 class ApplicationConnection; | 14 class ApplicationConnection; |
| 19 } | 15 } |
| 20 | 16 |
| 21 namespace filesystem { | 17 namespace filesystem { |
| 22 | 18 |
| 23 class FileSystemImpl : public FileSystem { | 19 class FileSystemImpl : public FileSystem { |
| 24 public: | 20 public: |
| 25 FileSystemImpl(mojo::ApplicationConnection* connection, | 21 FileSystemImpl(mojo::ApplicationConnection* connection, |
| 26 mojo::InterfaceRequest<FileSystem> request); | 22 mojo::InterfaceRequest<FileSystem> request); |
| 27 ~FileSystemImpl() override; | 23 ~FileSystemImpl() override; |
| 28 | 24 |
| 29 // |Files| implementation: | 25 // |Files| implementation: |
| 30 | 26 // We provide a "private" temporary file system as the default. In Debug |
| 31 // Current valid values for |file_system| are "temp" for a temporary | 27 // builds, we also provide access to a common file system named "debug" |
| 32 // filesystem and "origin" for a persistent filesystem bound to the origin of | 28 // (stored under ~/MojoDebug). |
| 33 // the URL of the caller. | |
| 34 void OpenFileSystem(const mojo::String& file_system, | 29 void OpenFileSystem(const mojo::String& file_system, |
| 35 mojo::InterfaceRequest<Directory> directory, | 30 mojo::InterfaceRequest<Directory> directory, |
| 36 const OpenFileSystemCallback& callback) override; | 31 const OpenFileSystemCallback& callback) override; |
| 37 | 32 |
| 38 private: | 33 private: |
| 39 // Gets the system specific toplevel profile directory. | |
| 40 base::FilePath GetSystemProfileDir() const; | |
| 41 | |
| 42 // Takes the origin string from |remote_application_url_|. | |
| 43 std::string GetOriginFromRemoteApplicationURL() const; | |
| 44 | |
| 45 // Sanitizes |origin| so it is an acceptable filesystem name. | |
| 46 void BuildSanitizedOrigin(const std::string& origin, | |
| 47 std::string* sanitized_origin); | |
| 48 | |
| 49 const std::string remote_application_url_; | 34 const std::string remote_application_url_; |
| 50 mojo::StrongBinding<FileSystem> binding_; | 35 mojo::StrongBinding<FileSystem> binding_; |
| 51 | 36 |
| 52 DISALLOW_COPY_AND_ASSIGN(FileSystemImpl); | 37 DISALLOW_COPY_AND_ASSIGN(FileSystemImpl); |
| 53 }; | 38 }; |
| 54 | 39 |
| 55 } // namespace filesystem | 40 } // namespace filesystem |
| 56 | 41 |
| 57 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ | 42 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_IMPL_H_ |
| OLD | NEW |