OLD | NEW |
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" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 TaskManagerHandler::~TaskManagerHandler() { | 188 TaskManagerHandler::~TaskManagerHandler() { |
189 DisableTaskManager(NULL); | 189 DisableTaskManager(NULL); |
190 } | 190 } |
191 | 191 |
192 // TaskManagerHandler, public: ----------------------------------------------- | 192 // TaskManagerHandler, public: ----------------------------------------------- |
193 | 193 |
194 void TaskManagerHandler::OnModelChanged() { | 194 void TaskManagerHandler::OnModelChanged() { |
195 const int count = model_->GroupCount(); | 195 const int count = model_->GroupCount(); |
196 | 196 |
197 FundamentalValue start_value(0); | 197 base::FundamentalValue start_value(0); |
198 FundamentalValue length_value(count); | 198 base::FundamentalValue length_value(count); |
199 ListValue tasks_value; | 199 base::ListValue tasks_value; |
200 for (int i = 0; i < count; i++) { | 200 for (int i = 0; i < count; ++i) |
201 tasks_value.Append(CreateTaskGroupValue(model_, i)); | 201 tasks_value.Append(CreateTaskGroupValue(model_, i)); |
202 } | 202 |
203 if (is_enabled_) { | 203 if (is_enabled_) { |
204 web_ui_->CallJavascriptFunction("taskChanged", | 204 web_ui_->CallJavascriptFunction("taskChanged", |
205 start_value, length_value, tasks_value); | 205 start_value, length_value, tasks_value); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 void TaskManagerHandler::OnItemsChanged(const int start, const int length) { | 209 void TaskManagerHandler::OnItemsChanged(const int start, const int length) { |
210 UpdateResourceGroupTable(start, length); | 210 UpdateResourceGroupTable(start, length); |
211 | 211 |
212 // Converts from an index of resources to an index of groups. | 212 // Converts from an index of resources to an index of groups. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 resource_to_group_table_.insert(it, static_cast<size_t>(length), -1); | 363 resource_to_group_table_.insert(it, static_cast<size_t>(length), -1); |
364 | 364 |
365 for (int i = start; i < start + length; i++) { | 365 for (int i = start; i < start + length; i++) { |
366 const int group_index = model_->GetGroupIndexForResource(i); | 366 const int group_index = model_->GetGroupIndexForResource(i); |
367 resource_to_group_table_[i] = group_index; | 367 resource_to_group_table_[i] = group_index; |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 void TaskManagerHandler::OnGroupChanged(const int group_start, | 371 void TaskManagerHandler::OnGroupChanged(const int group_start, |
372 const int group_length) { | 372 const int group_length) { |
373 FundamentalValue start_value(group_start); | 373 base::FundamentalValue start_value(group_start); |
374 FundamentalValue length_value(group_length); | 374 base::FundamentalValue length_value(group_length); |
375 ListValue tasks_value; | 375 base::ListValue tasks_value; |
376 | 376 |
377 for (int i = 0; i < group_length; i++) { | 377 for (int i = 0; i < group_length; ++i) |
378 tasks_value.Append(CreateTaskGroupValue(model_, group_start + i)); | 378 tasks_value.Append(CreateTaskGroupValue(model_, group_start + i)); |
379 } | 379 |
380 if (is_enabled_) { | 380 if (is_enabled_) { |
381 web_ui_->CallJavascriptFunction("taskChanged", | 381 web_ui_->CallJavascriptFunction("taskChanged", |
382 start_value, length_value, tasks_value); | 382 start_value, length_value, tasks_value); |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 void TaskManagerHandler::OnGroupAdded(const int group_start, | 386 void TaskManagerHandler::OnGroupAdded(const int group_start, |
387 const int group_length) { | 387 const int group_length) { |
388 FundamentalValue start_value(group_start); | 388 base::FundamentalValue start_value(group_start); |
389 FundamentalValue length_value(group_length); | 389 base::FundamentalValue length_value(group_length); |
390 ListValue tasks_value; | 390 base::ListValue tasks_value; |
391 for (int i = 0; i < group_length; i++) { | 391 for (int i = 0; i < group_length; ++i) |
392 tasks_value.Append(CreateTaskGroupValue(model_, group_start + i)); | 392 tasks_value.Append(CreateTaskGroupValue(model_, group_start + i)); |
393 } | 393 |
394 if (is_enabled_) { | 394 if (is_enabled_) { |
395 web_ui_->CallJavascriptFunction("taskAdded", | 395 web_ui_->CallJavascriptFunction("taskAdded", |
396 start_value, length_value, tasks_value); | 396 start_value, length_value, tasks_value); |
397 } | 397 } |
398 } | 398 } |
399 | 399 |
400 void TaskManagerHandler::OnGroupRemoved(const int group_start, | 400 void TaskManagerHandler::OnGroupRemoved(const int group_start, |
401 const int group_length) { | 401 const int group_length) { |
402 FundamentalValue start_value(group_start); | 402 base::FundamentalValue start_value(group_start); |
403 FundamentalValue length_value(group_length); | 403 base::FundamentalValue length_value(group_length); |
404 if (is_enabled_) | 404 if (is_enabled_) |
405 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); | 405 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); |
406 } | 406 } |
407 | |
OLD | NEW |