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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 base::Process process = base::Process::Open(instances_[row]->pid); | 135 base::Process process = base::Process::Open(instances_[row]->pid); |
136 process.Terminate(9, true); | 136 process.Terminate(9, true); |
137 } | 137 } |
138 | 138 |
139 // Overridden from mojo::shell::mojom::InstanceListener: | 139 // Overridden from mojo::shell::mojom::InstanceListener: |
140 void SetExistingInstances(mojo::Array<InstanceInfoPtr> instances) override { | 140 void SetExistingInstances(mojo::Array<InstanceInfoPtr> instances) override { |
141 // This callback should only be called with an empty model. | 141 // This callback should only be called with an empty model. |
142 DCHECK(instances_.empty()); | 142 DCHECK(instances_.empty()); |
143 mojo::Array<mojo::String> names; | 143 mojo::Array<mojo::String> names; |
144 for (size_t i = 0; i < instances.size(); ++i) { | 144 for (size_t i = 0; i < instances.size(); ++i) { |
145 InsertInstance(instances[i]->id, instances[i]->name, instances[i]->pid); | 145 InsertInstance(instances[i]->id, instances[i]->identity->name, |
146 names.push_back(instances[i]->name); | 146 instances[i]->pid); |
| 147 names.push_back(instances[i]->identity->name); |
147 } | 148 } |
148 catalog_->GetEntries(std::move(names), | 149 catalog_->GetEntries(std::move(names), |
149 base::Bind(&TaskViewerContents::OnGotCatalogEntries, | 150 base::Bind(&TaskViewerContents::OnGotCatalogEntries, |
150 weak_ptr_factory_.GetWeakPtr())); | 151 weak_ptr_factory_.GetWeakPtr())); |
151 } | 152 } |
152 void InstanceCreated(InstanceInfoPtr instance) override { | 153 void InstanceCreated(InstanceInfoPtr instance) override { |
153 DCHECK(!ContainsId(instance->id)); | 154 DCHECK(!ContainsId(instance->id)); |
154 InsertInstance(instance->id, instance->name, instance->pid); | 155 InsertInstance(instance->id, instance->identity->name, instance->pid); |
155 observer_->OnItemsAdded(static_cast<int>(instances_.size()), 1); | 156 observer_->OnItemsAdded(static_cast<int>(instances_.size()), 1); |
156 mojo::Array<mojo::String> names; | 157 mojo::Array<mojo::String> names; |
157 names.push_back(instance->name); | 158 names.push_back(instance->identity->name); |
158 catalog_->GetEntries(std::move(names), | 159 catalog_->GetEntries(std::move(names), |
159 base::Bind(&TaskViewerContents::OnGotCatalogEntries, | 160 base::Bind(&TaskViewerContents::OnGotCatalogEntries, |
160 weak_ptr_factory_.GetWeakPtr())); | 161 weak_ptr_factory_.GetWeakPtr())); |
161 } | 162 } |
162 void InstanceDestroyed(uint32_t id) override { | 163 void InstanceDestroyed(uint32_t id) override { |
163 for (auto it = instances_.begin(); it != instances_.end(); ++it) { | 164 for (auto it = instances_.begin(); it != instances_.end(); ++it) { |
164 if ((*it)->id == id) { | 165 if ((*it)->id == id) { |
165 observer_->OnItemsRemoved( | 166 observer_->OnItemsRemoved( |
166 static_cast<int>(it - instances_.begin()), 1); | 167 static_cast<int>(it - instances_.begin()), 1); |
167 instances_.erase(it); | 168 instances_.erase(it); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 253 |
253 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); | 254 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); |
254 }; | 255 }; |
255 | 256 |
256 } // namespace | 257 } // namespace |
257 | 258 |
258 TaskViewer::TaskViewer() {} | 259 TaskViewer::TaskViewer() {} |
259 TaskViewer::~TaskViewer() {} | 260 TaskViewer::~TaskViewer() {} |
260 | 261 |
261 void TaskViewer::Initialize(mojo::Connector* connector, | 262 void TaskViewer::Initialize(mojo::Connector* connector, |
262 const std::string& url, | 263 const mojo::Identity& identity, |
263 const std::string& user_id, | |
264 uint32_t id) { | 264 uint32_t id) { |
265 tracing_.Initialize(connector, url); | 265 tracing_.Initialize(connector, identity.name()); |
266 | 266 |
267 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); | 267 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); |
268 views::WindowManagerConnection::Create(connector); | 268 views::WindowManagerConnection::Create(connector); |
269 | 269 |
270 mojo::shell::mojom::ShellPtr shell; | 270 mojo::shell::mojom::ShellPtr shell; |
271 connector->ConnectToInterface("mojo:shell", &shell); | 271 connector->ConnectToInterface("mojo:shell", &shell); |
272 | 272 |
273 mojo::shell::mojom::InstanceListenerPtr listener; | 273 mojo::shell::mojom::InstanceListenerPtr listener; |
274 mojo::shell::mojom::InstanceListenerRequest request = GetProxy(&listener); | 274 mojo::shell::mojom::InstanceListenerRequest request = GetProxy(&listener); |
275 shell->AddInstanceListener(std::move(listener)); | 275 shell->AddInstanceListener(std::move(listener)); |
276 | 276 |
277 package_manager::mojom::CatalogPtr catalog; | 277 package_manager::mojom::CatalogPtr catalog; |
278 connector->ConnectToInterface("mojo:package_manager", &catalog); | 278 connector->ConnectToInterface("mojo:package_manager", &catalog); |
279 | 279 |
280 TaskViewerContents* task_viewer = new TaskViewerContents( | 280 TaskViewerContents* task_viewer = new TaskViewerContents( |
281 std::move(request), std::move(catalog)); | 281 std::move(request), std::move(catalog)); |
282 views::Widget* window = views::Widget::CreateWindowWithBounds( | 282 views::Widget* window = views::Widget::CreateWindowWithBounds( |
283 task_viewer, gfx::Rect(10, 10, 500, 500)); | 283 task_viewer, gfx::Rect(10, 10, 500, 500)); |
284 window->Show(); | 284 window->Show(); |
285 } | 285 } |
286 | 286 |
287 } // namespace task_viewer | 287 } // namespace task_viewer |
288 } // namespace main | 288 } // namespace main |
OLD | NEW |