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

Side by Side Diff: services/shell/standalone/context.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "services/shell/standalone/context.h" 5 #include "services/shell/standalone/context.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Setup() { mojo::edk::Init(); } 56 Setup() { mojo::edk::Init(); }
57 57
58 ~Setup() {} 58 ~Setup() {}
59 59
60 private: 60 private:
61 DISALLOW_COPY_AND_ASSIGN(Setup); 61 DISALLOW_COPY_AND_ASSIGN(Setup);
62 }; 62 };
63 63
64 class TracingInterfaceProvider : public mojom::InterfaceProvider { 64 class TracingInterfaceProvider : public mojom::InterfaceProvider {
65 public: 65 public:
66 TracingInterfaceProvider(Tracer* tracer, 66 explicit TracingInterfaceProvider(Tracer* tracer) : tracer_(tracer) {}
67 mojom::InterfaceProviderRequest request)
68 : tracer_(tracer), binding_(this, std::move(request)) {}
69 ~TracingInterfaceProvider() override {} 67 ~TracingInterfaceProvider() override {}
70 68
71 // mojom::InterfaceProvider: 69 // mojom::InterfaceProvider:
72 void GetInterface(const std::string& interface_name, 70 void GetInterface(const std::string& interface_name,
73 mojo::ScopedMessagePipeHandle client_handle) override { 71 mojo::ScopedMessagePipeHandle client_handle) override {
74 if (tracer_ && interface_name == tracing::mojom::Provider::Name_) { 72 if (tracer_ && interface_name == tracing::mojom::Provider::Name_) {
75 tracer_->ConnectToProvider( 73 tracer_->ConnectToProvider(
76 mojo::MakeRequest<tracing::mojom::Provider>( 74 mojo::MakeRequest<tracing::mojom::Provider>(
77 std::move(client_handle))); 75 std::move(client_handle)));
78 } 76 }
79 } 77 }
80 78
81 private: 79 private:
82 Tracer* tracer_; 80 Tracer* tracer_;
83 mojo::StrongBinding<mojom::InterfaceProvider> binding_;
84 81
85 DISALLOW_COPY_AND_ASSIGN(TracingInterfaceProvider); 82 DISALLOW_COPY_AND_ASSIGN(TracingInterfaceProvider);
86 }; 83 };
87 84
88 const size_t kMaxBlockingPoolThreads = 3; 85 const size_t kMaxBlockingPoolThreads = 3;
89 86
90 std::unique_ptr<base::Thread> CreateIOThread(const char* name) { 87 std::unique_ptr<base::Thread> CreateIOThread(const char* name) {
91 std::unique_ptr<base::Thread> thread(new base::Thread(name)); 88 std::unique_ptr<base::Thread> thread(new base::Thread(name));
92 base::Thread::Options options; 89 base::Thread::Options options;
93 options.message_loop_type = base::MessageLoop::TYPE_IO; 90 options.message_loop_type = base::MessageLoop::TYPE_IO;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 std::unique_ptr<catalog::Store> store; 164 std::unique_ptr<catalog::Store> store;
168 if (init_params) 165 if (init_params)
169 store = std::move(init_params->catalog_store); 166 store = std::move(init_params->catalog_store);
170 catalog_.reset( 167 catalog_.reset(
171 new catalog::Catalog(blocking_pool_.get(), std::move(store), nullptr)); 168 new catalog::Catalog(blocking_pool_.get(), std::move(store), nullptr));
172 service_manager_.reset(new ServiceManager(std::move(runner_factory), 169 service_manager_.reset(new ServiceManager(std::move(runner_factory),
173 catalog_->TakeService())); 170 catalog_->TakeService()));
174 171
175 mojom::InterfaceProviderPtr tracing_remote_interfaces; 172 mojom::InterfaceProviderPtr tracing_remote_interfaces;
176 mojom::InterfaceProviderPtr tracing_local_interfaces; 173 mojom::InterfaceProviderPtr tracing_local_interfaces;
177 new TracingInterfaceProvider(&tracer_, GetProxy(&tracing_local_interfaces)); 174 mojo::MakeStrongBinding(base::MakeUnique<TracingInterfaceProvider>(&tracer_),
175 mojo::GetProxy(&tracing_local_interfaces));
178 176
179 std::unique_ptr<ConnectParams> params(new ConnectParams); 177 std::unique_ptr<ConnectParams> params(new ConnectParams);
180 params->set_source(CreateServiceManagerIdentity()); 178 params->set_source(CreateServiceManagerIdentity());
181 params->set_target(Identity("mojo:tracing", mojom::kRootUserID)); 179 params->set_target(Identity("mojo:tracing", mojom::kRootUserID));
182 params->set_remote_interfaces(mojo::GetProxy(&tracing_remote_interfaces)); 180 params->set_remote_interfaces(mojo::GetProxy(&tracing_remote_interfaces));
183 service_manager_->Connect(std::move(params)); 181 service_manager_->Connect(std::move(params));
184 182
185 if (command_line.HasSwitch(tracing::kTraceStartup)) { 183 if (command_line.HasSwitch(tracing::kTraceStartup)) {
186 tracing::mojom::CollectorPtr coordinator; 184 tracing::mojom::CollectorPtr coordinator;
187 auto coordinator_request = GetProxy(&coordinator); 185 auto coordinator_request = GetProxy(&coordinator);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 mojom::InterfaceProviderPtr local_interfaces; 253 mojom::InterfaceProviderPtr local_interfaces;
256 254
257 std::unique_ptr<ConnectParams> params(new ConnectParams); 255 std::unique_ptr<ConnectParams> params(new ConnectParams);
258 params->set_source(CreateServiceManagerIdentity()); 256 params->set_source(CreateServiceManagerIdentity());
259 params->set_target(Identity(name, mojom::kRootUserID)); 257 params->set_target(Identity(name, mojom::kRootUserID));
260 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); 258 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces));
261 service_manager_->Connect(std::move(params)); 259 service_manager_->Connect(std::move(params));
262 } 260 }
263 261
264 } // namespace shell 262 } // namespace shell
OLDNEW
« no previous file with comments | « services/navigation/view_impl.cc ('k') | services/ui/gpu/display_compositor/compositor_frame_sink_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698