Index: content/browser/mojo/browser_shell_connection.cc |
diff --git a/content/browser/mojo/browser_shell_connection.cc b/content/browser/mojo/browser_shell_connection.cc |
index 5b762a2a88af00f68296dced26e5187e697a6766..a39e8ee893e97e09b94fe5c730cb70f882fcbb2f 100644 |
--- a/content/browser/mojo/browser_shell_connection.cc |
+++ b/content/browser/mojo/browser_shell_connection.cc |
@@ -4,11 +4,14 @@ |
#include "content/browser/mojo/browser_shell_connection.h" |
+#include "base/bind.h" |
#include "content/browser/mojo/constants.h" |
#include "services/shell/public/interfaces/connector.mojom.h" |
namespace content { |
+BrowserShellConnection::BrowserShellConnection() {} |
+ |
BrowserShellConnection::BrowserShellConnection( |
shell::mojom::ShellClientRequest request) |
: shell_connection_(new shell::ShellConnection(this, std::move(request))) {} |
@@ -16,6 +19,7 @@ BrowserShellConnection::BrowserShellConnection( |
BrowserShellConnection::~BrowserShellConnection() {} |
shell::Connector* BrowserShellConnection::GetConnector() { |
+ DCHECK(shell_connection_); |
return shell_connection_->connector(); |
} |
@@ -25,11 +29,22 @@ void BrowserShellConnection::AddEmbeddedApplication( |
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
std::unique_ptr<EmbeddedApplicationRunner> app( |
new EmbeddedApplicationRunner(callback, task_runner)); |
+ AddShellClientRequestHandler( |
+ name, base::Bind(&EmbeddedApplicationRunner::BindShellClientRequest, |
+ base::Unretained(app.get()))); |
auto result = embedded_apps_.insert( |
std::make_pair(name.as_string(), std::move(app))); |
DCHECK(result.second); |
} |
+void BrowserShellConnection::AddShellClientRequestHandler( |
+ const base::StringPiece& name, |
+ const ShellClientRequestHandler& handler) { |
+ auto result = request_handlers_.insert( |
+ std::make_pair(name.as_string(), handler)); |
+ DCHECK(result.second); |
+} |
+ |
bool BrowserShellConnection::AcceptConnection(shell::Connection* connection) { |
std::string remote_app = connection->GetRemoteIdentity().name(); |
if (remote_app == "mojo:shell") { |
@@ -56,9 +71,9 @@ void BrowserShellConnection::Create( |
void BrowserShellConnection::CreateShellClient( |
shell::mojom::ShellClientRequest request, |
const mojo::String& name) { |
- auto it = embedded_apps_.find(name); |
- if (it != embedded_apps_.end()) |
- it->second->BindShellClientRequest(std::move(request)); |
+ auto it = request_handlers_.find(name); |
+ if (it != request_handlers_.end()) |
+ it->second.Run(std::move(request)); |
} |
} // namespace content |