| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | |
| 6 #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <memory> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/lazy_instance.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "content/common/content_export.h" | |
| 16 #include "services/shell/public/interfaces/connector.mojom.h" | |
| 17 #include "services/shell/service_manager.h" | |
| 18 | |
| 19 namespace catalog { | |
| 20 class Catalog; | |
| 21 } | |
| 22 | |
| 23 namespace content { | |
| 24 | |
| 25 // MojoShellContext hosts the browser's ApplicationManager, coordinating | |
| 26 // app registration and interconnection. | |
| 27 class CONTENT_EXPORT MojoShellContext { | |
| 28 public: | |
| 29 MojoShellContext(); | |
| 30 ~MojoShellContext(); | |
| 31 | |
| 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. | |
| 45 static shell::Connector* GetConnectorForIOThread(); | |
| 46 | |
| 47 private: | |
| 48 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 | |
| 62 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; | |
| 63 std::unique_ptr<catalog::Catalog> catalog_; | |
| 64 std::unique_ptr<shell::ServiceManager> service_manager_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); | |
| 67 }; | |
| 68 | |
| 69 } // namespace content | |
| 70 | |
| 71 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | |
| OLD | NEW |