| 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" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 //////////////////////////////////////////////////////////////////////////////// | 53 //////////////////////////////////////////////////////////////////////////////// |
| 54 // TaskManagerModel class | 54 // TaskManagerModel class |
| 55 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 int TaskManagerModel::goats_teleported_ = 0; | 58 int TaskManagerModel::goats_teleported_ = 0; |
| 59 | 59 |
| 60 TaskManagerModel::TaskManagerModel(TaskManager* task_manager) | 60 TaskManagerModel::TaskManagerModel(TaskManager* task_manager) |
| 61 : ui_loop_(MessageLoop::current()), | 61 : update_state_(IDLE) { |
| 62 update_state_(IDLE) { | |
| 63 | 62 |
| 64 TaskManagerBrowserProcessResourceProvider* browser_provider = | 63 TaskManagerBrowserProcessResourceProvider* browser_provider = |
| 65 new TaskManagerBrowserProcessResourceProvider(task_manager); | 64 new TaskManagerBrowserProcessResourceProvider(task_manager); |
| 66 browser_provider->AddRef(); | 65 browser_provider->AddRef(); |
| 67 providers_.push_back(browser_provider); | 66 providers_.push_back(browser_provider); |
| 68 TaskManagerTabContentsResourceProvider* wc_provider = | 67 TaskManagerTabContentsResourceProvider* wc_provider = |
| 69 new TaskManagerTabContentsResourceProvider(task_manager); | 68 new TaskManagerTabContentsResourceProvider(task_manager); |
| 70 wc_provider->AddRef(); | 69 wc_provider->AddRef(); |
| 71 providers_.push_back(wc_provider); | 70 providers_.push_back(wc_provider); |
| 72 TaskManagerChildProcessResourceProvider* child_process_provider = | 71 TaskManagerChildProcessResourceProvider* child_process_provider = |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 754 } |
| 756 | 755 |
| 757 void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) { | 756 void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) { |
| 758 int render_process_host_child_id = -1, routing_id = -1; | 757 int render_process_host_child_id = -1, routing_id = -1; |
| 759 ResourceDispatcherHost::RenderViewForRequest(job->request(), | 758 ResourceDispatcherHost::RenderViewForRequest(job->request(), |
| 760 &render_process_host_child_id, | 759 &render_process_host_child_id, |
| 761 &routing_id); | 760 &routing_id); |
| 762 // This happens in the IO thread, post it to the UI thread. | 761 // This happens in the IO thread, post it to the UI thread. |
| 763 int origin_child_id = | 762 int origin_child_id = |
| 764 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); | 763 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); |
| 765 ui_loop_->PostTask(FROM_HERE, | 764 ChromeThread::PostTask( |
| 766 NewRunnableMethod( | 765 ChromeThread::UI, FROM_HERE, |
| 767 this, | 766 NewRunnableMethod( |
| 768 &TaskManagerModel::BytesRead, | 767 this, |
| 769 BytesReadParam(origin_child_id, | 768 &TaskManagerModel::BytesRead, |
| 770 render_process_host_child_id, | 769 BytesReadParam(origin_child_id, |
| 771 routing_id, byte_count))); | 770 render_process_host_child_id, |
| 771 routing_id, byte_count))); |
| 772 } | 772 } |
| 773 | 773 |
| 774 bool TaskManagerModel::GetProcessMetricsForRow( | 774 bool TaskManagerModel::GetProcessMetricsForRow( |
| 775 int row, base::ProcessMetrics** proc_metrics) const { | 775 int row, base::ProcessMetrics** proc_metrics) const { |
| 776 DCHECK(row < ResourceCount()); | 776 DCHECK(row < ResourceCount()); |
| 777 *proc_metrics = NULL; | 777 *proc_metrics = NULL; |
| 778 | 778 |
| 779 MetricsMap::const_iterator iter = | 779 MetricsMap::const_iterator iter = |
| 780 metrics_map_.find(resources_[row]->GetProcess()); | 780 metrics_map_.find(resources_[row]->GetProcess()); |
| 781 if (iter == metrics_map_.end()) | 781 if (iter == metrics_map_.end()) |
| (...skipping 77 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 |