| OLD | NEW |
| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 273 |
| 274 std::vector<std::unique_ptr<InstanceInfo>> instances_; | 274 std::vector<std::unique_ptr<InstanceInfo>> instances_; |
| 275 | 275 |
| 276 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; | 276 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; |
| 277 | 277 |
| 278 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); | 278 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 } // namespace | 281 } // namespace |
| 282 | 282 |
| 283 TaskViewer::TaskViewer() {} | 283 TaskViewer::TaskViewer() { |
| 284 registry_.AddInterface<::mash::mojom::Launchable>(this); |
| 285 } |
| 284 TaskViewer::~TaskViewer() {} | 286 TaskViewer::~TaskViewer() {} |
| 285 | 287 |
| 286 void TaskViewer::RemoveWindow(views::Widget* widget) { | 288 void TaskViewer::RemoveWindow(views::Widget* widget) { |
| 287 auto it = std::find(windows_.begin(), windows_.end(), widget); | 289 auto it = std::find(windows_.begin(), windows_.end(), widget); |
| 288 DCHECK(it != windows_.end()); | 290 DCHECK(it != windows_.end()); |
| 289 windows_.erase(it); | 291 windows_.erase(it); |
| 290 if (windows_.empty()) | 292 if (windows_.empty()) |
| 291 base::MessageLoop::current()->QuitWhenIdle(); | 293 base::MessageLoop::current()->QuitWhenIdle(); |
| 292 } | 294 } |
| 293 | 295 |
| 294 void TaskViewer::OnStart() { | 296 void TaskViewer::OnStart() { |
| 295 tracing_.Initialize(context()->connector(), context()->identity().name()); | 297 tracing_.Initialize(context()->connector(), context()->identity().name()); |
| 296 | 298 |
| 297 aura_init_ = base::MakeUnique<views::AuraInit>( | 299 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 298 context()->connector(), context()->identity(), "views_mus_resources.pak", | 300 context()->connector(), context()->identity(), "views_mus_resources.pak", |
| 299 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); | 301 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); |
| 300 } | 302 } |
| 301 | 303 |
| 302 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info, | 304 void TaskViewer::OnBindInterface( |
| 303 service_manager::InterfaceRegistry* registry) { | 305 const service_manager::ServiceInfo& source_info, |
| 304 registry->AddInterface<::mash::mojom::Launchable>(this); | 306 const std::string& interface_name, |
| 305 return true; | 307 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 308 registry_.BindInterface(source_info.identity, interface_name, |
| 309 std::move(interface_pipe)); |
| 306 } | 310 } |
| 307 | 311 |
| 308 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 312 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
| 309 bool reuse = how == mojom::LaunchMode::REUSE || | 313 bool reuse = how == mojom::LaunchMode::REUSE || |
| 310 how == mojom::LaunchMode::DEFAULT; | 314 how == mojom::LaunchMode::DEFAULT; |
| 311 if (reuse && !windows_.empty()) { | 315 if (reuse && !windows_.empty()) { |
| 312 windows_.back()->Activate(); | 316 windows_.back()->Activate(); |
| 313 return; | 317 return; |
| 314 } | 318 } |
| 315 | 319 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 332 windows_.push_back(window); | 336 windows_.push_back(window); |
| 333 } | 337 } |
| 334 | 338 |
| 335 void TaskViewer::Create(const service_manager::Identity& remote_identity, | 339 void TaskViewer::Create(const service_manager::Identity& remote_identity, |
| 336 ::mash::mojom::LaunchableRequest request) { | 340 ::mash::mojom::LaunchableRequest request) { |
| 337 bindings_.AddBinding(this, std::move(request)); | 341 bindings_.AddBinding(this, std::move(request)); |
| 338 } | 342 } |
| 339 | 343 |
| 340 } // namespace task_viewer | 344 } // namespace task_viewer |
| 341 } // namespace main | 345 } // namespace main |
| OLD | NEW |