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

Unified Diff: content/browser/mojo/browser_shell_connection.cc

Issue 1889253002: Remove uses of shell::Loader from content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/mojo/browser_shell_connection.h ('k') | content/browser/mojo/mojo_shell_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/mojo/browser_shell_connection.h ('k') | content/browser/mojo/mojo_shell_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698