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

Side by Side Diff: shell/context.cc

Issue 791493006: De-client tracing.TraceController interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 "shell/context.h" 5 #include "shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "mojo/common/trace_controller_impl.h"
21 #include "mojo/common/tracing_impl.h" 22 #include "mojo/common/tracing_impl.h"
22 #include "mojo/edk/embedder/embedder.h" 23 #include "mojo/edk/embedder/embedder.h"
23 #include "mojo/edk/embedder/simple_platform_support.h" 24 #include "mojo/edk/embedder/simple_platform_support.h"
24 #include "mojo/public/cpp/application/application_connection.h" 25 #include "mojo/public/cpp/application/application_connection.h"
25 #include "mojo/public/cpp/application/application_delegate.h" 26 #include "mojo/public/cpp/application/application_delegate.h"
26 #include "mojo/public/cpp/application/application_impl.h" 27 #include "mojo/public/cpp/application/application_impl.h"
27 #include "services/tracing/tracing.mojom.h" 28 #include "services/tracing/tracing.mojom.h"
28 #include "shell/application_manager/application_loader.h" 29 #include "shell/application_manager/application_loader.h"
29 #include "shell/application_manager/application_manager.h" 30 #include "shell/application_manager/application_manager.h"
30 #include "shell/dynamic_application_loader.h" 31 #include "shell/dynamic_application_loader.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 const GURL from(pair.first); 140 const GURL from(pair.first);
140 const GURL to = context->ResolveCommandLineURL(pair.second); 141 const GURL to = context->ResolveCommandLineURL(pair.second);
141 if (!from.is_valid() || !to.is_valid()) 142 if (!from.is_valid() || !to.is_valid())
142 return false; 143 return false;
143 resolver->AddCustomMapping(from, to); 144 resolver->AddCustomMapping(from, to);
144 } 145 }
145 } 146 }
146 return true; 147 return true;
147 } 148 }
148 149
150 class TracingServiceProvider : public ServiceProvider {
151 public:
152 explicit TracingServiceProvider(InterfaceRequest<ServiceProvider> request)
153 : binding_(this, request.Pass()) {}
154 ~TracingServiceProvider() override {}
155
156 void ConnectToService(const mojo::String& service_name,
157 ScopedMessagePipeHandle client_handle) override {
158 if (service_name == tracing::TraceController::Name_) {
159 new TraceControllerImpl(
160 MakeRequest<tracing::TraceController>(client_handle.Pass()));
161 }
162 }
163
164 private:
165 StrongBinding<ServiceProvider> binding_;
166 };
viettrungluu 2015/02/02 21:22:44 DISALLOW_COPY_AND_ASSIGN
167
149 } // namespace 168 } // namespace
150 169
151 Context::Context() : application_manager_(this) { 170 Context::Context() : application_manager_(this) {
152 DCHECK(!base::MessageLoop::current()); 171 DCHECK(!base::MessageLoop::current());
153 172
154 // By default assume that the local apps reside alongside the shell. 173 // By default assume that the local apps reside alongside the shell.
155 // TODO(ncbray): really, this should be passed in rather than defaulting. 174 // TODO(ncbray): really, this should be passed in rather than defaulting.
156 // This default makes sense for desktop but not Android. 175 // This default makes sense for desktop but not Android.
157 base::FilePath shell_dir; 176 base::FilePath shell_dir;
158 PathService::Get(base::DIR_MODULE, &shell_dir); 177 PathService::Get(base::DIR_MODULE, &shell_dir);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory()); 241 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory());
223 else 242 else
224 runner_factory.reset(new InProcessDynamicServiceRunnerFactory()); 243 runner_factory.reset(new InProcessDynamicServiceRunnerFactory());
225 244
226 DynamicApplicationLoader* dynamic_application_loader = 245 DynamicApplicationLoader* dynamic_application_loader =
227 new DynamicApplicationLoader(this, runner_factory.Pass()); 246 new DynamicApplicationLoader(this, runner_factory.Pass());
228 InitContentHandlers(dynamic_application_loader, command_line); 247 InitContentHandlers(dynamic_application_loader, command_line);
229 application_manager_.set_default_loader( 248 application_manager_.set_default_loader(
230 scoped_ptr<ApplicationLoader>(dynamic_application_loader)); 249 scoped_ptr<ApplicationLoader>(dynamic_application_loader));
231 250
232 tracing::TraceDataCollectorPtr trace_data_collector_ptr; 251 ServiceProviderPtr tracing_service_provider_ptr;
233 application_manager_.ConnectToService(GURL("mojo:tracing"), 252 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr));
234 &trace_data_collector_ptr); 253 application_manager_.ConnectToApplication(
235 TracingImpl::Create(trace_data_collector_ptr.Pass()); 254 GURL("mojo:tracing"), GURL(""), nullptr,
255 tracing_service_provider_ptr.Pass());
236 256
237 if (listener_) 257 if (listener_)
238 listener_->WaitForListening(); 258 listener_->WaitForListening();
239 259
240 return true; 260 return true;
241 } 261 }
242 262
243 void Context::OnApplicationError(const GURL& url) { 263 void Context::OnApplicationError(const GURL& url) {
244 if (app_urls_.find(url) != app_urls_.end()) { 264 if (app_urls_.find(url) != app_urls_.end()) {
245 app_urls_.erase(url); 265 app_urls_.erase(url);
(...skipping 22 matching lines...) Expand all
268 ScopedMessagePipeHandle Context::ConnectToServiceByName( 288 ScopedMessagePipeHandle Context::ConnectToServiceByName(
269 const GURL& application_url, 289 const GURL& application_url,
270 const std::string& service_name) { 290 const std::string& service_name) {
271 app_urls_.insert(application_url); 291 app_urls_.insert(application_url);
272 return application_manager_.ConnectToServiceByName(application_url, 292 return application_manager_.ConnectToServiceByName(application_url,
273 service_name).Pass(); 293 service_name).Pass();
274 } 294 }
275 295
276 } // namespace shell 296 } // namespace shell
277 } // namespace mojo 297 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698