| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BROWSER_SHELL_CONNECTION_H_ | 5 #ifndef CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_ |
| 6 #define CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_ | 6 #define CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 17 #include "content/common/mojo/embedded_application_runner.h" | 17 #include "content/common/mojo/embedded_application_runner.h" |
| 18 #include "content/public/common/mojo_application_info.h" |
| 18 #include "mojo/public/cpp/bindings/binding_set.h" | 19 #include "mojo/public/cpp/bindings/binding_set.h" |
| 19 #include "services/shell/public/cpp/connector.h" | 20 #include "services/shell/public/cpp/connector.h" |
| 20 #include "services/shell/public/cpp/interface_factory.h" | 21 #include "services/shell/public/cpp/interface_factory.h" |
| 21 #include "services/shell/public/cpp/shell_client.h" | 22 #include "services/shell/public/cpp/shell_client.h" |
| 22 #include "services/shell/public/cpp/shell_connection.h" | 23 #include "services/shell/public/cpp/shell_connection.h" |
| 23 #include "services/shell/public/interfaces/shell_client.mojom.h" | 24 #include "services/shell/public/interfaces/shell_client.mojom.h" |
| 24 #include "services/shell/public/interfaces/shell_client_factory.mojom.h" | 25 #include "services/shell/public/interfaces/shell_client_factory.mojom.h" |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 42 BrowserShellConnection(); | 43 BrowserShellConnection(); |
| 43 | 44 |
| 44 // Constructs a connection associated with its own ShellClient pipe. | 45 // Constructs a connection associated with its own ShellClient pipe. |
| 45 explicit BrowserShellConnection(shell::mojom::ShellClientRequest request); | 46 explicit BrowserShellConnection(shell::mojom::ShellClientRequest request); |
| 46 | 47 |
| 47 ~BrowserShellConnection() override; | 48 ~BrowserShellConnection() override; |
| 48 | 49 |
| 49 shell::Connector* GetConnector(); | 50 shell::Connector* GetConnector(); |
| 50 | 51 |
| 51 // Adds an embedded application to this connection's ShellClientFactory. | 52 // Adds an embedded application to this connection's ShellClientFactory. |
| 52 // |callback| will be used to create a new instance of the application on | 53 // |info| provides details on how to construct new instances of the |
| 53 // |task_runner|'s thread if no instance is running when an incoming | 54 // application when an incoming connection is made to |name|. |
| 54 // connection is made to |name|. If |task_runner| is null, the calling thread | 55 void AddEmbeddedApplication(const base::StringPiece& name, |
| 55 // will be used to run the application. | 56 const MojoApplicationInfo& info); |
| 56 void AddEmbeddedApplication( | |
| 57 const base::StringPiece& name, | |
| 58 const EmbeddedApplicationRunner::FactoryCallback& callback, | |
| 59 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | |
| 60 | 57 |
| 61 // Adds a generic ShellClientRequestHandler for a given application name. This | 58 // Adds a generic ShellClientRequestHandler for a given application name. This |
| 62 // will be used to satisfy any incoming calls to CreateShellClient() which | 59 // will be used to satisfy any incoming calls to CreateShellClient() which |
| 63 // reference the given name. | 60 // reference the given name. |
| 64 // | 61 // |
| 65 // For in-process applications, it is preferrable to use | 62 // For in-process applications, it is preferrable to use |
| 66 // |AddEmbeddedApplication()| as defined above. | 63 // |AddEmbeddedApplication()| as defined above. |
| 67 void AddShellClientRequestHandler(const base::StringPiece& name, | 64 void AddShellClientRequestHandler(const base::StringPiece& name, |
| 68 const ShellClientRequestHandler& handler); | 65 const ShellClientRequestHandler& handler); |
| 69 | 66 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 84 std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>> | 81 std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>> |
| 85 embedded_apps_; | 82 embedded_apps_; |
| 86 std::unordered_map<std::string, ShellClientRequestHandler> request_handlers_; | 83 std::unordered_map<std::string, ShellClientRequestHandler> request_handlers_; |
| 87 | 84 |
| 88 DISALLOW_COPY_AND_ASSIGN(BrowserShellConnection); | 85 DISALLOW_COPY_AND_ASSIGN(BrowserShellConnection); |
| 89 }; | 86 }; |
| 90 | 87 |
| 91 } // namespace content | 88 } // namespace content |
| 92 | 89 |
| 93 #endif // CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_ | 90 #endif // CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_ |
| OLD | NEW |