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

Unified Diff: content/common/mojo/mojo_shell_connection_impl.cc

Issue 2183703005: Renderers should obtain browser InterfaceProvider by connecting to browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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/common/mojo/mojo_shell_connection_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/mojo_shell_connection_impl.cc
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc
index 1295ab60cc5d0889f9d4d35b0bdee2a10795d92d..47ff4f0c56f1e05bd9e469acb0ce39edc6703089 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -84,12 +84,26 @@ class MojoShellConnectionImpl::IOThreadContext
DCHECK(posted);
}
- // Safe to call any time before Start() is called.
+ // Safe to call any time before a message is received from a process.
+ // i.e. can be called when starting the process but not afterwards.
void AddConnectionFilter(std::unique_ptr<ConnectionFilter> filter) {
- DCHECK(!started_);
+ base::AutoLock lock(lock_);
connection_filters_.emplace_back(std::move(filter));
}
+ std::unique_ptr<ConnectionFilter> RemoveConnectionFilter(
+ ConnectionFilter* filter) {
+ for (auto it = connection_filters_.begin(); it != connection_filters_.end();
Ken Rockot(use gerrit already) 2016/07/29 23:20:47 This needs to hold lock_ too
+ ++it) {
+ if (it->get() == filter) {
+ std::unique_ptr<ConnectionFilter> taken = std::move(*it);
+ connection_filters_.erase(it);
+ return taken;
+ }
+ }
+ return nullptr;
+ }
+
// Safe to call any time before Start() is called.
void SetDefaultBinderForBrowserConnection(
const shell::InterfaceRegistry::Binder& binder) {
@@ -285,6 +299,8 @@ class MojoShellConnectionImpl::IOThreadContext
mojo::BindingSet<shell::mojom::ServiceFactory> factory_bindings_;
std::vector<std::unique_ptr<ConnectionFilter>> connection_filters_;
+ base::Lock lock_;
+
DISALLOW_COPY_AND_ASSIGN(IOThreadContext);
};
@@ -388,10 +404,14 @@ void MojoShellConnectionImpl::SetupInterfaceRequestProxies(
base::Bind(&MojoShellConnectionImpl::GetInterface,
weak_factory_.GetWeakPtr(), registry));
+ if (!provider)
+ return;
+
// Forward all remote interface requests on |provider| to our IO-thread
// context. This will ensure they're forwarded to the provider on the
// incoming browser connection.
- provider->Forward(base::Bind(&IOThreadContext::GetRemoteInterface, context_));
+ provider->Forward(base::Bind(&IOThreadContext::GetRemoteInterface,
+ context_));
}
void MojoShellConnectionImpl::AddConnectionFilter(
@@ -399,6 +419,11 @@ void MojoShellConnectionImpl::AddConnectionFilter(
context_->AddConnectionFilter(std::move(filter));
}
+std::unique_ptr<ConnectionFilter>
+MojoShellConnectionImpl::RemoveConnectionFilter(ConnectionFilter* filter) {
+ return context_->RemoveConnectionFilter(filter);
+}
+
void MojoShellConnectionImpl::AddEmbeddedService(
const std::string& name,
const MojoApplicationInfo& info) {
« no previous file with comments | « content/common/mojo/mojo_shell_connection_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698