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

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

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 years, 9 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/manifest.json ('k') | mash/wm/apptest_manifest.json » ('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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 DCHECK(row < static_cast<int>(instances_.size())); 137 DCHECK(row < static_cast<int>(instances_.size()));
138 base::Process process = base::Process::Open(instances_[row]->pid); 138 base::Process process = base::Process::Open(instances_[row]->pid);
139 process.Terminate(9, true); 139 process.Terminate(9, true);
140 } 140 }
141 141
142 // Overridden from mojo::shell::mojom::ApplicationManagerListener: 142 // Overridden from mojo::shell::mojom::ApplicationManagerListener:
143 void SetRunningApplications( 143 void SetRunningApplications(
144 mojo::Array<ApplicationInfoPtr> applications) override { 144 mojo::Array<ApplicationInfoPtr> applications) override {
145 // This callback should only be called with an empty model. 145 // This callback should only be called with an empty model.
146 DCHECK(instances_.empty()); 146 DCHECK(instances_.empty());
147 mojo::Array<mojo::String> urls; 147 mojo::Array<mojo::String> names;
148 for (size_t i = 0; i < applications.size(); ++i) { 148 for (size_t i = 0; i < applications.size(); ++i) {
149 InsertInstance(applications[i]->id, applications[i]->url, 149 InsertInstance(applications[i]->id, applications[i]->name,
150 applications[i]->pid); 150 applications[i]->pid);
151 urls.push_back(applications[i]->url); 151 names.push_back(applications[i]->name);
152 } 152 }
153 catalog_->GetEntries(std::move(urls), 153 catalog_->GetEntries(std::move(names),
154 base::Bind(&TaskViewerContents::OnGotCatalogEntries, 154 base::Bind(&TaskViewerContents::OnGotCatalogEntries,
155 weak_ptr_factory_.GetWeakPtr())); 155 weak_ptr_factory_.GetWeakPtr()));
156 } 156 }
157 void ApplicationInstanceCreated(ApplicationInfoPtr application) override { 157 void ApplicationInstanceCreated(ApplicationInfoPtr application) override {
158 DCHECK(!ContainsId(application->id)); 158 DCHECK(!ContainsId(application->id));
159 InsertInstance(application->id, application->url, application->pid); 159 InsertInstance(application->id, application->name, application->pid);
160 observer_->OnItemsAdded(static_cast<int>(instances_.size()), 1); 160 observer_->OnItemsAdded(static_cast<int>(instances_.size()), 1);
161 mojo::Array<mojo::String> urls; 161 mojo::Array<mojo::String> names;
162 urls.push_back(application->url); 162 names.push_back(application->name);
163 catalog_->GetEntries(std::move(urls), 163 catalog_->GetEntries(std::move(names),
164 base::Bind(&TaskViewerContents::OnGotCatalogEntries, 164 base::Bind(&TaskViewerContents::OnGotCatalogEntries,
165 weak_ptr_factory_.GetWeakPtr())); 165 weak_ptr_factory_.GetWeakPtr()));
166 } 166 }
167 void ApplicationInstanceDestroyed(uint32_t id) override { 167 void ApplicationInstanceDestroyed(uint32_t id) override {
168 for (auto it = instances_.begin(); it != instances_.end(); ++it) { 168 for (auto it = instances_.begin(); it != instances_.end(); ++it) {
169 if ((*it)->id == id) { 169 if ((*it)->id == id) {
170 observer_->OnItemsRemoved( 170 observer_->OnItemsRemoved(
171 static_cast<int>(it - instances_.begin()), 1); 171 static_cast<int>(it - instances_.begin()), 1);
172 instances_.erase(it); 172 instances_.erase(it);
173 return; 173 return;
(...skipping 23 matching lines...) Expand all
197 void InsertInstance(uint32_t id, const std::string& url, uint32_t pid) { 197 void InsertInstance(uint32_t id, const std::string& url, uint32_t pid) {
198 instances_.push_back(make_scoped_ptr(new InstanceInfo(id, url, pid))); 198 instances_.push_back(make_scoped_ptr(new InstanceInfo(id, url, pid)));
199 } 199 }
200 200
201 void OnGotCatalogEntries( 201 void OnGotCatalogEntries(
202 mojo::Map<mojo::String, 202 mojo::Map<mojo::String,
203 package_manager::mojom::CatalogEntryPtr> entries) { 203 package_manager::mojom::CatalogEntryPtr> entries) {
204 for (auto it = instances_.begin(); it != instances_.end(); ++it) { 204 for (auto it = instances_.begin(); it != instances_.end(); ++it) {
205 auto entry_it = entries.find((*it)->url); 205 auto entry_it = entries.find((*it)->url);
206 if (entry_it != entries.end()) { 206 if (entry_it != entries.end()) {
207 (*it)->name = entry_it->second->name; 207 (*it)->name = entry_it->second->display_name;
208 observer_->OnItemsChanged( 208 observer_->OnItemsChanged(
209 static_cast<int>(it - instances_.begin()), 1); 209 static_cast<int>(it - instances_.begin()), 1);
210 } 210 }
211 } 211 }
212 } 212 }
213 213
214 static std::vector<ui::TableColumn> GetColumns() { 214 static std::vector<ui::TableColumn> GetColumns() {
215 std::vector<ui::TableColumn> columns; 215 std::vector<ui::TableColumn> columns;
216 216
217 ui::TableColumn name_column; 217 ui::TableColumn name_column;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 TaskViewerContents* task_viewer = new TaskViewerContents( 284 TaskViewerContents* task_viewer = new TaskViewerContents(
285 std::move(request), std::move(catalog)); 285 std::move(request), std::move(catalog));
286 views::Widget* window = views::Widget::CreateWindowWithBounds( 286 views::Widget* window = views::Widget::CreateWindowWithBounds(
287 task_viewer, gfx::Rect(10, 10, 500, 500)); 287 task_viewer, gfx::Rect(10, 10, 500, 500));
288 window->Show(); 288 window->Show();
289 } 289 }
290 290
291 } // namespace task_viewer 291 } // namespace task_viewer
292 } // namespace main 292 } // namespace main
OLDNEW
« no previous file with comments | « mash/task_viewer/manifest.json ('k') | mash/wm/apptest_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698