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

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

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 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_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" 13 #include "mojo/shell/public/cpp/application_delegate.h"
14 #include "mojo/shell/public/cpp/interface_factory.h" 14 #include "mojo/shell/public/cpp/interface_factory.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 class ApplicationImpl; 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::ApplicationDelegate,
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 // |ApplicationDelegate| override:
38 void Initialize(mojo::ApplicationImpl* app) override; 38 void Initialize(mojo::Shell* shell, const std::string& url,
39 uint32_t id) override;
39 bool AcceptConnection( 40 bool AcceptConnection(
40 mojo::ApplicationConnection* connection) override; 41 mojo::ApplicationConnection* connection) override;
41 bool ShellConnectionLost() override; 42 bool ShellConnectionLost() override;
42 43
43 // |InterfaceFactory<Files>| implementation: 44 // |InterfaceFactory<Files>| implementation:
44 void Create(mojo::ApplicationConnection* connection, 45 void Create(mojo::ApplicationConnection* connection,
45 mojo::InterfaceRequest<FileSystem> request) override; 46 mojo::InterfaceRequest<FileSystem> request) override;
46 47
47 // Use a vector to work around map not letting us use FileSystemClientPtr as 48 // Use a vector to work around map not letting us use FileSystemClientPtr as
48 // a value in a std::map. The move constructors are to allow us to deal with 49 // a value in a std::map. The move constructors are to allow us to deal with
49 // FileSystemClientPtr inside a vector. 50 // FileSystemClientPtr inside a vector.
50 struct Client { 51 struct Client {
51 Client(DirectoryImpl* directory, FileSystemClientPtr fs_client); 52 Client(DirectoryImpl* directory, FileSystemClientPtr fs_client);
52 Client(Client&& rhs); 53 Client(Client&& rhs);
53 ~Client(); 54 ~Client();
54 55
55 Client& operator=(Client&& rhs); 56 Client& operator=(Client&& rhs);
56 57
57 DirectoryImpl* directory_; 58 DirectoryImpl* directory_;
58 FileSystemClientPtr fs_client_; 59 FileSystemClientPtr fs_client_;
59 }; 60 };
60 std::vector<Client> client_mapping_; 61 std::vector<Client> client_mapping_;
61 62
62 mojo::ApplicationImpl* app_; 63 mojo::Shell* shell_;
63 mojo::TracingImpl tracing_; 64 mojo::TracingImpl tracing_;
64 65
65 // Set to true when our shell connection is closed. On connection error, we 66 // Set to true when our shell connection is closed. On connection error, we
66 // then broadcast a notification to all FileSystemClients that they should 67 // then broadcast a notification to all FileSystemClients that they should
67 // shut down. Once the final one does, then we QuitNow(). 68 // shut down. Once the final one does, then we QuitNow().
68 bool in_shutdown_; 69 bool in_shutdown_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(FileSystemApp); 71 DISALLOW_COPY_AND_ASSIGN(FileSystemApp);
71 }; 72 };
72 73
73 } // namespace filesystem 74 } // namespace filesystem
74 75
75 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_ 76 #endif // COMPONENTS_FILESYSTEM_FILE_SYSTEM_APP_H_
OLDNEW
« no previous file with comments | « components/devtools_service/devtools_service_delegate.cc ('k') | components/filesystem/file_system_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698