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 CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
6 #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 6 #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/lazy_instance.h" | |
14 #include "base/macros.h" | 13 #include "base/macros.h" |
15 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
16 #include "services/shell/public/interfaces/connector.mojom.h" | |
17 #include "services/shell/service_manager.h" | 15 #include "services/shell/service_manager.h" |
18 | 16 |
19 namespace catalog { | 17 namespace catalog { |
20 class Catalog; | 18 class Catalog; |
21 } | 19 } |
22 | 20 |
23 namespace content { | 21 namespace content { |
24 | 22 |
25 // MojoShellContext hosts the browser's ApplicationManager, coordinating | 23 // MojoShellContext hosts the browser's ApplicationManager, coordinating |
26 // app registration and interconnection. | 24 // app registration and interconnection. |
27 class CONTENT_EXPORT MojoShellContext { | 25 class CONTENT_EXPORT MojoShellContext { |
28 public: | 26 public: |
29 MojoShellContext(); | 27 MojoShellContext(); |
30 ~MojoShellContext(); | 28 ~MojoShellContext(); |
31 | 29 |
32 // Connects an application at |name| and gets a handle to its exposed | |
33 // services. This is only intended for use in browser code that's not part of | |
34 // some Mojo application. May be called from any thread. |requestor_name| is | |
35 // given to the target application as the requestor's name upon connection. | |
36 static void ConnectToApplication( | |
37 const std::string& user_id, | |
38 const std::string& name, | |
39 const std::string& requestor_name, | |
40 shell::mojom::InterfaceProviderRequest request, | |
41 shell::mojom::InterfaceProviderPtr exposed_services, | |
42 const shell::mojom::Connector::ConnectCallback& callback); | |
43 | |
44 // Returns a shell::Connector that can be used on the IO thread. | 30 // Returns a shell::Connector that can be used on the IO thread. |
45 static shell::Connector* GetConnectorForIOThread(); | 31 static shell::Connector* GetConnectorForIOThread(); |
46 | 32 |
47 private: | 33 private: |
48 class BuiltinManifestProvider; | 34 class BuiltinManifestProvider; |
49 class Proxy; | |
50 friend class Proxy; | |
51 | |
52 void ConnectToApplicationOnOwnThread( | |
53 const std::string& user_id, | |
54 const std::string& name, | |
55 const std::string& requestor_name, | |
56 shell::mojom::InterfaceProviderRequest request, | |
57 shell::mojom::InterfaceProviderPtr exposed_services, | |
58 const shell::mojom::Connector::ConnectCallback& callback); | |
59 | |
60 static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; | |
61 | 35 |
62 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; | 36 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; |
63 std::unique_ptr<catalog::Catalog> catalog_; | 37 std::unique_ptr<catalog::Catalog> catalog_; |
64 std::unique_ptr<shell::ServiceManager> service_manager_; | 38 std::unique_ptr<shell::ServiceManager> service_manager_; |
65 | 39 |
66 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); | 40 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); |
67 }; | 41 }; |
68 | 42 |
69 } // namespace content | 43 } // namespace content |
70 | 44 |
71 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 45 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
OLD | NEW |