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

Unified Diff: content/browser/utility_process_host_impl.cc

Issue 2832633002: Add PDF compositor service (Closed)
Patch Set: rebase Created 3 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
Index: content/browser/utility_process_host_impl.cc
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc
index d8f11f6edb610d31631bffd155151a12994a95c6..e1cb62d123e888d5e7a6650805055b0fd79d0333 100644
--- a/content/browser/utility_process_host_impl.cc
+++ b/content/browser/utility_process_host_impl.cc
@@ -4,6 +4,7 @@
#include "content/browser/utility_process_host_impl.h"
+#include <memory>
#include <utility>
#include "base/base_switches.h"
@@ -22,7 +23,9 @@
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "build/build_config.h"
+#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "content/browser/browser_child_process_host_impl.h"
+#include "content/browser/browser_main_loop.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/service_manager/service_manager_context.h"
#include "content/common/child_process_host_impl.h"
@@ -32,6 +35,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/utility_process_host_client.h"
+#include "content/public/common/connection_filter.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/mojo_channel_switches.h"
#include "content/public/common/process_type.h"
@@ -40,6 +44,7 @@
#include "content/public/common/service_manager_connection.h"
#include "content/public/common/service_names.mojom.h"
#include "mojo/edk/embedder/embedder.h"
+#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "ui/base/ui_base_switches.h"
@@ -128,6 +133,29 @@ class UtilitySandboxedProcessLauncherDelegate
UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL;
+class UtilityProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter {
+ public:
+ ConnectionFilterImpl(
Lei Zhang 2017/05/04 02:13:13 explicit?
Wei Li 2017/05/04 18:18:28 Done.
+ std::unique_ptr<service_manager::BinderRegistry> registry)
+ : registry_(std::move(registry)) {}
+
+ private:
+ // ConnectionFilter:
+ void OnBindInterface(const service_manager::ServiceInfo& source_info,
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle* interface_pipe,
+ service_manager::Connector* connector) override {
+ if (registry_->CanBindInterface(interface_name)) {
+ registry_->BindInterface(source_info.identity, interface_name,
+ std::move(*interface_pipe));
+ }
+ }
+
+ std::unique_ptr<service_manager::BinderRegistry> registry_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl);
+};
+
UtilityProcessHost* UtilityProcessHost::Create(
const scoped_refptr<UtilityProcessHostClient>& client,
const scoped_refptr<base::SequencedTaskRunner>& client_task_runner) {
@@ -227,6 +255,26 @@ void UtilityProcessHostImpl::BindInterface(
std::move(interface_pipe));
}
+void UtilityProcessHostImpl::RegisterMojoServices() {
+ auto registry = base::MakeUnique<service_manager::BinderRegistry>();
+ // May be null during test execution.
+ if (ServiceManagerConnection::GetForProcess()) {
+ registry->AddInterface(base::Bind(
+ &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest,
+ base::Unretained(
+ memory_instrumentation::CoordinatorImpl::GetInstance())));
+
+ discardable_memory::DiscardableSharedMemoryManager* manager =
+ BrowserMainLoop::GetInstance()->discardable_shared_memory_manager();
+ registry->AddInterface(
+ base::Bind(&discardable_memory::DiscardableSharedMemoryManager::Bind,
+ base::Unretained(manager)));
+
+ ServiceManagerConnection::GetForProcess()->AddConnectionFilter(
+ base::MakeUnique<ConnectionFilterImpl>(std::move(registry)));
+ }
+}
+
void UtilityProcessHostImpl::SetName(const base::string16& name) {
name_ = name;
}

Powered by Google App Engine
This is Rietveld 408576698