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

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

Issue 9565041: Cleanup: Typedef std::pairs in TaskManager code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/task_manager/task_manager.h" 15 #include "chrome/browser/task_manager/task_manager.h"
15 #include "chrome/browser/ui/webui/web_ui_util.h" 16 #include "chrome/browser/ui/webui/web_ui_util.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
17 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/render_view_host_delegate.h" 21 #include "content/public/browser/render_view_host_delegate.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_ui.h" 23 #include "content/public/browser/web_ui.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "webkit/glue/webpreferences.h" 25 #include "webkit/glue/webpreferences.h"
25 26
26 namespace { 27 namespace {
27 28
28 Value* CreateColumnValue(const TaskManagerModel* tm, 29 Value* CreateColumnValue(const TaskManagerModel* tm,
29 const std::string column_name, 30 const std::string& column_name,
30 const int i) { 31 const int i) {
31 if (column_name == "uniqueId") 32 if (column_name == "uniqueId")
32 return Value::CreateIntegerValue(tm->GetResourceUniqueId(i)); 33 return Value::CreateIntegerValue(tm->GetResourceUniqueId(i));
33 if (column_name == "type") 34 if (column_name == "type")
34 return Value::CreateStringValue( 35 return Value::CreateStringValue(
35 TaskManager::Resource::GetResourceTypeAsString( 36 TaskManager::Resource::GetResourceTypeAsString(
36 tm->GetResourceType(i))); 37 tm->GetResourceType(i)));
37 if (column_name == "processId") 38 if (column_name == "processId")
38 return Value::CreateStringValue(tm->GetResourceProcessId(i)); 39 return Value::CreateStringValue(tm->GetResourceProcessId(i));
39 if (column_name == "processIdValue") 40 if (column_name == "processIdValue")
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 128
128 NOTREACHED(); 129 NOTREACHED();
129 return NULL; 130 return NULL;
130 } 131 }
131 132
132 void CreateGroupColumnList(const TaskManagerModel* tm, 133 void CreateGroupColumnList(const TaskManagerModel* tm,
133 const std::string& column_name, 134 const std::string& column_name,
134 const int index, 135 const int index,
135 const int length, 136 const int length,
136 DictionaryValue* val) { 137 DictionaryValue* val) {
137 ListValue *list = new ListValue(); 138 ListValue* list = new ListValue();
138 for (int i = index; i < (index + length); ++i) { 139 for (int i = index; i < (index + length); ++i) {
139 list->Append(CreateColumnValue(tm, column_name, i)); 140 list->Append(CreateColumnValue(tm, column_name, i));
140 } 141 }
141 val->Set(column_name, list); 142 val->Set(column_name, list);
142 } 143 }
143 144
144 struct ColumnType { 145 struct ColumnType {
145 const char* column_id; 146 const char* column_id;
146 // Whether the column has the real value separately or not, instead of the 147 // Whether the column has the real value separately or not, instead of the
147 // formatted value to display. 148 // formatted value to display.
(...skipping 29 matching lines...) Expand all
177 const TaskManagerModel* tm, 178 const TaskManagerModel* tm,
178 const int group_index, 179 const int group_index,
179 const std::set<std::string>& columns) { 180 const std::set<std::string>& columns) {
180 DictionaryValue* val = new DictionaryValue(); 181 DictionaryValue* val = new DictionaryValue();
181 182
182 const int group_count = tm->GroupCount(); 183 const int group_count = tm->GroupCount();
183 if (group_index >= group_count) 184 if (group_index >= group_count)
184 return val; 185 return val;
185 186
186 int index = tm->GetResourceIndexForGroup(group_index, 0); 187 int index = tm->GetResourceIndexForGroup(group_index, 0);
187 std::pair<int, int> group_range; 188 int length = tm->GetGroupRangeForResource(index).second;
188 group_range = tm->GetGroupRangeForResource(index);
189 int length = group_range.second;
190 189
191 // Forces to set following 3 columns regardless of |enable_columns|. 190 // Forces to set following 3 columns regardless of |enable_columns|.
192 val->SetInteger("index", index); 191 val->SetInteger("index", index);
193 val->SetBoolean("isBackgroundResource", 192 val->SetBoolean("isBackgroundResource",
194 tm->IsBackgroundResource(index)); 193 tm->IsBackgroundResource(index));
195 CreateGroupColumnList(tm, "uniqueId", index, length, val); 194 CreateGroupColumnList(tm, "uniqueId", index, length, val);
196 CreateGroupColumnList(tm, "processId", index, 1, val); 195 CreateGroupColumnList(tm, "processId", index, 1, val);
197 196
198 for (size_t i = 0; i < arraysize(kColumnsList); ++i) { 197 for (size_t i = 0; i < arraysize(kColumnsList); ++i) {
199 const std::string column_id = kColumnsList[i].column_id; 198 const std::string column_id = kColumnsList[i].column_id;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 void TaskManagerHandler::OnGroupAdded(const int group_start, 396 void TaskManagerHandler::OnGroupAdded(const int group_start,
398 const int group_length) { 397 const int group_length) {
399 } 398 }
400 399
401 void TaskManagerHandler::OnGroupRemoved(const int group_start, 400 void TaskManagerHandler::OnGroupRemoved(const int group_start,
402 const int group_length) { 401 const int group_length) {
403 } 402 }
404 403
405 void TaskManagerHandler::OnReadyPeriodicalUpdate() { 404 void TaskManagerHandler::OnReadyPeriodicalUpdate() {
406 } 405 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698