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/location.h" |
10 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
12 #include "base/process/process_metrics.h" | 13 #include "base/process/process_metrics.h" |
| 14 #include "base/single_thread_task_runner.h" |
13 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
14 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
15 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/thread_task_runner_handle.h" |
18 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/profiles/profile_window.h" | 23 #include "chrome/browser/profiles/profile_window.h" |
21 #include "chrome/browser/task_manager/background_information.h" | 24 #include "chrome/browser/task_manager/background_information.h" |
22 #include "chrome/browser/task_manager/browser_process_resource_provider.h" | 25 #include "chrome/browser/task_manager/browser_process_resource_provider.h" |
23 #include "chrome/browser/task_manager/child_process_resource_provider.h" | 26 #include "chrome/browser/task_manager/child_process_resource_provider.h" |
24 #include "chrome/browser/task_manager/extension_information.h" | 27 #include "chrome/browser/task_manager/extension_information.h" |
25 #include "chrome/browser/task_manager/guest_information.h" | 28 #include "chrome/browser/task_manager/guest_information.h" |
26 #include "chrome/browser/task_manager/panel_information.h" | 29 #include "chrome/browser/task_manager/panel_information.h" |
27 #include "chrome/browser/task_manager/printing_information.h" | 30 #include "chrome/browser/task_manager/printing_information.h" |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 // action the first time. | 1018 // action the first time. |
1016 update_requests_++; | 1019 update_requests_++; |
1017 if (update_requests_ > 1) | 1020 if (update_requests_ > 1) |
1018 return; | 1021 return; |
1019 DCHECK_EQ(1, update_requests_); | 1022 DCHECK_EQ(1, update_requests_); |
1020 DCHECK_NE(TASK_PENDING, update_state_); | 1023 DCHECK_NE(TASK_PENDING, update_state_); |
1021 | 1024 |
1022 // If update_state_ is STOPPING, it means a task is still pending. Setting | 1025 // If update_state_ is STOPPING, it means a task is still pending. Setting |
1023 // it to TASK_PENDING ensures the tasks keep being posted (by Refresh()). | 1026 // it to TASK_PENDING ensures the tasks keep being posted (by Refresh()). |
1024 if (update_state_ == IDLE) { | 1027 if (update_state_ == IDLE) { |
1025 base::MessageLoop::current()->PostTask( | 1028 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1026 FROM_HERE, | 1029 FROM_HERE, base::Bind(&TaskManagerModel::RefreshCallback, this)); |
1027 base::Bind(&TaskManagerModel::RefreshCallback, this)); | |
1028 } | 1030 } |
1029 update_state_ = TASK_PENDING; | 1031 update_state_ = TASK_PENDING; |
1030 | 1032 |
1031 // Notify resource providers that we are updating. | 1033 // Notify resource providers that we are updating. |
1032 StartListening(); | 1034 StartListening(); |
1033 | 1035 |
1034 if (!resources_.empty()) { | 1036 if (!resources_.empty()) { |
1035 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, | 1037 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, |
1036 OnReadyPeriodicalUpdate()); | 1038 OnReadyPeriodicalUpdate()); |
1037 } | 1039 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 if (info) | 1234 if (info) |
1233 info->GetAssociatedRenderFrame(&child_id, &route_id); | 1235 info->GetAssociatedRenderFrame(&child_id, &route_id); |
1234 | 1236 |
1235 // Get the origin PID of the request's originator. This will only be set for | 1237 // Get the origin PID of the request's originator. This will only be set for |
1236 // plugins - for renderer or browser initiated requests it will be zero. | 1238 // plugins - for renderer or browser initiated requests it will be zero. |
1237 int origin_pid = 0; | 1239 int origin_pid = 0; |
1238 if (info) | 1240 if (info) |
1239 origin_pid = info->GetOriginPID(); | 1241 origin_pid = info->GetOriginPID(); |
1240 | 1242 |
1241 if (bytes_read_buffer_.empty()) { | 1243 if (bytes_read_buffer_.empty()) { |
1242 base::MessageLoop::current()->PostDelayedTask( | 1244 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1243 FROM_HERE, | 1245 FROM_HERE, base::Bind(&TaskManagerModel::NotifyMultipleBytesRead, this), |
1244 base::Bind(&TaskManagerModel::NotifyMultipleBytesRead, this), | |
1245 base::TimeDelta::FromSeconds(1)); | 1246 base::TimeDelta::FromSeconds(1)); |
1246 } | 1247 } |
1247 | 1248 |
1248 bytes_read_buffer_.push_back( | 1249 bytes_read_buffer_.push_back( |
1249 BytesReadParam(origin_pid, child_id, route_id, byte_count)); | 1250 BytesReadParam(origin_pid, child_id, route_id, byte_count)); |
1250 } | 1251 } |
1251 | 1252 |
1252 // This is called on the UI thread. | 1253 // This is called on the UI thread. |
1253 void TaskManagerModel::NotifyDataReady() { | 1254 void TaskManagerModel::NotifyDataReady() { |
1254 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 19 matching lines...) Expand all Loading... |
1274 | 1275 |
1275 if (update_state_ == STOPPING) { | 1276 if (update_state_ == STOPPING) { |
1276 // We have been asked to stop. | 1277 // We have been asked to stop. |
1277 update_state_ = IDLE; | 1278 update_state_ = IDLE; |
1278 return; | 1279 return; |
1279 } | 1280 } |
1280 | 1281 |
1281 Refresh(); | 1282 Refresh(); |
1282 | 1283 |
1283 // Schedule the next update. | 1284 // Schedule the next update. |
1284 base::MessageLoop::current()->PostDelayedTask( | 1285 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1285 FROM_HERE, | 1286 FROM_HERE, base::Bind(&TaskManagerModel::RefreshCallback, this), |
1286 base::Bind(&TaskManagerModel::RefreshCallback, this), | |
1287 base::TimeDelta::FromMilliseconds(kUpdateTimeMs)); | 1287 base::TimeDelta::FromMilliseconds(kUpdateTimeMs)); |
1288 } | 1288 } |
1289 | 1289 |
1290 void TaskManagerModel::RefreshVideoMemoryUsageStats() { | 1290 void TaskManagerModel::RefreshVideoMemoryUsageStats() { |
1291 if (pending_video_memory_usage_stats_update_) | 1291 if (pending_video_memory_usage_stats_update_) |
1292 return; | 1292 return; |
1293 | 1293 |
1294 if (!video_memory_usage_stats_observer_.get()) { | 1294 if (!video_memory_usage_stats_observer_.get()) { |
1295 video_memory_usage_stats_observer_.reset( | 1295 video_memory_usage_stats_observer_.reset( |
1296 new TaskManagerModelGpuDataManagerObserver()); | 1296 new TaskManagerModelGpuDataManagerObserver()); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 params.host_desktop_type = desktop_type; | 1536 params.host_desktop_type = desktop_type; |
1537 chrome::Navigate(¶ms); | 1537 chrome::Navigate(¶ms); |
1538 } | 1538 } |
1539 | 1539 |
1540 TaskManager::TaskManager() | 1540 TaskManager::TaskManager() |
1541 : model_(new TaskManagerModel(this)) { | 1541 : model_(new TaskManagerModel(this)) { |
1542 } | 1542 } |
1543 | 1543 |
1544 TaskManager::~TaskManager() { | 1544 TaskManager::~TaskManager() { |
1545 } | 1545 } |
OLD | NEW |