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

Side by Side Diff: media/capture/content/screen_capture_device_core.cc

Issue 2692393002: Tab/Desktop capture: Fix for super-old frame after resume. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « media/capture/content/screen_capture_device_core.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/capture/content/screen_capture_device_core.h" 5 #include "media/capture/content/screen_capture_device_core.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 capture_machine_->Start( 62 capture_machine_->Start(
63 oracle_proxy_, params, 63 oracle_proxy_, params,
64 base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr())); 64 base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr()));
65 65
66 TransitionStateTo(kCapturing); 66 TransitionStateTo(kCapturing);
67 } 67 }
68 68
69 void ScreenCaptureDeviceCore::RequestRefreshFrame() { 69 void ScreenCaptureDeviceCore::RequestRefreshFrame() {
70 DCHECK(thread_checker_.CalledOnValidThread()); 70 DCHECK(thread_checker_.CalledOnValidThread());
71 71
72 if (state_ != kCapturing && state_ != kSuspended) 72 if (state_ != kCapturing)
73 return; 73 return;
74 74
75 // Try to use the less resource-intensive "passive" refresh mechanism, unless
76 // this is the first refresh following a Resume().
77 if (force_active_refresh_once_) {
78 capture_machine_->MaybeCaptureForRefresh();
79 force_active_refresh_once_ = false;
80 return;
81 }
82
83 // Make a best-effort attempt at a passive refresh, but fall-back to an active
84 // refresh if that fails.
75 if (oracle_proxy_->AttemptPassiveRefresh()) 85 if (oracle_proxy_->AttemptPassiveRefresh())
76 return; 86 return;
77 capture_machine_->MaybeCaptureForRefresh(); 87 capture_machine_->MaybeCaptureForRefresh();
78 } 88 }
79 89
80 void ScreenCaptureDeviceCore::Suspend() { 90 void ScreenCaptureDeviceCore::Suspend() {
81 DCHECK(thread_checker_.CalledOnValidThread()); 91 DCHECK(thread_checker_.CalledOnValidThread());
82 92
83 if (state_ != kCapturing) 93 if (state_ != kCapturing)
84 return; 94 return;
85 95
86 TransitionStateTo(kSuspended); 96 TransitionStateTo(kSuspended);
87 97
88 capture_machine_->Suspend(); 98 capture_machine_->Suspend();
89 } 99 }
90 100
91 void ScreenCaptureDeviceCore::Resume() { 101 void ScreenCaptureDeviceCore::Resume() {
92 DCHECK(thread_checker_.CalledOnValidThread()); 102 DCHECK(thread_checker_.CalledOnValidThread());
93 103
94 if (state_ != kSuspended) 104 if (state_ != kSuspended)
95 return; 105 return;
96 106
107 force_active_refresh_once_ = true;
97 TransitionStateTo(kCapturing); 108 TransitionStateTo(kCapturing);
98 109
99 capture_machine_->Resume(); 110 capture_machine_->Resume();
100 } 111 }
101 112
102 void ScreenCaptureDeviceCore::StopAndDeAllocate() { 113 void ScreenCaptureDeviceCore::StopAndDeAllocate() {
103 DCHECK(thread_checker_.CalledOnValidThread()); 114 DCHECK(thread_checker_.CalledOnValidThread());
104 115
105 if (state_ != kCapturing && state_ != kSuspended) 116 if (state_ != kCapturing && state_ != kSuspended)
106 return; 117 return;
(...skipping 15 matching lines...) Expand all
122 } 133 }
123 134
124 void ScreenCaptureDeviceCore::CaptureStarted(bool success) { 135 void ScreenCaptureDeviceCore::CaptureStarted(bool success) {
125 DCHECK(thread_checker_.CalledOnValidThread()); 136 DCHECK(thread_checker_.CalledOnValidThread());
126 if (!success) 137 if (!success)
127 Error(FROM_HERE, "Failed to start capture machine."); 138 Error(FROM_HERE, "Failed to start capture machine.");
128 } 139 }
129 140
130 ScreenCaptureDeviceCore::ScreenCaptureDeviceCore( 141 ScreenCaptureDeviceCore::ScreenCaptureDeviceCore(
131 std::unique_ptr<VideoCaptureMachine> capture_machine) 142 std::unique_ptr<VideoCaptureMachine> capture_machine)
132 : state_(kIdle), capture_machine_(std::move(capture_machine)) { 143 : state_(kIdle),
144 capture_machine_(std::move(capture_machine)),
145 force_active_refresh_once_(false) {
133 DCHECK(capture_machine_.get()); 146 DCHECK(capture_machine_.get());
134 } 147 }
135 148
136 ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() { 149 ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() {
137 DCHECK(thread_checker_.CalledOnValidThread()); 150 DCHECK(thread_checker_.CalledOnValidThread());
138 DCHECK(state_ != kCapturing && state_ != kSuspended); 151 DCHECK(state_ != kCapturing && state_ != kSuspended);
139 if (capture_machine_) { 152 if (capture_machine_) {
140 capture_machine_->Stop( 153 capture_machine_->Stop(
141 base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_))); 154 base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_)));
142 } 155 }
(...skipping 23 matching lines...) Expand all
166 return; 179 return;
167 180
168 if (oracle_proxy_.get()) 181 if (oracle_proxy_.get())
169 oracle_proxy_->ReportError(from_here, reason); 182 oracle_proxy_->ReportError(from_here, reason);
170 183
171 StopAndDeAllocate(); 184 StopAndDeAllocate();
172 TransitionStateTo(kError); 185 TransitionStateTo(kError);
173 } 186 }
174 187
175 } // namespace media 188 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/content/screen_capture_device_core.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698