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

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
« no previous file with comments | « mojo/shell/public/interfaces/shell_client.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers 108 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers
109 << ": '" << parts[i + 1] << "' is not a valid URL."; 109 << ": '" << parts[i + 1] << "' is not a valid URL.";
110 return; 110 return;
111 } 111 }
112 // TODO(eseidel): We should also validate that the mimetype is valid 112 // TODO(eseidel): We should also validate that the mimetype is valid
113 // net/base/mime_util.h could do this, but we don't want to depend on net. 113 // net/base/mime_util.h could do this, but we don't want to depend on net.
114 manager->RegisterContentHandler(parts[i], url); 114 manager->RegisterContentHandler(parts[i], url);
115 } 115 }
116 } 116 }
117 117
118 class TracingServiceProvider : public ServiceProvider { 118 class TracingInterfaceProvider : public InterfaceProvider {
119 public: 119 public:
120 TracingServiceProvider(Tracer* tracer, 120 TracingInterfaceProvider(Tracer* tracer,
121 InterfaceRequest<ServiceProvider> request) 121 InterfaceRequest<InterfaceProvider> request)
122 : tracer_(tracer), binding_(this, std::move(request)) {} 122 : tracer_(tracer), binding_(this, std::move(request)) {}
123 ~TracingServiceProvider() override {} 123 ~TracingInterfaceProvider() override {}
124 124
125 void ConnectToService(const mojo::String& service_name, 125 void GetInterface(const mojo::String& interface_name,
126 ScopedMessagePipeHandle client_handle) override { 126 ScopedMessagePipeHandle client_handle) override {
127 if (tracer_ && service_name == tracing::TraceProvider::Name_) { 127 if (tracer_ && interface_name == tracing::TraceProvider::Name_) {
128 tracer_->ConnectToProvider( 128 tracer_->ConnectToProvider(
129 MakeRequest<tracing::TraceProvider>(std::move(client_handle))); 129 MakeRequest<tracing::TraceProvider>(std::move(client_handle)));
130 } 130 }
131 } 131 }
132 132
133 private: 133 private:
134 Tracer* tracer_; 134 Tracer* tracer_;
135 StrongBinding<ServiceProvider> binding_; 135 StrongBinding<InterfaceProvider> binding_;
136 136
137 DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider); 137 DISALLOW_COPY_AND_ASSIGN(TracingInterfaceProvider);
138 }; 138 };
139 139
140 } // namespace 140 } // namespace
141 141
142 Context::Context() 142 Context::Context()
143 : package_manager_(nullptr), main_entry_time_(base::Time::Now()) {} 143 : package_manager_(nullptr), main_entry_time_(base::Time::Now()) {}
144 144
145 Context::~Context() { 145 Context::~Context() {
146 DCHECK(!base::MessageLoop::current()); 146 DCHECK(!base::MessageLoop::current());
147 } 147 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 runner_factory.reset( 190 runner_factory.reset(
191 new InProcessNativeRunnerFactory(task_runners_->blocking_pool())); 191 new InProcessNativeRunnerFactory(task_runners_->blocking_pool()));
192 } else { 192 } else {
193 runner_factory.reset( 193 runner_factory.reset(
194 new OutOfProcessNativeRunnerFactory(task_runners_->blocking_pool())); 194 new OutOfProcessNativeRunnerFactory(task_runners_->blocking_pool()));
195 } 195 }
196 application_manager_.reset(new ApplicationManager( 196 application_manager_.reset(new ApplicationManager(
197 make_scoped_ptr(package_manager_), std::move(runner_factory), 197 make_scoped_ptr(package_manager_), std::move(runner_factory),
198 task_runners_->blocking_pool())); 198 task_runners_->blocking_pool()));
199 199
200 ServiceProviderPtr tracing_services; 200 InterfaceProviderPtr tracing_remote_interfaces;
201 ServiceProviderPtr tracing_exposed_services; 201 InterfaceProviderPtr tracing_local_interfaces;
202 new TracingServiceProvider(&tracer_, GetProxy(&tracing_exposed_services)); 202 new TracingInterfaceProvider(&tracer_, GetProxy(&tracing_local_interfaces));
203 203
204 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); 204 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
205 params->set_source(Identity(GURL("mojo:shell"), std::string(), 205 params->set_source(Identity(GURL("mojo:shell"), std::string(),
206 GetPermissiveCapabilityFilter())); 206 GetPermissiveCapabilityFilter()));
207 params->SetTarget(Identity(GURL("mojo:tracing"), std::string(), 207 params->SetTarget(Identity(GURL("mojo:tracing"), std::string(),
208 GetPermissiveCapabilityFilter())); 208 GetPermissiveCapabilityFilter()));
209 params->set_services(GetProxy(&tracing_services)); 209 params->set_remote_interfaces(GetProxy(&tracing_remote_interfaces));
210 params->set_exposed_services(std::move(tracing_exposed_services)); 210 params->set_local_interfaces(std::move(tracing_local_interfaces));
211 application_manager_->ConnectToApplication(std::move(params)); 211 application_manager_->ConnectToApplication(std::move(params));
212 212
213 if (command_line.HasSwitch(tracing::kTraceStartup)) { 213 if (command_line.HasSwitch(tracing::kTraceStartup)) {
214 tracing::TraceCollectorPtr coordinator; 214 tracing::TraceCollectorPtr coordinator;
215 auto coordinator_request = GetProxy(&coordinator); 215 auto coordinator_request = GetProxy(&coordinator);
216 tracing_services->ConnectToService(tracing::TraceCollector::Name_, 216 tracing_remote_interfaces->GetInterface(
217 coordinator_request.PassMessagePipe()); 217 tracing::TraceCollector::Name_, coordinator_request.PassMessagePipe());
218 tracer_.StartCollectingFromTracingService(std::move(coordinator)); 218 tracer_.StartCollectingFromTracingService(std::move(coordinator));
219 } 219 }
220 220
221 // Record the shell startup metrics used for performance testing. 221 // Record the shell startup metrics used for performance testing.
222 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 222 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
223 tracing::kEnableStatsCollectionBindings)) { 223 tracing::kEnableStatsCollectionBindings)) {
224 tracing::StartupPerformanceDataCollectorPtr collector; 224 tracing::StartupPerformanceDataCollectorPtr collector;
225 tracing_services->ConnectToService( 225 tracing_remote_interfaces->GetInterface(
226 tracing::StartupPerformanceDataCollector::Name_, 226 tracing::StartupPerformanceDataCollector::Name_,
227 GetProxy(&collector).PassMessagePipe()); 227 GetProxy(&collector).PassMessagePipe());
228 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) 228 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)
229 // CurrentProcessInfo::CreationTime is only defined on some platforms. 229 // CurrentProcessInfo::CreationTime is only defined on some platforms.
230 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); 230 const base::Time creation_time = base::CurrentProcessInfo::CreationTime();
231 collector->SetShellProcessCreationTime(creation_time.ToInternalValue()); 231 collector->SetShellProcessCreationTime(creation_time.ToInternalValue());
232 #endif 232 #endif
233 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); 233 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue());
234 } 234 }
235 } 235 }
(...skipping 15 matching lines...) Expand all
251 } 251 }
252 252
253 void Context::OnShutdownComplete() { 253 void Context::OnShutdownComplete() {
254 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 254 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
255 task_runners_->shell_runner()); 255 task_runners_->shell_runner());
256 base::MessageLoop::current()->QuitWhenIdle(); 256 base::MessageLoop::current()->QuitWhenIdle();
257 } 257 }
258 258
259 void Context::Run(const GURL& url) { 259 void Context::Run(const GURL& url) {
260 DCHECK(app_complete_callback_.is_null()); 260 DCHECK(app_complete_callback_.is_null());
261 ServiceProviderPtr services; 261 InterfaceProviderPtr remote_interfaces;
262 ServiceProviderPtr exposed_services; 262 InterfaceProviderPtr local_interfaces;
263 263
264 app_urls_.insert(url); 264 app_urls_.insert(url);
265 265
266 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); 266 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
267 params->SetTarget( 267 params->SetTarget(
268 Identity(url, std::string(), GetPermissiveCapabilityFilter())); 268 Identity(url, std::string(), GetPermissiveCapabilityFilter()));
269 params->set_services(GetProxy(&services)); 269 params->set_remote_interfaces(GetProxy(&remote_interfaces));
270 params->set_exposed_services(std::move(exposed_services)); 270 params->set_local_interfaces(std::move(local_interfaces));
271 params->set_on_application_end( 271 params->set_on_application_end(
272 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); 272 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url));
273 application_manager_->ConnectToApplication(std::move(params)); 273 application_manager_->ConnectToApplication(std::move(params));
274 } 274 }
275 275
276 void Context::RunCommandLineApplication(const base::Closure& callback) { 276 void Context::RunCommandLineApplication(const base::Closure& callback) {
277 DCHECK(app_urls_.empty()); 277 DCHECK(app_urls_.empty());
278 DCHECK(app_complete_callback_.is_null()); 278 DCHECK(app_complete_callback_.is_null());
279 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 279 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
280 base::CommandLine::StringVector args = command_line->GetArgs(); 280 base::CommandLine::StringVector args = command_line->GetArgs();
(...skipping 17 matching lines...) Expand all
298 base::MessageLoop::current()->QuitWhenIdle(); 298 base::MessageLoop::current()->QuitWhenIdle();
299 } else { 299 } else {
300 app_complete_callback_.Run(); 300 app_complete_callback_.Run();
301 } 301 }
302 } 302 }
303 } 303 }
304 } 304 }
305 305
306 } // namespace shell 306 } // namespace shell
307 } // namespace mojo 307 } // namespace mojo
OLDNEW
« no previous file with comments | « 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