| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/sampling/task_group.h" | 5 #include "chrome/browser/task_manager/sampling/task_group.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/base_features.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/task_manager/sampling/shared_sampler.h" | 14 #include "chrome/browser/task_manager/sampling/shared_sampler.h" |
| 14 #include "chrome/browser/task_manager/task_manager_observer.h" | 15 #include "chrome/browser/task_manager/task_manager_observer.h" |
| 15 #include "components/nacl/browser/nacl_browser.h" | 16 #include "components/nacl/browser/nacl_browser.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/memory_coordinator.h" | 18 #include "content/public/browser/memory_coordinator.h" |
| 18 #include "content/public/common/content_features.h" | |
| 19 #include "gpu/ipc/common/memory_stats.h" | 19 #include "gpu/ipc/common/memory_stats.h" |
| 20 | 20 |
| 21 namespace task_manager { | 21 namespace task_manager { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // A mask for the refresh types that are done in the background thread. | 25 // A mask for the refresh types that are done in the background thread. |
| 26 const int kBackgroundRefreshTypesMask = | 26 const int kBackgroundRefreshTypesMask = |
| 27 REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY | REFRESH_TYPE_IDLE_WAKEUPS | | 27 REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY | REFRESH_TYPE_IDLE_WAKEUPS | |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // implementation supports that. The actual work is done on the worker thread. | 203 // implementation supports that. The actual work is done on the worker thread. |
| 204 // At the moment this is supported only on OS_WIN. | 204 // At the moment this is supported only on OS_WIN. |
| 205 if (shared_refresh_flags != 0) { | 205 if (shared_refresh_flags != 0) { |
| 206 shared_sampler_->Refresh(process_id_, shared_refresh_flags); | 206 shared_sampler_->Refresh(process_id_, shared_refresh_flags); |
| 207 refresh_flags &= ~shared_refresh_flags; | 207 refresh_flags &= ~shared_refresh_flags; |
| 208 } | 208 } |
| 209 | 209 |
| 210 // 6- Refresh memory state when memory coordinator is enabled. | 210 // 6- Refresh memory state when memory coordinator is enabled. |
| 211 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_MEMORY_STATE, | 211 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_MEMORY_STATE, |
| 212 refresh_flags) && | 212 refresh_flags) && |
| 213 base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { | 213 base::FeatureList::IsEnabled(base::features::kMemoryCoordinator)) { |
| 214 memory_state_ = | 214 memory_state_ = |
| 215 content::MemoryCoordinator::GetInstance()->GetStateForProcess( | 215 content::MemoryCoordinator::GetInstance()->GetStateForProcess( |
| 216 process_handle_); | 216 process_handle_); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // The remaining resource refreshes are time consuming and cannot be done on | 219 // The remaining resource refreshes are time consuming and cannot be done on |
| 220 // the UI thread. Do them all on the worker thread using the TaskGroupSampler. | 220 // the UI thread. Do them all on the worker thread using the TaskGroupSampler. |
| 221 // 7- CPU usage. | 221 // 7- CPU usage. |
| 222 // 8- Memory usage. | 222 // 8- Memory usage. |
| 223 // 9- Idle Wakeups per second. | 223 // 9- Idle Wakeups per second. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 351 |
| 352 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { | 352 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { |
| 353 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 353 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 354 | 354 |
| 355 current_on_bg_done_flags_ |= finished_refresh_type; | 355 current_on_bg_done_flags_ |= finished_refresh_type; |
| 356 if (AreBackgroundCalculationsDone()) | 356 if (AreBackgroundCalculationsDone()) |
| 357 on_background_calculations_done_.Run(); | 357 on_background_calculations_done_.Run(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 } // namespace task_manager | 360 } // namespace task_manager |
| OLD | NEW |