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

Side by Side Diff: content/browser/renderer_host/media/desktop_capture_device_aura.cc

Issue 130253002: Attempt to fixed crash on stop mirroring by stopping render thread on a worker thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed miu's comments Created 6 years, 11 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 | « no previous file | content/browser/renderer_host/media/video_capture_device_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/renderer_host/media/desktop_capture_device_aura.h" 5 #include "content/browser/renderer_host/media/desktop_capture_device_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "cc/output/copy_output_request.h" 9 #include "cc/output/copy_output_request.h"
10 #include "cc/output/copy_output_result.h" 10 #include "cc/output/copy_output_result.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 public aura::WindowObserver, 90 public aura::WindowObserver,
91 public ui::CompositorObserver, 91 public ui::CompositorObserver,
92 public base::SupportsWeakPtr<DesktopVideoCaptureMachine> { 92 public base::SupportsWeakPtr<DesktopVideoCaptureMachine> {
93 public: 93 public:
94 DesktopVideoCaptureMachine(const DesktopMediaID& source); 94 DesktopVideoCaptureMachine(const DesktopMediaID& source);
95 virtual ~DesktopVideoCaptureMachine(); 95 virtual ~DesktopVideoCaptureMachine();
96 96
97 // VideoCaptureFrameSource overrides. 97 // VideoCaptureFrameSource overrides.
98 virtual bool Start( 98 virtual bool Start(
99 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy) OVERRIDE; 99 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy) OVERRIDE;
100 virtual void Stop() OVERRIDE; 100 virtual void Stop(const base::Closure& callback) OVERRIDE;
101 101
102 // Implements aura::WindowObserver. 102 // Implements aura::WindowObserver.
103 virtual void OnWindowBoundsChanged(aura::Window* window, 103 virtual void OnWindowBoundsChanged(aura::Window* window,
104 const gfx::Rect& old_bounds, 104 const gfx::Rect& old_bounds,
105 const gfx::Rect& new_bounds) OVERRIDE; 105 const gfx::Rect& new_bounds) OVERRIDE;
106 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; 106 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
107 107
108 // Implements ui::CompositorObserver. 108 // Implements ui::CompositorObserver.
109 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE {} 109 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE {}
110 virtual void OnCompositingStarted(ui::Compositor* compositor, 110 virtual void OnCompositingStarted(ui::Compositor* compositor,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 // Starts timer. 207 // Starts timer.
208 timer_.Start(FROM_HERE, oracle_proxy_->capture_period(), 208 timer_.Start(FROM_HERE, oracle_proxy_->capture_period(),
209 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), 209 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(),
210 false)); 210 false));
211 211
212 started_ = true; 212 started_ = true;
213 return true; 213 return true;
214 } 214 }
215 215
216 void DesktopVideoCaptureMachine::Stop() { 216 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) {
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 218
219 // Stop observing window events. 219 // Stop observing window events.
220 if (desktop_window_) { 220 if (desktop_window_) {
221 desktop_window_->RemoveObserver(this); 221 desktop_window_->RemoveObserver(this);
222 desktop_window_ = NULL; 222 desktop_window_ = NULL;
223 } 223 }
224 224
225 // Stop observing compositor updates. 225 // Stop observing compositor updates.
226 if (desktop_layer_) { 226 if (desktop_layer_) {
227 ui::Compositor* compositor = desktop_layer_->GetCompositor(); 227 ui::Compositor* compositor = desktop_layer_->GetCompositor();
228 if (compositor) 228 if (compositor)
229 compositor->RemoveObserver(this); 229 compositor->RemoveObserver(this);
230 desktop_layer_ = NULL; 230 desktop_layer_ = NULL;
231 } 231 }
232 232
233 // Stop timer. 233 // Stop timer.
234 timer_.Stop(); 234 timer_.Stop();
235 235
236 started_ = false; 236 started_ = false;
237
238 callback.Run();
237 } 239 }
238 240
239 void DesktopVideoCaptureMachine::UpdateCaptureSize() { 241 void DesktopVideoCaptureMachine::UpdateCaptureSize() {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
241 if (oracle_proxy_ && desktop_layer_) { 243 if (oracle_proxy_ && desktop_layer_) {
242 oracle_proxy_->UpdateCaptureSize(ui::ConvertSizeToPixel( 244 oracle_proxy_->UpdateCaptureSize(ui::ConvertSizeToPixel(
243 desktop_layer_, desktop_layer_->bounds().size())); 245 desktop_layer_, desktop_layer_->bounds().size()));
244 } 246 }
245 ClearCursorState(); 247 ClearCursorState();
246 } 248 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 DCHECK(desktop_window_ && window == desktop_window_); 396 DCHECK(desktop_window_ && window == desktop_window_);
395 397
396 // Post task to update capture size on UI thread. 398 // Post task to update capture size on UI thread.
397 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 399 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
398 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); 400 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr()));
399 } 401 }
400 402
401 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { 403 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) {
402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
403 405
404 Stop(); 406 Stop(base::Bind(&base::DoNothing));
405 407
406 oracle_proxy_->ReportError(); 408 oracle_proxy_->ReportError();
407 } 409 }
408 410
409 void DesktopVideoCaptureMachine::OnCompositingEnded( 411 void DesktopVideoCaptureMachine::OnCompositingEnded(
410 ui::Compositor* compositor) { 412 ui::Compositor* compositor) {
411 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 413 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
412 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); 414 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true));
413 } 415 }
414 416
(...skipping 19 matching lines...) Expand all
434 scoped_ptr<Client> client) { 436 scoped_ptr<Client> client) {
435 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); 437 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString();
436 impl_->AllocateAndStart(params, client.Pass()); 438 impl_->AllocateAndStart(params, client.Pass());
437 } 439 }
438 440
439 void DesktopCaptureDeviceAura::StopAndDeAllocate() { 441 void DesktopCaptureDeviceAura::StopAndDeAllocate() {
440 impl_->StopAndDeAllocate(); 442 impl_->StopAndDeAllocate();
441 } 443 }
442 444
443 } // namespace content 445 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_device_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698