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

Side by Side Diff: content/shell/utility/shell_content_utility_client.cc

Issue 2810343002: Convert UtilityThread/Clients to add ConnectionFilters instead of using ChildThread's InterfaceRegi… (Closed)
Patch Set: . 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/utility/shell_content_utility_client.h" 5 #include "content/shell/utility/shell_content_utility_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/process/process.h" 13 #include "base/process/process.h"
14 #include "content/public/child/child_thread.h"
15 #include "content/public/common/service_manager_connection.h"
16 #include "content/public/common/simple_connection_filter.h"
14 #include "content/public/test/test_service.h" 17 #include "content/public/test/test_service.h"
15 #include "content/public/test/test_service.mojom.h" 18 #include "content/public/test/test_service.mojom.h"
16 #include "mojo/public/cpp/bindings/strong_binding.h" 19 #include "mojo/public/cpp/bindings/strong_binding.h"
17 #include "mojo/public/cpp/system/buffer.h" 20 #include "mojo/public/cpp/system/buffer.h"
18 #include "services/service_manager/public/cpp/interface_registry.h" 21 #include "services/service_manager/public/cpp/binder_registry.h"
19 22
20 namespace content { 23 namespace content {
21 24
22 namespace { 25 namespace {
23 26
24 class TestServiceImpl : public mojom::TestService { 27 class TestServiceImpl : public mojom::TestService {
25 public: 28 public:
26 static void Create(mojom::TestServiceRequest request) { 29 static void Create(mojom::TestServiceRequest request) {
27 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl), 30 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl),
28 std::move(request)); 31 std::move(request));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 72
70 std::unique_ptr<service_manager::Service> CreateTestService() { 73 std::unique_ptr<service_manager::Service> CreateTestService() {
71 return std::unique_ptr<service_manager::Service>(new TestService); 74 return std::unique_ptr<service_manager::Service>(new TestService);
72 } 75 }
73 76
74 } // namespace 77 } // namespace
75 78
76 ShellContentUtilityClient::~ShellContentUtilityClient() { 79 ShellContentUtilityClient::~ShellContentUtilityClient() {
77 } 80 }
78 81
82 void ShellContentUtilityClient::UtilityThreadStarted() {
83 auto registry = base::MakeUnique<service_manager::BinderRegistry>();
84 registry->AddInterface(base::Bind(&TestServiceImpl::Create),
85 base::ThreadTaskRunnerHandle::Get());
86 content::ChildThread::Get()
87 ->GetServiceManagerConnection()
88 ->AddConnectionFilter(
89 base::MakeUnique<SimpleConnectionFilter>(std::move(registry)));
90 }
91
79 void ShellContentUtilityClient::RegisterServices(StaticServiceMap* services) { 92 void ShellContentUtilityClient::RegisterServices(StaticServiceMap* services) {
80 ServiceInfo info; 93 ServiceInfo info;
81 info.factory = base::Bind(&CreateTestService); 94 info.factory = base::Bind(&CreateTestService);
82 services->insert(std::make_pair(kTestServiceUrl, info)); 95 services->insert(std::make_pair(kTestServiceUrl, info));
83 } 96 }
84 97
85 void ShellContentUtilityClient::ExposeInterfacesToBrowser(
86 service_manager::InterfaceRegistry* registry) {
87 registry->AddInterface(base::Bind(&TestServiceImpl::Create));
88 }
89
90 } // namespace content 98 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/utility/shell_content_utility_client.h ('k') | content/utility/utility_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698