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

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

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 | « mash/task_viewer/task_viewer.h ('k') | mash/wm/accelerator_registrar_unittest.cc » ('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 16 matching lines...) Expand all
27 #include "ui/views/controls/table/table_view.h" 27 #include "ui/views/controls/table/table_view.h"
28 #include "ui/views/controls/table/table_view_observer.h" 28 #include "ui/views/controls/table/table_view_observer.h"
29 #include "ui/views/mus/aura_init.h" 29 #include "ui/views/mus/aura_init.h"
30 #include "ui/views/mus/window_manager_connection.h" 30 #include "ui/views/mus/window_manager_connection.h"
31 #include "ui/views/widget/widget_delegate.h" 31 #include "ui/views/widget/widget_delegate.h"
32 32
33 namespace mash { 33 namespace mash {
34 namespace task_viewer { 34 namespace task_viewer {
35 namespace { 35 namespace {
36 36
37 using mojo::shell::mojom::InstanceInfoPtr; 37 using shell::mojom::InstanceInfoPtr;
38 38
39 class TaskViewerContents : public views::WidgetDelegateView, 39 class TaskViewerContents : public views::WidgetDelegateView,
40 public ui::TableModel, 40 public ui::TableModel,
41 public views::ButtonListener, 41 public views::ButtonListener,
42 public mojo::shell::mojom::InstanceListener { 42 public shell::mojom::InstanceListener {
43 public: 43 public:
44 TaskViewerContents(mojo::shell::mojom::InstanceListenerRequest request, 44 TaskViewerContents(shell::mojom::InstanceListenerRequest request,
45 catalog::mojom::CatalogPtr catalog) 45 catalog::mojom::CatalogPtr catalog)
46 : binding_(this, std::move(request)), 46 : binding_(this, std::move(request)),
47 catalog_(std::move(catalog)), 47 catalog_(std::move(catalog)),
48 table_view_(nullptr), 48 table_view_(nullptr),
49 table_view_parent_(nullptr), 49 table_view_parent_(nullptr),
50 kill_button_( 50 kill_button_(
51 new views::LabelButton(this, base::ASCIIToUTF16("Kill Process"))), 51 new views::LabelButton(this, base::ASCIIToUTF16("Kill Process"))),
52 observer_(nullptr), 52 observer_(nullptr),
53 weak_ptr_factory_(this) { 53 weak_ptr_factory_(this) {
54 // We don't want to show an empty UI on startup, so just block until we 54 // We don't want to show an empty UI on startup, so just block until we
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Overridden from views::ButtonListener: 142 // Overridden from views::ButtonListener:
143 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 143 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
144 DCHECK_EQ(sender, kill_button_); 144 DCHECK_EQ(sender, kill_button_);
145 DCHECK_EQ(table_view_->SelectedRowCount(), 1); 145 DCHECK_EQ(table_view_->SelectedRowCount(), 1);
146 int row = table_view_->FirstSelectedRow(); 146 int row = table_view_->FirstSelectedRow();
147 DCHECK(row < static_cast<int>(instances_.size())); 147 DCHECK(row < static_cast<int>(instances_.size()));
148 base::Process process = base::Process::Open(instances_[row]->pid); 148 base::Process process = base::Process::Open(instances_[row]->pid);
149 process.Terminate(9, true); 149 process.Terminate(9, true);
150 } 150 }
151 151
152 // Overridden from mojo::shell::mojom::InstanceListener: 152 // Overridden from shell::mojom::InstanceListener:
153 void SetExistingInstances(mojo::Array<InstanceInfoPtr> instances) override { 153 void SetExistingInstances(mojo::Array<InstanceInfoPtr> instances) override {
154 // This callback should only be called with an empty model. 154 // This callback should only be called with an empty model.
155 DCHECK(instances_.empty()); 155 DCHECK(instances_.empty());
156 mojo::Array<mojo::String> names; 156 mojo::Array<mojo::String> names;
157 for (size_t i = 0; i < instances.size(); ++i) { 157 for (size_t i = 0; i < instances.size(); ++i) {
158 InsertInstance(instances[i]->id, instances[i]->identity->name, 158 InsertInstance(instances[i]->id, instances[i]->identity->name,
159 instances[i]->pid); 159 instances[i]->pid);
160 names.push_back(instances[i]->identity->name); 160 names.push_back(instances[i]->identity->name);
161 } 161 }
162 catalog_->GetEntries(std::move(names), 162 catalog_->GetEntries(std::move(names),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 pid_column.id = 2; 244 pid_column.id = 2;
245 // TODO(beng): use resources. 245 // TODO(beng): use resources.
246 pid_column.title = base::ASCIIToUTF16("PID"); 246 pid_column.title = base::ASCIIToUTF16("PID");
247 pid_column.width = 50; 247 pid_column.width = 50;
248 pid_column.sortable = true; 248 pid_column.sortable = true;
249 columns.push_back(pid_column); 249 columns.push_back(pid_column);
250 250
251 return columns; 251 return columns;
252 } 252 }
253 253
254 mojo::Binding<mojo::shell::mojom::InstanceListener> binding_; 254 mojo::Binding<shell::mojom::InstanceListener> binding_;
255 catalog::mojom::CatalogPtr catalog_; 255 catalog::mojom::CatalogPtr catalog_;
256 256
257 views::TableView* table_view_; 257 views::TableView* table_view_;
258 views::View* table_view_parent_; 258 views::View* table_view_parent_;
259 views::LabelButton* kill_button_; 259 views::LabelButton* kill_button_;
260 ui::TableModelObserver* observer_; 260 ui::TableModelObserver* observer_;
261 261
262 std::vector<std::unique_ptr<InstanceInfo>> instances_; 262 std::vector<std::unique_ptr<InstanceInfo>> instances_;
263 263
264 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; 264 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_;
265 265
266 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); 266 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents);
267 }; 267 };
268 268
269 } // namespace 269 } // namespace
270 270
271 TaskViewer::TaskViewer() {} 271 TaskViewer::TaskViewer() {}
272 TaskViewer::~TaskViewer() {} 272 TaskViewer::~TaskViewer() {}
273 273
274 void TaskViewer::Initialize(mojo::Connector* connector, 274 void TaskViewer::Initialize(shell::Connector* connector,
275 const mojo::Identity& identity, 275 const shell::Identity& identity,
276 uint32_t id) { 276 uint32_t id) {
277 tracing_.Initialize(connector, identity.name()); 277 tracing_.Initialize(connector, identity.name());
278 278
279 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 279 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
280 views::WindowManagerConnection::Create(connector); 280 views::WindowManagerConnection::Create(connector);
281 281
282 mojo::shell::mojom::ShellPtr shell; 282 shell::mojom::ShellPtr shell;
283 connector->ConnectToInterface("mojo:shell", &shell); 283 connector->ConnectToInterface("mojo:shell", &shell);
284 284
285 mojo::shell::mojom::InstanceListenerPtr listener; 285 shell::mojom::InstanceListenerPtr listener;
286 mojo::shell::mojom::InstanceListenerRequest request = GetProxy(&listener); 286 shell::mojom::InstanceListenerRequest request = GetProxy(&listener);
287 shell->AddInstanceListener(std::move(listener)); 287 shell->AddInstanceListener(std::move(listener));
288 288
289 catalog::mojom::CatalogPtr catalog; 289 catalog::mojom::CatalogPtr catalog;
290 connector->ConnectToInterface("mojo:catalog", &catalog); 290 connector->ConnectToInterface("mojo:catalog", &catalog);
291 291
292 TaskViewerContents* task_viewer = new TaskViewerContents( 292 TaskViewerContents* task_viewer = new TaskViewerContents(
293 std::move(request), std::move(catalog)); 293 std::move(request), std::move(catalog));
294 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 294 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
295 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); 295 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500));
296 window->Show(); 296 window->Show();
297 } 297 }
298 298
299 } // namespace task_viewer 299 } // namespace task_viewer
300 } // namespace main 300 } // namespace main
OLDNEW
« no previous file with comments | « mash/task_viewer/task_viewer.h ('k') | mash/wm/accelerator_registrar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698