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

Side by Side Diff: remoting/host/video_frame_recorder.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "remoting/host/video_frame_recorder.h" 5 #include "remoting/host/video_frame_recorder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 base::WeakPtrFactory<RecordingVideoEncoder> weak_factory_; 53 base::WeakPtrFactory<RecordingVideoEncoder> weak_factory_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(RecordingVideoEncoder); 55 DISALLOW_COPY_AND_ASSIGN(RecordingVideoEncoder);
56 }; 56 };
57 57
58 VideoFrameRecorder::RecordingVideoEncoder::RecordingVideoEncoder( 58 VideoFrameRecorder::RecordingVideoEncoder::RecordingVideoEncoder(
59 scoped_ptr<VideoEncoder> encoder, 59 scoped_ptr<VideoEncoder> encoder,
60 scoped_refptr<base::TaskRunner> recorder_task_runner, 60 scoped_refptr<base::TaskRunner> recorder_task_runner,
61 base::WeakPtr<VideoFrameRecorder> recorder) 61 base::WeakPtr<VideoFrameRecorder> recorder)
62 : encoder_(encoder.Pass()), 62 : encoder_(std::move(encoder)),
63 recorder_task_runner_(recorder_task_runner), 63 recorder_task_runner_(recorder_task_runner),
64 recorder_(recorder), 64 recorder_(recorder),
65 enable_recording_(false), 65 enable_recording_(false),
66 weak_factory_(this) { 66 weak_factory_(this) {
67 DCHECK(encoder_); 67 DCHECK(encoder_);
68 DCHECK(recorder_task_runner_.get()); 68 DCHECK(recorder_task_runner_.get());
69 } 69 }
70 70
71 base::WeakPtr<VideoFrameRecorder::RecordingVideoEncoder> 71 base::WeakPtr<VideoFrameRecorder::RecordingVideoEncoder>
72 VideoFrameRecorder::RecordingVideoEncoder::AsWeakPtr() { 72 VideoFrameRecorder::RecordingVideoEncoder::AsWeakPtr() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 DetachVideoEncoderWrapper(); 126 DetachVideoEncoderWrapper();
127 } 127 }
128 128
129 scoped_ptr<VideoEncoder> VideoFrameRecorder::WrapVideoEncoder( 129 scoped_ptr<VideoEncoder> VideoFrameRecorder::WrapVideoEncoder(
130 scoped_ptr<VideoEncoder> encoder) { 130 scoped_ptr<VideoEncoder> encoder) {
131 DCHECK(!encoder_task_runner_.get()); 131 DCHECK(!encoder_task_runner_.get());
132 DCHECK(!caller_task_runner_.get()); 132 DCHECK(!caller_task_runner_.get());
133 caller_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 133 caller_task_runner_ = base::ThreadTaskRunnerHandle::Get();
134 134
135 scoped_ptr<RecordingVideoEncoder> recording_encoder( 135 scoped_ptr<RecordingVideoEncoder> recording_encoder(
136 new RecordingVideoEncoder(encoder.Pass(), 136 new RecordingVideoEncoder(std::move(encoder),
137 caller_task_runner_, 137 caller_task_runner_,
138 weak_factory_.GetWeakPtr())); 138 weak_factory_.GetWeakPtr()));
139 recording_encoder_ = recording_encoder->AsWeakPtr(); 139 recording_encoder_ = recording_encoder->AsWeakPtr();
140 140
141 return recording_encoder.Pass(); 141 return std::move(recording_encoder);
142 } 142 }
143 143
144 void VideoFrameRecorder::DetachVideoEncoderWrapper() { 144 void VideoFrameRecorder::DetachVideoEncoderWrapper() {
145 DCHECK(!caller_task_runner_.get() || 145 DCHECK(!caller_task_runner_.get() ||
146 caller_task_runner_->BelongsToCurrentThread()); 146 caller_task_runner_->BelongsToCurrentThread());
147 147
148 // Immediately detach the wrapper from this recorder. 148 // Immediately detach the wrapper from this recorder.
149 weak_factory_.InvalidateWeakPtrs(); 149 weak_factory_.InvalidateWeakPtrs();
150 150
151 // Clean up any pending recorded frames. 151 // Clean up any pending recorded frames.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 193 DCHECK(caller_task_runner_->BelongsToCurrentThread());
194 194
195 scoped_ptr<webrtc::DesktopFrame> frame; 195 scoped_ptr<webrtc::DesktopFrame> frame;
196 if (!recorded_frames_.empty()) { 196 if (!recorded_frames_.empty()) {
197 frame.reset(recorded_frames_.front()); 197 frame.reset(recorded_frames_.front());
198 recorded_frames_.pop_front(); 198 recorded_frames_.pop_front();
199 content_bytes_ -= FrameContentSize(frame.get()); 199 content_bytes_ -= FrameContentSize(frame.get());
200 DCHECK_GE(content_bytes_, 0); 200 DCHECK_GE(content_bytes_, 0);
201 } 201 }
202 202
203 return frame.Pass(); 203 return frame;
204 } 204 }
205 205
206 void VideoFrameRecorder::SetEncoderTaskRunner( 206 void VideoFrameRecorder::SetEncoderTaskRunner(
207 scoped_refptr<base::TaskRunner> task_runner) { 207 scoped_refptr<base::TaskRunner> task_runner) {
208 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 208 DCHECK(caller_task_runner_->BelongsToCurrentThread());
209 DCHECK(!encoder_task_runner_.get()); 209 DCHECK(!encoder_task_runner_.get());
210 DCHECK(task_runner.get()); 210 DCHECK(task_runner.get());
211 211
212 encoder_task_runner_ = task_runner; 212 encoder_task_runner_ = task_runner;
213 213
(...skipping 25 matching lines...) Expand all
239 if (content_bytes_ + frame_bytes > max_content_bytes_) { 239 if (content_bytes_ + frame_bytes > max_content_bytes_) {
240 return; 240 return;
241 } 241 }
242 242
243 // Store the frame and update the content byte count. 243 // Store the frame and update the content byte count.
244 recorded_frames_.push_back(frame.release()); 244 recorded_frames_.push_back(frame.release());
245 content_bytes_ += frame_bytes; 245 content_bytes_ += frame_bytes;
246 } 246 }
247 247
248 } // namespace remoting 248 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698