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

Unified Diff: remoting/host/video_scheduler.cc

Issue 14305004: Simplify ScreenCapturer interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/video_scheduler.h ('k') | remoting/host/video_scheduler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/video_scheduler.cc
diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc
index c927b3cbe2b5892b5db0fef4e754f4c3f007228c..e6cead840b6641272b2e6d9a932c53d3df1cb476 100644
--- a/remoting/host/video_scheduler.cc
+++ b/remoting/host/video_scheduler.cc
@@ -61,6 +61,10 @@ void VideoScheduler::OnCaptureCompleted(
scoped_refptr<media::ScreenCaptureData> capture_data) {
DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ // Do nothing if the scheduler is being stopped.
+ if (!capturer_)
+ return;
+
if (capture_data) {
scheduler_.RecordCaptureTime(
base::TimeDelta::FromMilliseconds(capture_data->capture_time_ms()));
@@ -81,6 +85,10 @@ void VideoScheduler::OnCursorShapeChanged(
scoped_ptr<media::MouseCursorShape> cursor_shape) {
DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ // Do nothing if the scheduler is being stopped.
+ if (!capturer_)
+ return;
+
scoped_ptr<protocol::CursorShapeInfo> cursor_proto(
new protocol::CursorShapeInfo());
cursor_proto->set_width(cursor_shape->size.width());
@@ -177,9 +185,6 @@ void VideoScheduler::StartOnCaptureThread() {
void VideoScheduler::StopOnCaptureThread() {
DCHECK(capture_task_runner_->BelongsToCurrentThread());
- // Stop |capturer_| and clear it to prevent pending tasks from using it.
- capturer_->Stop();
-
// |capture_timer_| must be destroyed on the thread on which it is used.
capture_timer_.reset();
@@ -278,14 +283,6 @@ void VideoScheduler::SendCursorShape(
cursor_stub_->SetCursorShape(*cursor_shape);
}
-void VideoScheduler::StopOnNetworkThread(
- scoped_ptr<media::ScreenCapturer> capturer) {
- DCHECK(network_task_runner_->BelongsToCurrentThread());
-
- // This is posted by StopOnEncodeThread meaning that both capture and encode
- // threads are stopped now and it is safe to delete |capturer|.
-}
-
// Encoder thread --------------------------------------------------------------
void VideoScheduler::EncodeFrame(
@@ -327,11 +324,9 @@ void VideoScheduler::StopOnEncodeThread(
DCHECK(encode_task_runner_->BelongsToCurrentThread());
// This is posted by StopOnCaptureThread, so we know that by the time we
- // process it there are no more encode tasks queued. Pass |capturer_| for
- // deletion on the thread that created it.
- network_task_runner_->PostTask(
- FROM_HERE, base::Bind(&VideoScheduler::StopOnNetworkThread, this,
- base::Passed(&capturer)));
+ // process it there are no more encode tasks queued. Pass |capturer| for
+ // deletion on the capture thread.
+ capture_task_runner_->DeleteSoon(FROM_HERE, capturer.release());
}
} // namespace remoting
« no previous file with comments | « remoting/host/video_scheduler.h ('k') | remoting/host/video_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698