| Index: components/filesystem/file_system_app.h
|
| diff --git a/components/filesystem/file_system_app.h b/components/filesystem/file_system_app.h
|
| index c636c54dbc745f03d95bea3e12c2b849a1a029ed..56e33aff2d978969d067ae103279ca32e0fa4060 100644
|
| --- a/components/filesystem/file_system_app.h
|
| +++ b/components/filesystem/file_system_app.h
|
| @@ -6,11 +6,16 @@
|
| #define COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_
|
|
|
| #include "base/macros.h"
|
| +#include "components/filesystem/directory_impl.h"
|
| #include "components/filesystem/file_system_impl.h"
|
| #include "components/filesystem/public/interfaces/file_system.mojom.h"
|
| #include "mojo/application/public/cpp/application_delegate.h"
|
| #include "mojo/application/public/cpp/interface_factory.h"
|
|
|
| +namespace mojo {
|
| +class ApplicationImpl;
|
| +}
|
| +
|
| namespace filesystem {
|
|
|
| class FileSystemApp : public mojo::ApplicationDelegate,
|
| @@ -19,15 +24,47 @@ class FileSystemApp : public mojo::ApplicationDelegate,
|
| FileSystemApp();
|
| ~FileSystemApp() override;
|
|
|
| + // Called by individual FileSystem objects to register lifetime events.
|
| + void RegisterDirectoryToClient(DirectoryImpl* directory,
|
| + FileSystemClientPtr client);
|
| +
|
| private:
|
| + // We set the DirectoryImpl's error handler to this function. We do this so
|
| + // that we can QuitNow() once the last DirectoryImpl has closed itself.
|
| + void OnDirectoryConnectionError(DirectoryImpl* directory);
|
| +
|
| // |ApplicationDelegate| override:
|
| + void Initialize(mojo::ApplicationImpl* app) override;
|
| bool ConfigureIncomingConnection(
|
| mojo::ApplicationConnection* connection) override;
|
| + bool OnShellConnectionError() override;
|
|
|
| // |InterfaceFactory<Files>| implementation:
|
| void Create(mojo::ApplicationConnection* connection,
|
| mojo::InterfaceRequest<FileSystem> request) override;
|
|
|
| + // Use a vector to work around map not letting us use FileSystemClientPtr as
|
| + // a value in a std::map. The move constructors are to allow us to deal with
|
| + // FileSystemClientPtr inside a vector.
|
| + struct Client {
|
| + Client(DirectoryImpl* directory, FileSystemClientPtr fs_client);
|
| + Client(Client&& rhs);
|
| + ~Client();
|
| +
|
| + Client& operator=(Client&& rhs);
|
| +
|
| + DirectoryImpl* directory_;
|
| + FileSystemClientPtr fs_client_;
|
| + };
|
| + std::vector<Client> client_mapping_;
|
| +
|
| + mojo::ApplicationImpl* app_;
|
| +
|
| + // Set to true when our shell connection is closed. On connection error, we
|
| + // then broadcast a notification to all FileSystemClients that they should
|
| + // shut down. Once the final one does, then we QuitNow().
|
| + bool in_shutdown_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(FileSystemApp);
|
| };
|
|
|
|
|