OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/process/process_metrics.h" | 12 #include "base/process/process_metrics.h" |
| 13 #include "base/profiler/scoped_tracker.h" |
13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/profiles/profile_window.h" | 21 #include "chrome/browser/profiles/profile_window.h" |
21 #include "chrome/browser/task_manager/background_information.h" | 22 #include "chrome/browser/task_manager/background_information.h" |
22 #include "chrome/browser/task_manager/browser_process_resource_provider.h" | 23 #include "chrome/browser/task_manager/browser_process_resource_provider.h" |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 for (ResourceList::iterator it = resources_.begin(); | 1223 for (ResourceList::iterator it = resources_.begin(); |
1223 it != resources_.end(); ++it) { | 1224 it != resources_.end(); ++it) { |
1224 if (base::GetProcId((*it)->GetProcess()) == renderer_id) { | 1225 if (base::GetProcId((*it)->GetProcess()) == renderer_id) { |
1225 (*it)->NotifyV8HeapStats(v8_memory_allocated, v8_memory_used); | 1226 (*it)->NotifyV8HeapStats(v8_memory_allocated, v8_memory_used); |
1226 } | 1227 } |
1227 } | 1228 } |
1228 } | 1229 } |
1229 | 1230 |
1230 void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request, | 1231 void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request, |
1231 int byte_count) { | 1232 int byte_count) { |
| 1233 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 1234 tracked_objects::ScopedTracker tracking_profile1( |
| 1235 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1236 "423948 TaskManagerModel::NotifyBytesRead1")); |
| 1237 |
1232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1233 if (!is_updating_byte_count_) | 1239 if (!is_updating_byte_count_) |
1234 return; | 1240 return; |
1235 | 1241 |
1236 // Only net::URLRequestJob instances created by the ResourceDispatcherHost | 1242 // Only net::URLRequestJob instances created by the ResourceDispatcherHost |
1237 // have an associated ResourceRequestInfo and a render frame associated. | 1243 // have an associated ResourceRequestInfo and a render frame associated. |
1238 // All other jobs will have -1 returned for the render process child and | 1244 // All other jobs will have -1 returned for the render process child and |
1239 // routing ids - the jobs may still match a resource based on their origin id, | 1245 // routing ids - the jobs may still match a resource based on their origin id, |
1240 // otherwise BytesRead() will attribute the activity to the Browser resource. | 1246 // otherwise BytesRead() will attribute the activity to the Browser resource. |
1241 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); | 1247 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); |
1242 int child_id = -1, route_id = -1; | 1248 int child_id = -1, route_id = -1; |
1243 if (info) | 1249 if (info) |
1244 info->GetAssociatedRenderFrame(&child_id, &route_id); | 1250 info->GetAssociatedRenderFrame(&child_id, &route_id); |
1245 | 1251 |
1246 // Get the origin PID of the request's originator. This will only be set for | 1252 // Get the origin PID of the request's originator. This will only be set for |
1247 // plugins - for renderer or browser initiated requests it will be zero. | 1253 // plugins - for renderer or browser initiated requests it will be zero. |
1248 int origin_pid = 0; | 1254 int origin_pid = 0; |
1249 if (info) | 1255 if (info) |
1250 origin_pid = info->GetOriginPID(); | 1256 origin_pid = info->GetOriginPID(); |
1251 | 1257 |
1252 if (bytes_read_buffer_.empty()) { | 1258 if (bytes_read_buffer_.empty()) { |
1253 base::MessageLoop::current()->PostDelayedTask( | 1259 base::MessageLoop::current()->PostDelayedTask( |
1254 FROM_HERE, | 1260 FROM_HERE, |
1255 base::Bind(&TaskManagerModel::NotifyMultipleBytesRead, this), | 1261 base::Bind(&TaskManagerModel::NotifyMultipleBytesRead, this), |
1256 base::TimeDelta::FromSeconds(1)); | 1262 base::TimeDelta::FromSeconds(1)); |
1257 } | 1263 } |
1258 | 1264 |
| 1265 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 1266 tracked_objects::ScopedTracker tracking_profile2( |
| 1267 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1268 "423948 TaskManagerModel::NotifyBytesRead2")); |
| 1269 |
1259 bytes_read_buffer_.push_back( | 1270 bytes_read_buffer_.push_back( |
1260 BytesReadParam(origin_pid, child_id, route_id, byte_count)); | 1271 BytesReadParam(origin_pid, child_id, route_id, byte_count)); |
1261 } | 1272 } |
1262 | 1273 |
1263 // This is called on the UI thread. | 1274 // This is called on the UI thread. |
1264 void TaskManagerModel::NotifyDataReady() { | 1275 void TaskManagerModel::NotifyDataReady() { |
1265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1266 for (size_t i = 0; i < on_data_ready_callbacks_.size(); ++i) { | 1277 for (size_t i = 0; i < on_data_ready_callbacks_.size(); ++i) { |
1267 if (!on_data_ready_callbacks_[i].is_null()) | 1278 if (!on_data_ready_callbacks_[i].is_null()) |
1268 on_data_ready_callbacks_[i].Run(); | 1279 on_data_ready_callbacks_[i].Run(); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 params.host_desktop_type = desktop_type; | 1555 params.host_desktop_type = desktop_type; |
1545 chrome::Navigate(¶ms); | 1556 chrome::Navigate(¶ms); |
1546 } | 1557 } |
1547 | 1558 |
1548 TaskManager::TaskManager() | 1559 TaskManager::TaskManager() |
1549 : model_(new TaskManagerModel(this)) { | 1560 : model_(new TaskManagerModel(this)) { |
1550 } | 1561 } |
1551 | 1562 |
1552 TaskManager::~TaskManager() { | 1563 TaskManager::~TaskManager() { |
1553 } | 1564 } |
OLD | NEW |