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 "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" | 5 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
11 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
13 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
14 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
15 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 17 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
16 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" | 18 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // static | 205 // static |
204 void VideoCaptureGpuJpegDecoder::GpuChannelEstablishedOnUIThread( | 206 void VideoCaptureGpuJpegDecoder::GpuChannelEstablishedOnUIThread( |
205 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 207 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
206 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this) { | 208 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this) { |
207 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 209 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
208 | 210 |
209 scoped_refptr<GpuChannelHost> gpu_channel_host( | 211 scoped_refptr<GpuChannelHost> gpu_channel_host( |
210 BrowserGpuChannelHostFactory::instance()->GetGpuChannel()); | 212 BrowserGpuChannelHostFactory::instance()->GetGpuChannel()); |
211 task_runner->PostTask( | 213 task_runner->PostTask( |
212 FROM_HERE, base::Bind(&VideoCaptureGpuJpegDecoder::FinishInitialization, | 214 FROM_HERE, base::Bind(&VideoCaptureGpuJpegDecoder::FinishInitialization, |
213 weak_this, base::Passed(&gpu_channel_host))); | 215 weak_this, std::move(gpu_channel_host))); |
214 } | 216 } |
215 | 217 |
216 void VideoCaptureGpuJpegDecoder::FinishInitialization( | 218 void VideoCaptureGpuJpegDecoder::FinishInitialization( |
217 scoped_refptr<GpuChannelHost> gpu_channel_host) { | 219 scoped_refptr<GpuChannelHost> gpu_channel_host) { |
218 DCHECK(CalledOnValidThread()); | 220 DCHECK(CalledOnValidThread()); |
219 base::AutoLock lock(lock_); | 221 base::AutoLock lock(lock_); |
220 if (!gpu_channel_host) { | 222 if (!gpu_channel_host) { |
221 LOG(ERROR) << "Failed to establish GPU channel for JPEG decoder"; | 223 LOG(ERROR) << "Failed to establish GPU channel for JPEG decoder"; |
222 } else if (gpu_channel_host->gpu_info().jpeg_decode_accelerator_supported) { | 224 } else if (gpu_channel_host->gpu_info().jpeg_decode_accelerator_supported) { |
223 gpu_channel_host_ = gpu_channel_host.Pass(); | 225 gpu_channel_host_ = std::move(gpu_channel_host); |
224 decoder_ = gpu_channel_host_->CreateJpegDecoder(this); | 226 decoder_ = gpu_channel_host_->CreateJpegDecoder(this); |
225 } | 227 } |
226 decoder_status_ = decoder_ ? INIT_PASSED : FAILED; | 228 decoder_status_ = decoder_ ? INIT_PASSED : FAILED; |
227 RecordInitDecodeUMA_Locked(); | 229 RecordInitDecodeUMA_Locked(); |
228 } | 230 } |
229 | 231 |
230 bool VideoCaptureGpuJpegDecoder::IsDecoding_Locked() const { | 232 bool VideoCaptureGpuJpegDecoder::IsDecoding_Locked() const { |
231 lock_.AssertAcquired(); | 233 lock_.AssertAcquired(); |
232 return !decode_done_closure_.is_null(); | 234 return !decode_done_closure_.is_null(); |
233 } | 235 } |
234 | 236 |
235 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { | 237 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { |
236 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", | 238 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", |
237 decoder_status_ == INIT_PASSED); | 239 decoder_status_ == INIT_PASSED); |
238 } | 240 } |
239 | 241 |
240 } // namespace content | 242 } // namespace content |
OLD | NEW |