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/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 const GURL& location, | 884 const GURL& location, |
885 int status_code) { | 885 int status_code) { |
886 } | 886 } |
887 | 887 |
888 void TaskManagerModel::OnBytesRead(net::URLRequestJob* job, const char* buf, | 888 void TaskManagerModel::OnBytesRead(net::URLRequestJob* job, const char* buf, |
889 int byte_count) { | 889 int byte_count) { |
890 int render_process_host_child_id = -1, routing_id = -1; | 890 int render_process_host_child_id = -1, routing_id = -1; |
891 if (!ResourceDispatcherHost::RenderViewForRequest(job->request(), | 891 if (!ResourceDispatcherHost::RenderViewForRequest(job->request(), |
892 &render_process_host_child_id, | 892 &render_process_host_child_id, |
893 &routing_id)) { | 893 &routing_id)) { |
894 NOTREACHED(); | 894 // Only net::URLRequestJob instances created by the ResourceDispatcherHost |
| 895 // have a render view associated. Jobs from components such as the |
| 896 // SearchProvider for autocomplete, have no associated view, so we can't |
| 897 // correctly attribute the bandwidth they consume. |
| 898 // TODO(wez): All jobs' resources should ideally be accountable, even if |
| 899 // only by contributing to the Browser process' stats. |
| 900 return; |
895 } | 901 } |
896 | 902 |
897 // This happens in the IO thread, post it to the UI thread. | 903 // This happens in the IO thread, post it to the UI thread. |
898 int origin_child_id = | 904 int origin_child_id = |
899 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); | 905 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); |
900 BrowserThread::PostTask( | 906 BrowserThread::PostTask( |
901 BrowserThread::UI, FROM_HERE, | 907 BrowserThread::UI, FROM_HERE, |
902 NewRunnableMethod( | 908 NewRunnableMethod( |
903 this, | 909 this, |
904 &TaskManagerModel::BytesRead, | 910 &TaskManagerModel::BytesRead, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 MetricsMap::const_iterator iter = metrics_map_.find(handle); | 1034 MetricsMap::const_iterator iter = metrics_map_.find(handle); |
1029 if (iter == metrics_map_.end()) | 1035 if (iter == metrics_map_.end()) |
1030 return false; | 1036 return false; |
1031 | 1037 |
1032 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) | 1038 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) |
1033 return false; | 1039 return false; |
1034 | 1040 |
1035 memory_usage_map_.insert(std::make_pair(handle, *usage)); | 1041 memory_usage_map_.insert(std::make_pair(handle, *usage)); |
1036 return true; | 1042 return true; |
1037 } | 1043 } |
OLD | NEW |