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

Unified Diff: mojo/shell/public/cpp/lib/connection_impl.cc

Issue 1681933005: Extracts InterfaceRegistry from ConnectionImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nested
Patch Set: . Created 4 years, 10 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 | « mojo/shell/public/cpp/lib/connection_impl.h ('k') | mojo/shell/public/cpp/lib/interface_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/public/cpp/lib/connection_impl.cc
diff --git a/mojo/shell/public/cpp/lib/connection_impl.cc b/mojo/shell/public/cpp/lib/connection_impl.cc
index bc66e70ecc60b0406357c34c4dfe7abc72229c1d..8f41dcbc1b8cdf6ad8ea6933cc9e8dbca6290989 100644
--- a/mojo/shell/public/cpp/lib/connection_impl.cc
+++ b/mojo/shell/public/cpp/lib/connection_impl.cc
@@ -31,32 +31,22 @@ ConnectionImpl::ConnectionImpl(
remote_id_(remote_id),
content_handler_id_(0u),
remote_ids_valid_(false),
- local_binding_(this),
+ local_registry_(std::move(local_interfaces), this),
remote_interfaces_(std::move(remote_interfaces)),
allowed_interfaces_(allowed_interfaces),
allow_all_interfaces_(allowed_interfaces_.size() == 1 &&
allowed_interfaces_.count("*") == 1),
- default_binder_(nullptr),
- weak_factory_(this) {
- if (local_interfaces.is_pending())
- local_binding_.Bind(std::move(local_interfaces));
-}
+ weak_factory_(this) {}
ConnectionImpl::ConnectionImpl()
: remote_id_(shell::mojom::Shell::kInvalidApplicationID),
content_handler_id_(shell::mojom::Shell::kInvalidApplicationID),
remote_ids_valid_(false),
- local_binding_(this),
+ local_registry_(shell::mojom::InterfaceProviderRequest(), this),
allow_all_interfaces_(true),
- default_binder_(nullptr),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
-ConnectionImpl::~ConnectionImpl() {
- for (auto& i : name_to_binder_)
- delete i.second;
- name_to_binder_.clear();
-}
+ConnectionImpl::~ConnectionImpl() {}
shell::mojom::Shell::ConnectToApplicationCallback
ConnectionImpl::GetConnectToApplicationCallback() {
@@ -67,25 +57,6 @@ ConnectionImpl::GetConnectToApplicationCallback() {
////////////////////////////////////////////////////////////////////////////////
// ConnectionImpl, Connection implementation:
-void ConnectionImpl::SetDefaultInterfaceBinder(InterfaceBinder* binder) {
- default_binder_ = binder;
-}
-
-bool ConnectionImpl::SetInterfaceBinderForName(
- InterfaceBinder* binder,
- const std::string& interface_name) {
- if (allow_all_interfaces_ ||
- allowed_interfaces_.count(interface_name)) {
- RemoveInterfaceBinderForName(interface_name);
- name_to_binder_[interface_name] = binder;
- return true;
- }
- LOG(WARNING) << "CapabilityFilter prevented connection to interface: "
- << interface_name << " connection_url:" << connection_url_
- << " remote_url:" << remote_url_;
- return false;
-}
-
const std::string& ConnectionImpl::GetConnectionURL() {
return connection_url_;
}
@@ -94,14 +65,6 @@ const std::string& ConnectionImpl::GetRemoteApplicationURL() {
return remote_url_;
}
-shell::mojom::InterfaceProvider* ConnectionImpl::GetRemoteInterfaces() {
- return remote_interfaces_.get();
-}
-
-shell::mojom::InterfaceProvider* ConnectionImpl::GetLocalInterfaces() {
- return this;
-}
-
void ConnectionImpl::SetRemoteInterfaceProviderConnectionErrorHandler(
const Closure& handler) {
remote_interfaces_.set_connection_error_handler(handler);
@@ -132,34 +95,25 @@ void ConnectionImpl::AddRemoteIDCallback(const Closure& callback) {
remote_id_callbacks_.push_back(callback);
}
-base::WeakPtr<Connection> ConnectionImpl::GetWeakPtr() {
- return weak_factory_.GetWeakPtr();
+bool ConnectionImpl::AllowsInterface(const std::string& interface_name) const {
+ return allow_all_interfaces_ || allowed_interfaces_.count(interface_name);
}
-////////////////////////////////////////////////////////////////////////////////
-// ConnectionImpl, shell::mojom::InterfaceProvider implementation:
-
-void ConnectionImpl::GetInterface(const mojo::String& interface_name,
- ScopedMessagePipeHandle handle) {
- auto iter = name_to_binder_.find(interface_name);
- InterfaceBinder* binder = iter != name_to_binder_.end() ? iter->second :
- default_binder_;
- if (binder)
- binder->BindInterface(this, interface_name, std::move(handle));
+shell::mojom::InterfaceProvider* ConnectionImpl::GetRemoteInterfaces() {
+ return remote_interfaces_.get();
}
-////////////////////////////////////////////////////////////////////////////////
-// ConnectionImpl, private:
+InterfaceRegistry* ConnectionImpl::GetLocalRegistry() {
+ return &local_registry_;
+}
-void ConnectionImpl::RemoveInterfaceBinderForName(
- const std::string& interface_name) {
- NameToInterfaceBinderMap::iterator it = name_to_binder_.find(interface_name);
- if (it == name_to_binder_.end())
- return;
- delete it->second;
- name_to_binder_.erase(it);
+base::WeakPtr<Connection> ConnectionImpl::GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
}
+////////////////////////////////////////////////////////////////////////////////
+// ConnectionImpl, private:
+
void ConnectionImpl::OnGotRemoteIDs(uint32_t target_application_id,
uint32_t content_handler_id) {
DCHECK(!remote_ids_valid_);
« no previous file with comments | « mojo/shell/public/cpp/lib/connection_impl.h ('k') | mojo/shell/public/cpp/lib/interface_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698