| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/process/process.h" | 14 #include "base/process/process.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
| 17 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" | 18 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" |
| 18 #include "mojo/shell/public/cpp/connection.h" | 19 #include "mojo/shell/public/cpp/connection.h" |
| 19 #include "mojo/shell/public/cpp/connector.h" | 20 #include "mojo/shell/public/cpp/connector.h" |
| 20 #include "mojo/shell/public/interfaces/shell.mojom.h" | 21 #include "mojo/shell/public/interfaces/shell.mojom.h" |
| 21 #include "ui/base/models/table_model.h" | 22 #include "ui/base/models/table_model.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 197 |
| 197 bool ContainsId(uint32_t id) const { | 198 bool ContainsId(uint32_t id) const { |
| 198 for (auto& it : instances_) { | 199 for (auto& it : instances_) { |
| 199 if (it->id == id) | 200 if (it->id == id) |
| 200 return true; | 201 return true; |
| 201 } | 202 } |
| 202 return false; | 203 return false; |
| 203 } | 204 } |
| 204 | 205 |
| 205 void InsertInstance(uint32_t id, const std::string& url, uint32_t pid) { | 206 void InsertInstance(uint32_t id, const std::string& url, uint32_t pid) { |
| 206 instances_.push_back(make_scoped_ptr(new InstanceInfo(id, url, pid))); | 207 instances_.push_back(base::WrapUnique(new InstanceInfo(id, url, pid))); |
| 207 } | 208 } |
| 208 | 209 |
| 209 void OnGotCatalogEntries( | 210 void OnGotCatalogEntries( |
| 210 mojo::Map<mojo::String, catalog::mojom::CatalogEntryPtr> entries) { | 211 mojo::Map<mojo::String, catalog::mojom::CatalogEntryPtr> entries) { |
| 211 for (auto it = instances_.begin(); it != instances_.end(); ++it) { | 212 for (auto it = instances_.begin(); it != instances_.end(); ++it) { |
| 212 auto entry_it = entries.find((*it)->url); | 213 auto entry_it = entries.find((*it)->url); |
| 213 if (entry_it != entries.end()) { | 214 if (entry_it != entries.end()) { |
| 214 (*it)->name = entry_it->second->display_name; | 215 (*it)->name = entry_it->second->display_name; |
| 215 observer_->OnItemsChanged( | 216 observer_->OnItemsChanged( |
| 216 static_cast<int>(it - instances_.begin()), 1); | 217 static_cast<int>(it - instances_.begin()), 1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 252 } |
| 252 | 253 |
| 253 mojo::Binding<mojo::shell::mojom::InstanceListener> binding_; | 254 mojo::Binding<mojo::shell::mojom::InstanceListener> binding_; |
| 254 catalog::mojom::CatalogPtr catalog_; | 255 catalog::mojom::CatalogPtr catalog_; |
| 255 | 256 |
| 256 views::TableView* table_view_; | 257 views::TableView* table_view_; |
| 257 views::View* table_view_parent_; | 258 views::View* table_view_parent_; |
| 258 views::LabelButton* kill_button_; | 259 views::LabelButton* kill_button_; |
| 259 ui::TableModelObserver* observer_; | 260 ui::TableModelObserver* observer_; |
| 260 | 261 |
| 261 std::vector<scoped_ptr<InstanceInfo>> instances_; | 262 std::vector<std::unique_ptr<InstanceInfo>> instances_; |
| 262 | 263 |
| 263 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; | 264 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; |
| 264 | 265 |
| 265 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); | 266 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); |
| 266 }; | 267 }; |
| 267 | 268 |
| 268 } // namespace | 269 } // namespace |
| 269 | 270 |
| 270 TaskViewer::TaskViewer() {} | 271 TaskViewer::TaskViewer() {} |
| 271 TaskViewer::~TaskViewer() {} | 272 TaskViewer::~TaskViewer() {} |
| (...skipping 18 matching lines...) Expand all Loading... |
| 290 | 291 |
| 291 TaskViewerContents* task_viewer = new TaskViewerContents( | 292 TaskViewerContents* task_viewer = new TaskViewerContents( |
| 292 std::move(request), std::move(catalog)); | 293 std::move(request), std::move(catalog)); |
| 293 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 294 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 294 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); | 295 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); |
| 295 window->Show(); | 296 window->Show(); |
| 296 } | 297 } |
| 297 | 298 |
| 298 } // namespace task_viewer | 299 } // namespace task_viewer |
| 299 } // namespace main | 300 } // namespace main |
| OLD | NEW |