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

Side by Side Diff: chrome/browser/ui/webui/task_manager_handler.cc

Issue 7537045: Revert 95015 - WebUI TaskManager: make it default on Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/task_manager_dialog.cc ('k') | chrome/chrome_tests.gypi » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/task_manager_handler.h" 5 #include "chrome/browser/ui/webui/task_manager_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/task_manager/task_manager.h" 12 #include "chrome/browser/task_manager/task_manager.h"
13 #include "chrome/browser/ui/webui/web_ui_util.h" 13 #include "chrome/browser/ui/webui/web_ui_util.h"
14 #include "chrome/common/chrome_notification_types.h"
15 #include "content/common/notification_service.h"
16 #include "content/common/notification_source.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
18 15
19 namespace { 16 namespace {
20 17
21 static Value* CreateColumnValue(const TaskManagerModel* tm, 18 static Value* CreateColumnValue(const TaskManagerModel* tm,
22 const std::string column_name, 19 const std::string column_name,
23 const int i) { 20 const int i) {
24 if (column_name == "processId") 21 if (column_name == "processId")
25 return Value::CreateStringValue(tm->GetResourceProcessId(i)); 22 return Value::CreateStringValue(tm->GetResourceProcessId(i));
26 if (column_name == "processIdValue") 23 if (column_name == "processIdValue")
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (group_start == group_end) 237 if (group_start == group_end)
241 return; 238 return;
242 else 239 else
243 group_end--; 240 group_end--;
244 } 241 }
245 242
246 OnGroupAdded(group_start, group_end - group_start + 1); 243 OnGroupAdded(group_start, group_end - group_start + 1);
247 } 244 }
248 245
249 void TaskManagerHandler::OnItemsRemoved(const int start, const int length) { 246 void TaskManagerHandler::OnItemsRemoved(const int start, const int length) {
250 // Returns if this is called before updating |resource_to_group_table_|.
251 if (resource_to_group_table_.size() < static_cast<size_t>(start + length))
252 return;
253
254 // Converts from an index of resources to an index of groups. 247 // Converts from an index of resources to an index of groups.
255 int group_start = resource_to_group_table_[start]; 248 int group_start = resource_to_group_table_[start];
256 int group_end = resource_to_group_table_[start + length - 1]; 249 int group_end = resource_to_group_table_[start + length - 1];
257 250
258 // First group to remove does not contain all the items in the group. Because 251 // First group to remove does not contain all the items in the group. Because
259 // the first item to remove and the previous one are in same group. 252 // the first item to remove and the previous one are in same group.
260 if (start != 0 && group_start == resource_to_group_table_[start - 1]) { 253 if (start != 0 && group_start == resource_to_group_table_[start - 1]) {
261 OnGroupChanged(group_start, 1); 254 OnGroupChanged(group_start, 1);
262 if (group_start == group_end) 255 if (group_start == group_end)
263 return; 256 return;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 model_->RemoveObserver(this); 325 model_->RemoveObserver(this);
333 } 326 }
334 327
335 void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) { 328 void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) {
336 if (is_enabled_) 329 if (is_enabled_)
337 return; 330 return;
338 331
339 is_enabled_ = true; 332 is_enabled_ = true;
340 model_->AddObserver(this); 333 model_->AddObserver(this);
341 model_->StartUpdating(); 334 model_->StartUpdating();
342
343 NotificationService::current()->Notify(
344 chrome::NOTIFICATION_TASK_MANAGER_WINDOW_READY,
345 Source<TaskManagerModel>(model_),
346 NotificationService::NoDetails());
347 } 335 }
348 336
349 void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) { 337 void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) {
350 task_manager_->OpenAboutMemory(); 338 task_manager_->OpenAboutMemory();
351 } 339 }
352 340
353 // TaskManagerHandler, private: ----------------------------------------------- 341 // TaskManagerHandler, private: -----------------------------------------------
354 342
355 void TaskManagerHandler::UpdateResourceGroupTable(int start, int length) { 343 void TaskManagerHandler::UpdateResourceGroupTable(int start, int length) {
356 if (resource_to_group_table_.size() < static_cast<size_t>(start)) { 344 if (resource_to_group_table_.size() < static_cast<size_t>(start)) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 386 }
399 387
400 void TaskManagerHandler::OnGroupRemoved(const int group_start, 388 void TaskManagerHandler::OnGroupRemoved(const int group_start,
401 const int group_length) { 389 const int group_length) {
402 FundamentalValue start_value(group_start); 390 FundamentalValue start_value(group_start);
403 FundamentalValue length_value(group_length); 391 FundamentalValue length_value(group_length);
404 if (is_enabled_) 392 if (is_enabled_)
405 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); 393 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value);
406 } 394 }
407 395
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/task_manager_dialog.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698