OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/task_manager.h" | 5 #include "chrome/browser/task_manager.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
12 #include "base/stats_table.h" | 12 #include "base/stats_table.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/thread.h" | 14 #include "base/thread.h" |
15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
16 #include "chrome/browser/browser_process.h" | |
17 #include "chrome/browser/browser_window.h" | 16 #include "chrome/browser/browser_window.h" |
| 17 #include "chrome/browser/chrome_thread.h" |
18 #include "chrome/browser/net/url_request_tracking.h" | 18 #include "chrome/browser/net/url_request_tracking.h" |
19 #include "chrome/browser/renderer_host/render_process_host.h" | 19 #include "chrome/browser/renderer_host/render_process_host.h" |
20 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 20 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
21 #include "chrome/browser/task_manager_resource_providers.h" | 21 #include "chrome/browser/task_manager_resource_providers.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/pref_service.h" | 23 #include "chrome/common/pref_service.h" |
24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
25 #include "grit/app_resources.h" | 25 #include "grit/app_resources.h" |
26 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 // it to TASK_PENDING ensures the tasks keep being posted (by Refresh()). | 429 // it to TASK_PENDING ensures the tasks keep being posted (by Refresh()). |
430 if (update_state_ == IDLE) { | 430 if (update_state_ == IDLE) { |
431 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 431 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
432 NewRunnableMethod(this, &TaskManagerModel::Refresh), | 432 NewRunnableMethod(this, &TaskManagerModel::Refresh), |
433 kUpdateTimeMs); | 433 kUpdateTimeMs); |
434 } | 434 } |
435 update_state_ = TASK_PENDING; | 435 update_state_ = TASK_PENDING; |
436 | 436 |
437 // Register jobs notifications so we can compute network usage (it must be | 437 // Register jobs notifications so we can compute network usage (it must be |
438 // done from the IO thread). | 438 // done from the IO thread). |
439 base::Thread* thread = g_browser_process->io_thread(); | 439 ChromeThread::PostTask( |
440 if (thread) | 440 ChromeThread::IO, FROM_HERE, |
441 thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 441 NewRunnableMethod( |
442 this, &TaskManagerModel::RegisterForJobDoneNotifications)); | 442 this, &TaskManagerModel::RegisterForJobDoneNotifications)); |
443 | 443 |
444 // Notify resource providers that we are updating. | 444 // Notify resource providers that we are updating. |
445 for (ResourceProviderList::iterator iter = providers_.begin(); | 445 for (ResourceProviderList::iterator iter = providers_.begin(); |
446 iter != providers_.end(); ++iter) { | 446 iter != providers_.end(); ++iter) { |
447 (*iter)->StartUpdating(); | 447 (*iter)->StartUpdating(); |
448 } | 448 } |
449 } | 449 } |
450 | 450 |
451 void TaskManagerModel::StopUpdating() { | 451 void TaskManagerModel::StopUpdating() { |
452 DCHECK_EQ(TASK_PENDING, update_state_); | 452 DCHECK_EQ(TASK_PENDING, update_state_); |
453 update_state_ = STOPPING; | 453 update_state_ = STOPPING; |
454 | 454 |
455 // Notify resource providers that we are done updating. | 455 // Notify resource providers that we are done updating. |
456 for (ResourceProviderList::const_iterator iter = providers_.begin(); | 456 for (ResourceProviderList::const_iterator iter = providers_.begin(); |
457 iter != providers_.end(); ++iter) { | 457 iter != providers_.end(); ++iter) { |
458 (*iter)->StopUpdating(); | 458 (*iter)->StopUpdating(); |
459 } | 459 } |
460 | 460 |
461 // Unregister jobs notification (must be done from the IO thread). | 461 // Unregister jobs notification (must be done from the IO thread). |
462 base::Thread* thread = g_browser_process->io_thread(); | 462 ChromeThread::PostTask( |
463 if (thread) | 463 ChromeThread::IO, FROM_HERE, |
464 thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 464 NewRunnableMethod( |
465 this, &TaskManagerModel::UnregisterForJobDoneNotifications)); | 465 this, &TaskManagerModel::UnregisterForJobDoneNotifications)); |
466 } | 466 } |
467 | 467 |
468 void TaskManagerModel::AddResourceProvider( | 468 void TaskManagerModel::AddResourceProvider( |
469 TaskManager::ResourceProvider* provider) { | 469 TaskManager::ResourceProvider* provider) { |
470 DCHECK(provider); | 470 DCHECK(provider); |
471 providers_.push_back(provider); | 471 providers_.push_back(provider); |
472 } | 472 } |
473 | 473 |
474 void TaskManagerModel::RemoveResourceProvider( | 474 void TaskManagerModel::RemoveResourceProvider( |
475 TaskManager::ResourceProvider* provider) { | 475 TaskManager::ResourceProvider* provider) { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 // or popup, we can only have one tab, hence we need to process this in a | 859 // or popup, we can only have one tab, hence we need to process this in a |
860 // tabbed browser window. Currently, |browser| is pointing to the application, | 860 // tabbed browser window. Currently, |browser| is pointing to the application, |
861 // popup window. Therefore, we have to retrieve the last active tab again, | 861 // popup window. Therefore, we have to retrieve the last active tab again, |
862 // since a new window has been used. | 862 // since a new window has been used. |
863 if (browser->type() & Browser::TYPE_APP_POPUP) { | 863 if (browser->type() & Browser::TYPE_APP_POPUP) { |
864 browser = BrowserList::GetLastActive(); | 864 browser = BrowserList::GetLastActive(); |
865 DCHECK(browser); | 865 DCHECK(browser); |
866 } | 866 } |
867 browser->window()->Show(); | 867 browser->window()->Show(); |
868 } | 868 } |
OLD | NEW |