Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/task_management/sampling/task_group.cc

Issue 1708783002: Mustash: move content::GPUVideoMemoryUsageStats to gpu::VideoMemoryUsageStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_management/sampling/task_group.h" 5 #include "chrome/browser/task_management/sampling/task_group.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/task_management/task_manager_observer.h" 11 #include "chrome/browser/task_management/task_manager_observer.h"
12 #include "components/nacl/browser/nacl_browser.h" 12 #include "components/nacl/browser/nacl_browser.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "gpu/ipc/common/memory_stats.h"
14 15
15 namespace task_management { 16 namespace task_management {
16 17
17 namespace { 18 namespace {
18 19
19 inline bool IsResourceRefreshEnabled(RefreshType refresh_type, 20 inline bool IsResourceRefreshEnabled(RefreshType refresh_type,
20 int refresh_flags) { 21 int refresh_flags) {
21 return (refresh_flags & refresh_type) != 0; 22 return (refresh_flags & refresh_type) != 0;
22 } 23 }
23 24
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 tasks_[task->task_id()] = task; 111 tasks_[task->task_id()] = task;
111 } 112 }
112 113
113 void TaskGroup::RemoveTask(Task* task) { 114 void TaskGroup::RemoveTask(Task* task) {
114 DCHECK(task); 115 DCHECK(task);
115 DCHECK(ContainsKey(tasks_, task->task_id())); 116 DCHECK(ContainsKey(tasks_, task->task_id()));
116 117
117 tasks_.erase(task->task_id()); 118 tasks_.erase(task->task_id());
118 } 119 }
119 120
120 void TaskGroup::Refresh( 121 void TaskGroup::Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats,
121 const content::GPUVideoMemoryUsageStats& gpu_memory_stats, 122 base::TimeDelta update_interval,
122 base::TimeDelta update_interval, 123 int64_t refresh_flags) {
123 int64_t refresh_flags) {
124 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 124 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
125 125
126 // First refresh the enabled non-expensive resources usages on the UI thread. 126 // First refresh the enabled non-expensive resources usages on the UI thread.
127 // 1- Refresh all the tasks as well as the total network usage (if enabled). 127 // 1- Refresh all the tasks as well as the total network usage (if enabled).
128 const bool network_usage_refresh_enabled = 128 const bool network_usage_refresh_enabled =
129 IsResourceRefreshEnabled(REFRESH_TYPE_NETWORK_USAGE, refresh_flags); 129 IsResourceRefreshEnabled(REFRESH_TYPE_NETWORK_USAGE, refresh_flags);
130 per_process_network_usage_ = network_usage_refresh_enabled ? 0 : -1; 130 per_process_network_usage_ = network_usage_refresh_enabled ? 0 : -1;
131 for (auto& task_pair : tasks_) { 131 for (auto& task_pair : tasks_) {
132 Task* task = task_pair.second; 132 Task* task = task_pair.second;
133 task->Refresh(update_interval, refresh_flags); 133 task->Refresh(update_interval, refresh_flags);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 out_list->push_back(task_pair.first); 173 out_list->push_back(task_pair.first);
174 } 174 }
175 175
176 Task* TaskGroup::GetTaskById(TaskId task_id) const { 176 Task* TaskGroup::GetTaskById(TaskId task_id) const {
177 DCHECK(ContainsKey(tasks_, task_id)); 177 DCHECK(ContainsKey(tasks_, task_id));
178 178
179 return tasks_.at(task_id); 179 return tasks_.at(task_id);
180 } 180 }
181 181
182 void TaskGroup::RefreshGpuMemory( 182 void TaskGroup::RefreshGpuMemory(
183 const content::GPUVideoMemoryUsageStats& gpu_memory_stats) { 183 const gpu::VideoMemoryUsageStats& gpu_memory_stats) {
184 auto itr = gpu_memory_stats.process_map.find(process_id_); 184 auto itr = gpu_memory_stats.process_map.find(process_id_);
185 if (itr == gpu_memory_stats.process_map.end()) { 185 if (itr == gpu_memory_stats.process_map.end()) {
186 gpu_memory_ = -1; 186 gpu_memory_ = -1;
187 gpu_memory_has_duplicates_ = false; 187 gpu_memory_has_duplicates_ = false;
188 return; 188 return;
189 } 189 }
190 190
191 gpu_memory_ = itr->second.video_memory; 191 gpu_memory_ = itr->second.video_memory;
192 gpu_memory_has_duplicates_ = itr->second.has_duplicates; 192 gpu_memory_has_duplicates_ = itr->second.has_duplicates;
193 } 193 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 #endif // defined(OS_LINUX) 237 #endif // defined(OS_LINUX)
238 238
239 void TaskGroup::OnProcessPriorityDone(bool is_backgrounded) { 239 void TaskGroup::OnProcessPriorityDone(bool is_backgrounded) {
240 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 240 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
241 241
242 is_backgrounded_ = is_backgrounded; 242 is_backgrounded_ = is_backgrounded;
243 } 243 }
244 244
245 } // namespace task_management 245 } // namespace task_management
OLDNEW
« no previous file with comments | « chrome/browser/task_management/sampling/task_group.h ('k') | chrome/browser/task_management/sampling/task_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698