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

Unified Diff: mojo/application/public/cpp/lib/service_registry.cc

Issue 1311353005: Adds a way to determine id of content handler that created app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nuke comment Created 5 years, 4 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/application/public/cpp/lib/service_registry.h ('k') | mojo/application/public/interfaces/shell.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/application/public/cpp/lib/service_registry.cc
diff --git a/mojo/application/public/cpp/lib/service_registry.cc b/mojo/application/public/cpp/lib/service_registry.cc
index 8b3be11aca74a44befda9dcb77c344d1350eef86..7edf8d6c1c821dd9b1b9c60d2e9cdd5d773e8f36 100644
--- a/mojo/application/public/cpp/lib/service_registry.cc
+++ b/mojo/application/public/cpp/lib/service_registry.cc
@@ -4,6 +4,7 @@
#include "mojo/application/public/cpp/lib/service_registry.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/service_connector.h"
@@ -24,6 +25,8 @@ ServiceRegistry::ServiceRegistry(
allowed_interfaces_(allowed_interfaces),
allow_all_interfaces_(allowed_interfaces_.size() == 1 &&
allowed_interfaces_.count("*") == 1),
+ content_handler_id_(0u),
+ is_content_handler_id_valid_(false),
weak_factory_(this) {
if (local_services.is_pending())
local_binding_.Bind(local_services.Pass());
@@ -38,6 +41,12 @@ ServiceRegistry::ServiceRegistry()
ServiceRegistry::~ServiceRegistry() {
}
+Shell::ConnectToApplicationCallback
+ServiceRegistry::GetConnectToApplicationCallback() {
+ return base::Bind(&ServiceRegistry::OnGotContentHandlerID,
+ weak_factory_.GetWeakPtr());
+}
+
void ServiceRegistry::SetServiceConnector(ServiceConnector* connector) {
service_connector_registry_.set_service_connector(connector);
}
@@ -65,6 +74,22 @@ void ServiceRegistry::SetRemoteServiceProviderConnectionErrorHandler(
remote_service_provider_.set_connection_error_handler(handler);
}
+bool ServiceRegistry::GetContentHandlerID(uint32_t* content_handler_id) {
+ if (!is_content_handler_id_valid_)
+ return false;
+
+ *content_handler_id = content_handler_id_;
+ return true;
+}
+
+void ServiceRegistry::AddContentHandlerIDCallback(const Closure& callback) {
+ if (is_content_handler_id_valid_) {
+ callback.Run();
+ return;
+ }
+ content_handler_id_callbacks_.push_back(callback);
+}
+
base::WeakPtr<ApplicationConnection> ServiceRegistry::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
@@ -88,6 +113,16 @@ ServiceProvider* ServiceRegistry::GetServiceProvider() {
return remote_service_provider_.get();
}
+void ServiceRegistry::OnGotContentHandlerID(uint32_t content_handler_id) {
+ DCHECK(!is_content_handler_id_valid_);
+ is_content_handler_id_valid_ = true;
+ content_handler_id_ = content_handler_id;
+ std::vector<Closure> callbacks;
+ callbacks.swap(content_handler_id_callbacks_);
+ for (auto callback : callbacks)
+ callback.Run();
+}
+
void ServiceRegistry::ConnectToService(const mojo::String& service_name,
ScopedMessagePipeHandle client_handle) {
service_connector_registry_.ConnectToService(this, service_name,
« no previous file with comments | « mojo/application/public/cpp/lib/service_registry.h ('k') | mojo/application/public/interfaces/shell.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698