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

Side by Side Diff: chrome/browser/task_manager.cc

Issue 500118: Fix cpu/memory measurements on OS X. (Closed)
Patch Set: foobar Created 11 years 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
OLDNEW
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
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)
536 base::ProcessMetrics::CreateProcessMetrics(process); 537 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
537 metrics_map_[process] = pm; 544 metrics_map_[process] = pm;
538 } 545 }
539 546
540 // Notify the table that the contents have changed for it to redraw. 547 // Notify the table that the contents have changed for it to redraw.
541 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, 548 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
542 OnItemsAdded(new_entry_index, 1)); 549 OnItemsAdded(new_entry_index, 1));
543 } 550 }
544 551
545 void TaskManagerModel::RemoveResource(TaskManager::Resource* resource) { 552 void TaskManagerModel::RemoveResource(TaskManager::Resource* resource) {
546 base::ProcessHandle process = resource->GetProcess(); 553 base::ProcessHandle process = resource->GetProcess();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // notifications. Every time we get notified some bytes were read we bump a 770 // notifications. Every time we get notified some bytes were read we bump a
764 // counter of read bytes for the associated resource. When the timer ticks, 771 // counter of read bytes for the associated resource. When the timer ticks,
765 // we'll compute the actual network usage (see the Refresh method). 772 // we'll compute the actual network usage (see the Refresh method).
766 void TaskManagerModel::OnJobAdded(URLRequestJob* job) { 773 void TaskManagerModel::OnJobAdded(URLRequestJob* job) {
767 } 774 }
768 775
769 void TaskManagerModel::OnJobRemoved(URLRequestJob* job) { 776 void TaskManagerModel::OnJobRemoved(URLRequestJob* job) {
770 } 777 }
771 778
772 void TaskManagerModel::OnJobDone(URLRequestJob* job, 779 void TaskManagerModel::OnJobDone(URLRequestJob* job,
773 const URLRequestStatus& status) { 780 const URLRequestStatus& status) {
774 } 781 }
775 782
776 void TaskManagerModel::OnJobRedirect(URLRequestJob* job, 783 void TaskManagerModel::OnJobRedirect(URLRequestJob* job,
777 const GURL& location, 784 const GURL& location,
778 int status_code) { 785 int status_code) {
779 } 786 }
780 787
781 void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) { 788 void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) {
782 int render_process_host_child_id = -1, routing_id = -1; 789 int render_process_host_child_id = -1, routing_id = -1;
783 ResourceDispatcherHost::RenderViewForRequest(job->request(), 790 ResourceDispatcherHost::RenderViewForRequest(job->request(),
784 &render_process_host_child_id, 791 &render_process_host_child_id,
785 &routing_id); 792 &routing_id);
786 // This happens in the IO thread, post it to the UI thread. 793 // This happens in the IO thread, post it to the UI thread.
787 int origin_child_id = 794 int origin_child_id =
788 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); 795 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // or popup, we can only have one tab, hence we need to process this in a 891 // or popup, we can only have one tab, hence we need to process this in a
885 // tabbed browser window. Currently, |browser| is pointing to the application, 892 // tabbed browser window. Currently, |browser| is pointing to the application,
886 // popup window. Therefore, we have to retrieve the last active tab again, 893 // popup window. Therefore, we have to retrieve the last active tab again,
887 // since a new window has been used. 894 // since a new window has been used.
888 if (browser->type() & Browser::TYPE_APP_POPUP) { 895 if (browser->type() & Browser::TYPE_APP_POPUP) {
889 browser = BrowserList::GetLastActive(); 896 browser = BrowserList::GetLastActive();
890 DCHECK(browser); 897 DCHECK(browser);
891 } 898 }
892 browser->window()->Show(); 899 browser->window()->Show();
893 } 900 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698