OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 858 |
859 ResourceValueMap::const_iterator iter_res = | 859 ResourceValueMap::const_iterator iter_res = |
860 current_byte_count_map_.find(resource); | 860 current_byte_count_map_.find(resource); |
861 if (iter_res == current_byte_count_map_.end()) | 861 if (iter_res == current_byte_count_map_.end()) |
862 current_byte_count_map_[resource] = param.byte_count; | 862 current_byte_count_map_[resource] = param.byte_count; |
863 else | 863 else |
864 current_byte_count_map_[resource] = iter_res->second + param.byte_count; | 864 current_byte_count_map_[resource] = iter_res->second + param.byte_count; |
865 } | 865 } |
866 | 866 |
867 | 867 |
868 // In order to retrieve the network usage, we register for URLRequestJob | 868 // In order to retrieve the network usage, we register for net::URLRequestJob |
869 // notifications. Every time we get notified some bytes were read we bump a | 869 // notifications. Every time we get notified some bytes were read we bump a |
870 // counter of read bytes for the associated resource. When the timer ticks, | 870 // counter of read bytes for the associated resource. When the timer ticks, |
871 // we'll compute the actual network usage (see the Refresh method). | 871 // we'll compute the actual network usage (see the Refresh method). |
872 void TaskManagerModel::OnJobAdded(URLRequestJob* job) { | 872 void TaskManagerModel::OnJobAdded(net::URLRequestJob* job) { |
873 } | 873 } |
874 | 874 |
875 void TaskManagerModel::OnJobRemoved(URLRequestJob* job) { | 875 void TaskManagerModel::OnJobRemoved(net::URLRequestJob* job) { |
876 } | 876 } |
877 | 877 |
878 void TaskManagerModel::OnJobDone(URLRequestJob* job, | 878 void TaskManagerModel::OnJobDone(net::URLRequestJob* job, |
879 const URLRequestStatus& status) { | 879 const URLRequestStatus& status) { |
880 } | 880 } |
881 | 881 |
882 void TaskManagerModel::OnJobRedirect(URLRequestJob* job, | 882 void TaskManagerModel::OnJobRedirect(net::URLRequestJob* job, |
883 const GURL& location, | 883 const GURL& location, |
884 int status_code) { | 884 int status_code) { |
885 } | 885 } |
886 | 886 |
887 void TaskManagerModel::OnBytesRead(URLRequestJob* job, const char* buf, | 887 void TaskManagerModel::OnBytesRead(net::URLRequestJob* job, const char* buf, |
888 int byte_count) { | 888 int byte_count) { |
889 int render_process_host_child_id = -1, routing_id = -1; | 889 int render_process_host_child_id = -1, routing_id = -1; |
890 ResourceDispatcherHost::RenderViewForRequest(job->request(), | 890 ResourceDispatcherHost::RenderViewForRequest(job->request(), |
891 &render_process_host_child_id, | 891 &render_process_host_child_id, |
892 &routing_id); | 892 &routing_id); |
893 // This happens in the IO thread, post it to the UI thread. | 893 // This happens in the IO thread, post it to the UI thread. |
894 int origin_child_id = | 894 int origin_child_id = |
895 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); | 895 chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request()); |
896 BrowserThread::PostTask( | 896 BrowserThread::PostTask( |
897 BrowserThread::UI, FROM_HERE, | 897 BrowserThread::UI, FROM_HERE, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 MetricsMap::const_iterator iter = metrics_map_.find(handle); | 1024 MetricsMap::const_iterator iter = metrics_map_.find(handle); |
1025 if (iter == metrics_map_.end()) | 1025 if (iter == metrics_map_.end()) |
1026 return false; | 1026 return false; |
1027 | 1027 |
1028 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) | 1028 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) |
1029 return false; | 1029 return false; |
1030 | 1030 |
1031 memory_usage_map_.insert(std::make_pair(handle, *usage)); | 1031 memory_usage_map_.insert(std::make_pair(handle, *usage)); |
1032 return true; | 1032 return true; |
1033 } | 1033 } |
OLD | NEW |