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

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

Issue 1684783002: Rename ServiceProvider to InterfaceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 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 "mojo/shell/standalone/context.h" 5 #include "mojo/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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 std::string port_str = 125 std::string port_str =
126 command_line.GetSwitchValueASCII(devtools_service::kRemoteDebuggingPort); 126 command_line.GetSwitchValueASCII(devtools_service::kRemoteDebuggingPort);
127 unsigned port; 127 unsigned port;
128 if (!base::StringToUint(port_str, &port) || port > 65535) { 128 if (!base::StringToUint(port_str, &port) || port > 65535) {
129 LOG(ERROR) << "Invalid value for switch " 129 LOG(ERROR) << "Invalid value for switch "
130 << devtools_service::kRemoteDebuggingPort << ": '" << port_str 130 << devtools_service::kRemoteDebuggingPort << ": '" << port_str
131 << "' is not a valid port number."; 131 << "' is not a valid port number.";
132 return; 132 return;
133 } 133 }
134 134
135 ServiceProviderPtr devtools_service_provider; 135 InterfaceProviderPtr devtools_interfaces;
136 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); 136 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
137 params->set_source(Identity(GURL("mojo:shell"), std::string(), 137 params->set_source(Identity(GURL("mojo:shell"), std::string(),
138 GetPermissiveCapabilityFilter())); 138 GetPermissiveCapabilityFilter()));
139 params->SetTarget(Identity(GURL("mojo:devtools_service"), std::string(), 139 params->SetTarget(Identity(GURL("mojo:devtools_service"), std::string(),
140 GetPermissiveCapabilityFilter())); 140 GetPermissiveCapabilityFilter()));
141 params->set_services(GetProxy(&devtools_service_provider)); 141 params->set_remote_interfaces(GetProxy(&devtools_interfaces));
142 manager->ConnectToApplication(std::move(params)); 142 manager->ConnectToApplication(std::move(params));
143 143
144 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; 144 devtools_service::DevToolsCoordinatorPtr devtools_coordinator;
145 devtools_service_provider->ConnectToService( 145 devtools_interfaces->GetInterface(
146 devtools_service::DevToolsCoordinator::Name_, 146 devtools_service::DevToolsCoordinator::Name_,
147 GetProxy(&devtools_coordinator).PassMessagePipe()); 147 GetProxy(&devtools_coordinator).PassMessagePipe());
148 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); 148 devtools_coordinator->Initialize(static_cast<uint16_t>(port));
149 } 149 }
150 150
151 class TracingServiceProvider : public ServiceProvider { 151 class TracingInterfaceProvider : public InterfaceProvider {
152 public: 152 public:
153 TracingServiceProvider(Tracer* tracer, 153 TracingInterfaceProvider(Tracer* tracer,
154 InterfaceRequest<ServiceProvider> request) 154 InterfaceRequest<InterfaceProvider> request)
155 : tracer_(tracer), binding_(this, std::move(request)) {} 155 : tracer_(tracer), binding_(this, std::move(request)) {}
156 ~TracingServiceProvider() override {} 156 ~TracingInterfaceProvider() override {}
157 157
158 void ConnectToService(const mojo::String& service_name, 158 void GetInterface(const mojo::String& interface_name,
159 ScopedMessagePipeHandle client_handle) override { 159 ScopedMessagePipeHandle client_handle) override {
160 if (tracer_ && service_name == tracing::TraceProvider::Name_) { 160 if (tracer_ && interface_name == tracing::TraceProvider::Name_) {
161 tracer_->ConnectToProvider( 161 tracer_->ConnectToProvider(
162 MakeRequest<tracing::TraceProvider>(std::move(client_handle))); 162 MakeRequest<tracing::TraceProvider>(std::move(client_handle)));
163 } 163 }
164 } 164 }
165 165
166 private: 166 private:
167 Tracer* tracer_; 167 Tracer* tracer_;
168 StrongBinding<ServiceProvider> binding_; 168 StrongBinding<InterfaceProvider> binding_;
169 169
170 DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider); 170 DISALLOW_COPY_AND_ASSIGN(TracingInterfaceProvider);
171 }; 171 };
172 172
173 } // namespace 173 } // namespace
174 174
175 Context::Context() 175 Context::Context()
176 : package_manager_(nullptr), main_entry_time_(base::Time::Now()) {} 176 : package_manager_(nullptr), main_entry_time_(base::Time::Now()) {}
177 177
178 Context::~Context() { 178 Context::~Context() {
179 DCHECK(!base::MessageLoop::current()); 179 DCHECK(!base::MessageLoop::current());
180 } 180 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 runner_factory.reset( 223 runner_factory.reset(
224 new InProcessNativeRunnerFactory(task_runners_->blocking_pool())); 224 new InProcessNativeRunnerFactory(task_runners_->blocking_pool()));
225 } else { 225 } else {
226 runner_factory.reset( 226 runner_factory.reset(
227 new OutOfProcessNativeRunnerFactory(task_runners_->blocking_pool())); 227 new OutOfProcessNativeRunnerFactory(task_runners_->blocking_pool()));
228 } 228 }
229 application_manager_.reset(new ApplicationManager( 229 application_manager_.reset(new ApplicationManager(
230 make_scoped_ptr(package_manager_), std::move(runner_factory), 230 make_scoped_ptr(package_manager_), std::move(runner_factory),
231 task_runners_->blocking_pool())); 231 task_runners_->blocking_pool()));
232 232
233 ServiceProviderPtr tracing_services; 233 InterfaceProviderPtr tracing_remote_interfaces;
234 ServiceProviderPtr tracing_exposed_services; 234 InterfaceProviderPtr tracing_local_interfaces;
235 new TracingServiceProvider(&tracer_, GetProxy(&tracing_exposed_services)); 235 new TracingInterfaceProvider(&tracer_, GetProxy(&tracing_local_interfaces));
236 236
237 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); 237 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
238 params->set_source(Identity(GURL("mojo:shell"), std::string(), 238 params->set_source(Identity(GURL("mojo:shell"), std::string(),
239 GetPermissiveCapabilityFilter())); 239 GetPermissiveCapabilityFilter()));
240 params->SetTarget(Identity(GURL("mojo:tracing"), std::string(), 240 params->SetTarget(Identity(GURL("mojo:tracing"), std::string(),
241 GetPermissiveCapabilityFilter())); 241 GetPermissiveCapabilityFilter()));
242 params->set_services(GetProxy(&tracing_services)); 242 params->set_remote_interfaces(GetProxy(&tracing_remote_interfaces));
243 params->set_exposed_services(std::move(tracing_exposed_services)); 243 params->set_local_interfaces(std::move(tracing_local_interfaces));
244 application_manager_->ConnectToApplication(std::move(params)); 244 application_manager_->ConnectToApplication(std::move(params));
245 245
246 if (command_line.HasSwitch(tracing::kTraceStartup)) { 246 if (command_line.HasSwitch(tracing::kTraceStartup)) {
247 tracing::TraceCollectorPtr coordinator; 247 tracing::TraceCollectorPtr coordinator;
248 auto coordinator_request = GetProxy(&coordinator); 248 auto coordinator_request = GetProxy(&coordinator);
249 tracing_services->ConnectToService(tracing::TraceCollector::Name_, 249 tracing_remote_interfaces->GetInterface(
250 coordinator_request.PassMessagePipe()); 250 tracing::TraceCollector::Name_, coordinator_request.PassMessagePipe());
251 tracer_.StartCollectingFromTracingService(std::move(coordinator)); 251 tracer_.StartCollectingFromTracingService(std::move(coordinator));
252 } 252 }
253 253
254 // Record the shell startup metrics used for performance testing. 254 // Record the shell startup metrics used for performance testing.
255 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 255 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
256 tracing::kEnableStatsCollectionBindings)) { 256 tracing::kEnableStatsCollectionBindings)) {
257 tracing::StartupPerformanceDataCollectorPtr collector; 257 tracing::StartupPerformanceDataCollectorPtr collector;
258 tracing_services->ConnectToService( 258 tracing_remote_interfaces->GetInterface(
259 tracing::StartupPerformanceDataCollector::Name_, 259 tracing::StartupPerformanceDataCollector::Name_,
260 GetProxy(&collector).PassMessagePipe()); 260 GetProxy(&collector).PassMessagePipe());
261 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) 261 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)
262 // CurrentProcessInfo::CreationTime is only defined on some platforms. 262 // CurrentProcessInfo::CreationTime is only defined on some platforms.
263 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); 263 const base::Time creation_time = base::CurrentProcessInfo::CreationTime();
264 collector->SetShellProcessCreationTime(creation_time.ToInternalValue()); 264 collector->SetShellProcessCreationTime(creation_time.ToInternalValue());
265 #endif 265 #endif
266 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); 266 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue());
267 } 267 }
268 268
(...skipping 17 matching lines...) Expand all
286 } 286 }
287 287
288 void Context::OnShutdownComplete() { 288 void Context::OnShutdownComplete() {
289 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 289 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
290 task_runners_->shell_runner()); 290 task_runners_->shell_runner());
291 base::MessageLoop::current()->QuitWhenIdle(); 291 base::MessageLoop::current()->QuitWhenIdle();
292 } 292 }
293 293
294 void Context::Run(const GURL& url) { 294 void Context::Run(const GURL& url) {
295 DCHECK(app_complete_callback_.is_null()); 295 DCHECK(app_complete_callback_.is_null());
296 ServiceProviderPtr services; 296 InterfaceProviderPtr remote_interfaces;
297 ServiceProviderPtr exposed_services; 297 InterfaceProviderPtr local_interfaces;
298 298
299 app_urls_.insert(url); 299 app_urls_.insert(url);
300 300
301 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); 301 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
302 params->SetTarget( 302 params->SetTarget(
303 Identity(url, std::string(), GetPermissiveCapabilityFilter())); 303 Identity(url, std::string(), GetPermissiveCapabilityFilter()));
304 params->set_services(GetProxy(&services)); 304 params->set_remote_interfaces(GetProxy(&remote_interfaces));
305 params->set_exposed_services(std::move(exposed_services)); 305 params->set_local_interfaces(std::move(local_interfaces));
306 params->set_on_application_end( 306 params->set_on_application_end(
307 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); 307 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url));
308 application_manager_->ConnectToApplication(std::move(params)); 308 application_manager_->ConnectToApplication(std::move(params));
309 } 309 }
310 310
311 void Context::RunCommandLineApplication(const base::Closure& callback) { 311 void Context::RunCommandLineApplication(const base::Closure& callback) {
312 DCHECK(app_urls_.empty()); 312 DCHECK(app_urls_.empty());
313 DCHECK(app_complete_callback_.is_null()); 313 DCHECK(app_complete_callback_.is_null());
314 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 314 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
315 base::CommandLine::StringVector args = command_line->GetArgs(); 315 base::CommandLine::StringVector args = command_line->GetArgs();
(...skipping 17 matching lines...) Expand all
333 base::MessageLoop::current()->QuitWhenIdle(); 333 base::MessageLoop::current()->QuitWhenIdle();
334 } else { 334 } else {
335 app_complete_callback_.Run(); 335 app_complete_callback_.Run();
336 } 336 }
337 } 337 }
338 } 338 }
339 } 339 }
340 340
341 } // namespace shell 341 } // namespace shell
342 } // namespace mojo 342 } // namespace mojo
OLDNEW
« content/child/mojo/mojo_application.cc ('K') | « mojo/shell/public/interfaces/shell_client.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698