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

Side by Side Diff: mash/task_viewer/task_viewer.cc

Issue 2500683002: Revert of Service Manager: Remove ServiceContext* arg from Service::OnStart() (Closed)
Patch Set: Created 4 years, 1 month 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 | « mash/task_viewer/task_viewer.h ('k') | mash/webtest/webtest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "mash/task_viewer/task_viewer.h" 5 #include "mash/task_viewer/task_viewer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 TaskViewer::~TaskViewer() {} 282 TaskViewer::~TaskViewer() {}
283 283
284 void TaskViewer::RemoveWindow(views::Widget* widget) { 284 void TaskViewer::RemoveWindow(views::Widget* widget) {
285 auto it = std::find(windows_.begin(), windows_.end(), widget); 285 auto it = std::find(windows_.begin(), windows_.end(), widget);
286 DCHECK(it != windows_.end()); 286 DCHECK(it != windows_.end());
287 windows_.erase(it); 287 windows_.erase(it);
288 if (windows_.empty()) 288 if (windows_.empty())
289 base::MessageLoop::current()->QuitWhenIdle(); 289 base::MessageLoop::current()->QuitWhenIdle();
290 } 290 }
291 291
292 void TaskViewer::OnStart() { 292 void TaskViewer::OnStart(service_manager::ServiceContext* context) {
293 tracing_.Initialize(context()->connector(), context()->identity().name()); 293 context_ = context;
294
295 tracing_.Initialize(context->connector(), context->identity().name());
294 296
295 aura_init_ = base::MakeUnique<views::AuraInit>( 297 aura_init_ = base::MakeUnique<views::AuraInit>(
296 context()->connector(), context()->identity(), "views_mus_resources.pak"); 298 context->connector(), context->identity(), "views_mus_resources.pak");
297 window_manager_connection_ = views::WindowManagerConnection::Create( 299 window_manager_connection_ = views::WindowManagerConnection::Create(
298 context()->connector(), context()->identity()); 300 context->connector(), context->identity());
299 } 301 }
300 302
301 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info, 303 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info,
302 service_manager::InterfaceRegistry* registry) { 304 service_manager::InterfaceRegistry* registry) {
303 registry->AddInterface<mojom::Launchable>(this); 305 registry->AddInterface<mojom::Launchable>(this);
304 return true; 306 return true;
305 } 307 }
306 308
307 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { 309 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) {
308 bool reuse = how == mojom::LaunchMode::REUSE || 310 bool reuse = how == mojom::LaunchMode::REUSE ||
309 how == mojom::LaunchMode::DEFAULT; 311 how == mojom::LaunchMode::DEFAULT;
310 if (reuse && !windows_.empty()) { 312 if (reuse && !windows_.empty()) {
311 windows_.back()->Activate(); 313 windows_.back()->Activate();
312 return; 314 return;
313 } 315 }
314 316
315 service_manager::mojom::ServiceManagerPtr service_manager; 317 service_manager::mojom::ServiceManagerPtr service_manager;
316 context()->connector()->ConnectToInterface( 318 context_->connector()->ConnectToInterface(
317 "service:service_manager", &service_manager); 319 "service:service_manager", &service_manager);
318 320
319 service_manager::mojom::ServiceManagerListenerPtr listener; 321 service_manager::mojom::ServiceManagerListenerPtr listener;
320 service_manager::mojom::ServiceManagerListenerRequest request = 322 service_manager::mojom::ServiceManagerListenerRequest request =
321 GetProxy(&listener); 323 GetProxy(&listener);
322 service_manager->AddListener(std::move(listener)); 324 service_manager->AddListener(std::move(listener));
323 325
324 catalog::mojom::CatalogPtr catalog; 326 catalog::mojom::CatalogPtr catalog;
325 context()->connector()->ConnectToInterface("service:catalog", &catalog); 327 context_->connector()->ConnectToInterface("service:catalog", &catalog);
326 328
327 TaskViewerContents* task_viewer = new TaskViewerContents( 329 TaskViewerContents* task_viewer = new TaskViewerContents(
328 this, std::move(request), std::move(catalog)); 330 this, std::move(request), std::move(catalog));
329 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 331 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
330 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); 332 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500));
331 window->Show(); 333 window->Show();
332 windows_.push_back(window); 334 windows_.push_back(window);
333 } 335 }
334 336
335 void TaskViewer::Create(const service_manager::Identity& remote_identity, 337 void TaskViewer::Create(const service_manager::Identity& remote_identity,
336 mojom::LaunchableRequest request) { 338 mojom::LaunchableRequest request) {
337 bindings_.AddBinding(this, std::move(request)); 339 bindings_.AddBinding(this, std::move(request));
338 } 340 }
339 341
340 } // namespace task_viewer 342 } // namespace task_viewer
341 } // namespace main 343 } // namespace main
OLDNEW
« no previous file with comments | « mash/task_viewer/task_viewer.h ('k') | mash/webtest/webtest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698