| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 resources_.end(), | 526 resources_.end(), |
| 527 (*group_entries)[group_entries->size() - 2]); | 527 (*group_entries)[group_entries->size() - 2]); |
| 528 DCHECK(iter != resources_.end()); | 528 DCHECK(iter != resources_.end()); |
| 529 new_entry_index = static_cast<int>(iter - resources_.begin()); | 529 new_entry_index = static_cast<int>(iter - resources_.begin()); |
| 530 resources_.insert(++iter, resource); | 530 resources_.insert(++iter, resource); |
| 531 } | 531 } |
| 532 | 532 |
| 533 // Create the ProcessMetrics for this process if needed (not in map). | 533 // Create the ProcessMetrics for this process if needed (not in map). |
| 534 if (metrics_map_.find(process) == metrics_map_.end()) { | 534 if (metrics_map_.find(process) == metrics_map_.end()) { |
| 535 base::ProcessMetrics* pm = | 535 base::ProcessMetrics* pm = |
| 536 #if !defined(OS_MACOSX) | |
| 537 base::ProcessMetrics::CreateProcessMetrics(process); | 536 base::ProcessMetrics::CreateProcessMetrics(process); |
| 538 #else | |
| 539 // TODO(thakis): Write a port provider that knows the task ports of | |
| 540 // child processes. | |
| 541 base::ProcessMetrics::CreateProcessMetrics(process, NULL); | |
| 542 #endif | |
| 543 | |
| 544 metrics_map_[process] = pm; | 537 metrics_map_[process] = pm; |
| 545 } | 538 } |
| 546 | 539 |
| 547 // Notify the table that the contents have changed for it to redraw. | 540 // Notify the table that the contents have changed for it to redraw. |
| 548 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, | 541 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, |
| 549 OnItemsAdded(new_entry_index, 1)); | 542 OnItemsAdded(new_entry_index, 1)); |
| 550 } | 543 } |
| 551 | 544 |
| 552 void TaskManagerModel::RemoveResource(TaskManager::Resource* resource) { | 545 void TaskManagerModel::RemoveResource(TaskManager::Resource* resource) { |
| 553 base::ProcessHandle process = resource->GetProcess(); | 546 base::ProcessHandle process = resource->GetProcess(); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 // notifications. Every time we get notified some bytes were read we bump a | 763 // notifications. Every time we get notified some bytes were read we bump a |
| 771 // counter of read bytes for the associated resource. When the timer ticks, | 764 // counter of read bytes for the associated resource. When the timer ticks, |
| 772 // we'll compute the actual network usage (see the Refresh method). | 765 // we'll compute the actual network usage (see the Refresh method). |
| 773 void TaskManagerModel::OnJobAdded(URLRequestJob* job) { | 766 void TaskManagerModel::OnJobAdded(URLRequestJob* job) { |
| 774 } | 767 } |
| 775 | 768 |
| 776 void TaskManagerModel::OnJobRemoved(URLRequestJob* job) { | 769 void TaskManagerModel::OnJobRemoved(URLRequestJob* job) { |
| 777 } | 770 } |
| 778 | 771 |
| 779 void TaskManagerModel::OnJobDone(URLRequestJob* job, | 772 void TaskManagerModel::OnJobDone(URLRequestJob* job, |
| 780 const URLRequestStatus& status) { | 773 const URLRequestStatus& status) { |
| 781 } | 774 } |
| 782 | 775 |
| 783 void TaskManagerModel::OnJobRedirect(URLRequestJob* job, | 776 void TaskManagerModel::OnJobRedirect(URLRequestJob* job, |
| 784 const GURL& location, | 777 const GURL& location, |
| 785 int status_code) { | 778 int status_code) { |
| 786 } | 779 } |
| 787 | 780 |
| 788 void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) { | 781 void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) { |
| 789 int render_process_host_child_id = -1, routing_id = -1; | 782 int render_process_host_child_id = -1, routing_id = -1; |
| 790 ResourceDispatcherHost::RenderViewForRequest(job->request(), | 783 ResourceDispatcherHost::RenderViewForRequest(job->request(), |
| 791 &render_process_host_child_id, | 784 &render_process_host_child_id, |
| 792 &routing_id); | 785 &routing_id); |
| 793 // This happens in the IO thread, post it to the UI thread. | 786 // This happens in the IO thread, post it to the UI thread. |
| 794 int origin_child_id = | 787 int origin_child_id = |
| 795 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); | 788 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 // or popup, we can only have one tab, hence we need to process this in a | 884 // or popup, we can only have one tab, hence we need to process this in a |
| 892 // tabbed browser window. Currently, |browser| is pointing to the application, | 885 // tabbed browser window. Currently, |browser| is pointing to the application, |
| 893 // popup window. Therefore, we have to retrieve the last active tab again, | 886 // popup window. Therefore, we have to retrieve the last active tab again, |
| 894 // since a new window has been used. | 887 // since a new window has been used. |
| 895 if (browser->type() & Browser::TYPE_APP_POPUP) { | 888 if (browser->type() & Browser::TYPE_APP_POPUP) { |
| 896 browser = BrowserList::GetLastActive(); | 889 browser = BrowserList::GetLastActive(); |
| 897 DCHECK(browser); | 890 DCHECK(browser); |
| 898 } | 891 } |
| 899 browser->window()->Show(); | 892 browser->window()->Show(); |
| 900 } | 893 } |
| OLD | NEW |