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

Side by Side Diff: content/browser/media/capture/desktop_capture_device.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
19 #include "base/timer/timer.h" 20 #include "base/timer/timer.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 scoped_ptr<PowerSaveBlocker> power_save_blocker_; 134 scoped_ptr<PowerSaveBlocker> power_save_blocker_;
134 135
135 DISALLOW_COPY_AND_ASSIGN(Core); 136 DISALLOW_COPY_AND_ASSIGN(Core);
136 }; 137 };
137 138
138 DesktopCaptureDevice::Core::Core( 139 DesktopCaptureDevice::Core::Core(
139 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 140 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
140 scoped_ptr<webrtc::DesktopCapturer> capturer, 141 scoped_ptr<webrtc::DesktopCapturer> capturer,
141 DesktopMediaID::Type type) 142 DesktopMediaID::Type type)
142 : task_runner_(task_runner), 143 : task_runner_(task_runner),
143 desktop_capturer_(capturer.Pass()), 144 desktop_capturer_(std::move(capturer)),
144 capture_in_progress_(false), 145 capture_in_progress_(false),
145 first_capture_returned_(false), 146 first_capture_returned_(false),
146 capturer_type_(type) { 147 capturer_type_(type) {}
147 }
148 148
149 DesktopCaptureDevice::Core::~Core() { 149 DesktopCaptureDevice::Core::~Core() {
150 DCHECK(task_runner_->BelongsToCurrentThread()); 150 DCHECK(task_runner_->BelongsToCurrentThread());
151 client_.reset(); 151 client_.reset();
152 output_frame_.reset(); 152 output_frame_.reset();
153 previous_frame_size_.set(0, 0); 153 previous_frame_size_.set(0, 0);
154 desktop_capturer_.reset(); 154 desktop_capturer_.reset();
155 } 155 }
156 156
157 void DesktopCaptureDevice::Core::AllocateAndStart( 157 void DesktopCaptureDevice::Core::AllocateAndStart(
158 const media::VideoCaptureParams& params, 158 const media::VideoCaptureParams& params,
159 scoped_ptr<Client> client) { 159 scoped_ptr<Client> client) {
160 DCHECK(task_runner_->BelongsToCurrentThread()); 160 DCHECK(task_runner_->BelongsToCurrentThread());
161 DCHECK_GT(params.requested_format.frame_size.GetArea(), 0); 161 DCHECK_GT(params.requested_format.frame_size.GetArea(), 0);
162 DCHECK_GT(params.requested_format.frame_rate, 0); 162 DCHECK_GT(params.requested_format.frame_rate, 0);
163 DCHECK(desktop_capturer_); 163 DCHECK(desktop_capturer_);
164 DCHECK(client.get()); 164 DCHECK(client.get());
165 DCHECK(!client_.get()); 165 DCHECK(!client_.get());
166 166
167 client_ = client.Pass(); 167 client_ = std::move(client);
168 requested_frame_rate_ = params.requested_format.frame_rate; 168 requested_frame_rate_ = params.requested_format.frame_rate;
169 resolution_chooser_.reset(new media::CaptureResolutionChooser( 169 resolution_chooser_.reset(new media::CaptureResolutionChooser(
170 params.requested_format.frame_size, 170 params.requested_format.frame_size,
171 params.resolution_change_policy)); 171 params.resolution_change_policy));
172 172
173 power_save_blocker_.reset( 173 power_save_blocker_.reset(
174 PowerSaveBlocker::Create( 174 PowerSaveBlocker::Create(
175 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, 175 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
176 PowerSaveBlocker::kReasonOther, 176 PowerSaveBlocker::kReasonOther,
177 "DesktopCaptureDevice is running").release()); 177 "DesktopCaptureDevice is running").release());
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 break; 401 break;
402 } 402 }
403 403
404 default: { 404 default: {
405 NOTREACHED(); 405 NOTREACHED();
406 } 406 }
407 } 407 }
408 408
409 scoped_ptr<media::VideoCaptureDevice> result; 409 scoped_ptr<media::VideoCaptureDevice> result;
410 if (capturer) 410 if (capturer)
411 result.reset(new DesktopCaptureDevice(capturer.Pass(), source.type)); 411 result.reset(new DesktopCaptureDevice(std::move(capturer), source.type));
412 412
413 return result.Pass(); 413 return result;
414 } 414 }
415 415
416 DesktopCaptureDevice::~DesktopCaptureDevice() { 416 DesktopCaptureDevice::~DesktopCaptureDevice() {
417 DCHECK(!core_); 417 DCHECK(!core_);
418 } 418 }
419 419
420 void DesktopCaptureDevice::AllocateAndStart( 420 void DesktopCaptureDevice::AllocateAndStart(
421 const media::VideoCaptureParams& params, 421 const media::VideoCaptureParams& params,
422 scoped_ptr<Client> client) { 422 scoped_ptr<Client> client) {
423 thread_.task_runner()->PostTask( 423 thread_.task_runner()->PostTask(
(...skipping 27 matching lines...) Expand all
451 : thread_("desktopCaptureThread") { 451 : thread_("desktopCaptureThread") {
452 #if defined(OS_WIN) 452 #if defined(OS_WIN)
453 // On Windows the thread must be a UI thread. 453 // On Windows the thread must be a UI thread.
454 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_UI; 454 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_UI;
455 #else 455 #else
456 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; 456 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT;
457 #endif 457 #endif
458 458
459 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); 459 thread_.StartWithOptions(base::Thread::Options(thread_type, 0));
460 460
461 core_.reset(new Core(thread_.task_runner(), capturer.Pass(), type)); 461 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type));
462 } 462 }
463 463
464 } // namespace content 464 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698