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

Side by Side Diff: content/gpu/gpu_child_thread.cc

Issue 8536037: base::Bind: Low-hanging fruit conversions of NewRunnableFunction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win fix 4. Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/user_metrics.cc ('k') | content/renderer/devtools_agent_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/gpu/gpu_child_thread.h" 5 #include "content/gpu/gpu_child_thread.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
12 #include "base/win/scoped_com_initializer.h" 13 #include "base/win/scoped_com_initializer.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "content/common/child_process.h" 15 #include "content/common/child_process.h"
15 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
16 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
17 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
18 #include "content/gpu/gpu_info_collector.h" 19 #include "content/gpu/gpu_info_collector.h"
19 #include "content/gpu/gpu_watchdog_thread.h" 20 #include "content/gpu/gpu_watchdog_thread.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 169
169 void GpuChildThread::OnCollectGraphicsInfo() { 170 void GpuChildThread::OnCollectGraphicsInfo() {
170 #if defined(OS_WIN) 171 #if defined(OS_WIN)
171 if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { 172 if (!gpu_info_.finalized && !collecting_dx_diagnostics_) {
172 // Prevent concurrent collection of DirectX diagnostics. 173 // Prevent concurrent collection of DirectX diagnostics.
173 collecting_dx_diagnostics_ = true; 174 collecting_dx_diagnostics_ = true;
174 175
175 // Asynchronously collect the DirectX diagnostics because this can take a 176 // Asynchronously collect the DirectX diagnostics because this can take a
176 // couple of seconds. 177 // couple of seconds.
177 if (!base::WorkerPool::PostTask( 178 if (!base::WorkerPool::PostTask(
178 FROM_HERE, 179 FROM_HERE, base::Bind(&GpuChildThread::CollectDxDiagnostics, this),
179 NewRunnableFunction(&GpuChildThread::CollectDxDiagnostics, this),
180 true)) { 180 true)) {
181 // Flag GPU info as complete if the DirectX diagnostics cannot be 181 // Flag GPU info as complete if the DirectX diagnostics cannot be
182 // collected. 182 // collected.
183 collecting_dx_diagnostics_ = false; 183 collecting_dx_diagnostics_ = false;
184 gpu_info_.finalized = true; 184 gpu_info_.finalized = true;
185 } else { 185 } else {
186 // Do not send response if we are still completing the GPUInfo struct 186 // Do not send response if we are still completing the GPUInfo struct
187 return; 187 return;
188 } 188 }
189 } 189 }
(...skipping 26 matching lines...) Expand all
216 216
217 // Runs on a worker thread. The GPU process never terminates voluntarily so 217 // Runs on a worker thread. The GPU process never terminates voluntarily so
218 // it is safe to assume that its message loop is valid. 218 // it is safe to assume that its message loop is valid.
219 void GpuChildThread::CollectDxDiagnostics(GpuChildThread* thread) { 219 void GpuChildThread::CollectDxDiagnostics(GpuChildThread* thread) {
220 base::win::ScopedCOMInitializer com_initializer; 220 base::win::ScopedCOMInitializer com_initializer;
221 221
222 content::DxDiagNode node; 222 content::DxDiagNode node;
223 gpu_info_collector::GetDxDiagnostics(&node); 223 gpu_info_collector::GetDxDiagnostics(&node);
224 224
225 thread->message_loop()->PostTask( 225 thread->message_loop()->PostTask(
226 FROM_HERE, 226 FROM_HERE, base::Bind(&GpuChildThread::SetDxDiagnostics, thread, node));
227 NewRunnableFunction(&GpuChildThread::SetDxDiagnostics, thread, node));
228 } 227 }
229 228
230 // Runs on the main thread. 229 // Runs on the main thread.
231 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, 230 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread,
232 const content::DxDiagNode& node) { 231 const content::DxDiagNode& node) {
233 thread->gpu_info_.dx_diagnostics = node; 232 thread->gpu_info_.dx_diagnostics = node;
234 thread->gpu_info_.finalized = true; 233 thread->gpu_info_.finalized = true;
235 thread->collecting_dx_diagnostics_ = false; 234 thread->collecting_dx_diagnostics_ = false;
236 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); 235 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_));
237 } 236 }
238 237
239 #endif 238 #endif
OLDNEW
« no previous file with comments | « content/browser/user_metrics.cc ('k') | content/renderer/devtools_agent_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698