| 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_APP_H_ | 5 #ifndef COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_ |
| 6 #define COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_ | 6 #define COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/filesystem/directory_impl.h" | 9 #include "components/filesystem/directory_impl.h" |
| 10 #include "components/filesystem/file_system_impl.h" | 10 #include "components/filesystem/file_system_impl.h" |
| 11 #include "components/filesystem/public/interfaces/file_system.mojom.h" | 11 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
| 12 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 12 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 13 #include "mojo/shell/public/cpp/application_delegate.h" | |
| 14 #include "mojo/shell/public/cpp/interface_factory.h" | 13 #include "mojo/shell/public/cpp/interface_factory.h" |
| 14 #include "mojo/shell/public/cpp/shell_client.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 class Shell; | 17 class Shell; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace filesystem { | 20 namespace filesystem { |
| 21 | 21 |
| 22 class FileSystemApp : public mojo::ApplicationDelegate, | 22 class FileSystemApp : public mojo::ShellClient, |
| 23 public mojo::InterfaceFactory<FileSystem> { | 23 public mojo::InterfaceFactory<FileSystem> { |
| 24 public: | 24 public: |
| 25 FileSystemApp(); | 25 FileSystemApp(); |
| 26 ~FileSystemApp() override; | 26 ~FileSystemApp() override; |
| 27 | 27 |
| 28 // Called by individual FileSystem objects to register lifetime events. | 28 // Called by individual FileSystem objects to register lifetime events. |
| 29 void RegisterDirectoryToClient(DirectoryImpl* directory, | 29 void RegisterDirectoryToClient(DirectoryImpl* directory, |
| 30 FileSystemClientPtr client); | 30 FileSystemClientPtr client); |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // We set the DirectoryImpl's error handler to this function. We do this so | 33 // We set the DirectoryImpl's error handler to this function. We do this so |
| 34 // that we can QuitNow() once the last DirectoryImpl has closed itself. | 34 // that we can QuitNow() once the last DirectoryImpl has closed itself. |
| 35 void OnDirectoryConnectionError(DirectoryImpl* directory); | 35 void OnDirectoryConnectionError(DirectoryImpl* directory); |
| 36 | 36 |
| 37 // |ApplicationDelegate| override: | 37 // |mojo::ShellClient| override: |
| 38 void Initialize(mojo::Shell* shell, const std::string& url, | 38 void Initialize(mojo::Shell* shell, const std::string& url, |
| 39 uint32_t id) override; | 39 uint32_t id) override; |
| 40 bool AcceptConnection( | 40 bool AcceptConnection(mojo::Connection* connection) override; |
| 41 mojo::ApplicationConnection* connection) override; | |
| 42 bool ShellConnectionLost() override; | 41 bool ShellConnectionLost() override; |
| 43 | 42 |
| 44 // |InterfaceFactory<Files>| implementation: | 43 // |InterfaceFactory<Files>| implementation: |
| 45 void Create(mojo::ApplicationConnection* connection, | 44 void Create(mojo::Connection* connection, |
| 46 mojo::InterfaceRequest<FileSystem> request) override; | 45 mojo::InterfaceRequest<FileSystem> request) override; |
| 47 | 46 |
| 48 // Use a vector to work around map not letting us use FileSystemClientPtr as | 47 // Use a vector to work around map not letting us use FileSystemClientPtr as |
| 49 // a value in a std::map. The move constructors are to allow us to deal with | 48 // a value in a std::map. The move constructors are to allow us to deal with |
| 50 // FileSystemClientPtr inside a vector. | 49 // FileSystemClientPtr inside a vector. |
| 51 struct Client { | 50 struct Client { |
| 52 Client(DirectoryImpl* directory, FileSystemClientPtr fs_client); | 51 Client(DirectoryImpl* directory, FileSystemClientPtr fs_client); |
| 53 Client(Client&& rhs); | 52 Client(Client&& rhs); |
| 54 ~Client(); | 53 ~Client(); |
| 55 | 54 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 // then broadcast a notification to all FileSystemClients that they should | 66 // then broadcast a notification to all FileSystemClients that they should |
| 68 // shut down. Once the final one does, then we QuitNow(). | 67 // shut down. Once the final one does, then we QuitNow(). |
| 69 bool in_shutdown_; | 68 bool in_shutdown_; |
| 70 | 69 |
| 71 DISALLOW_COPY_AND_ASSIGN(FileSystemApp); | 70 DISALLOW_COPY_AND_ASSIGN(FileSystemApp); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 } // namespace filesystem | 73 } // namespace filesystem |
| 75 | 74 |
| 76 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_ | 75 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_ |
| OLD | NEW |