| OLD | NEW |
| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() { |
| 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; |
| 223 } |
| 222 | 224 |
| 223 // Stop observing compositor updates. | 225 // Stop observing compositor updates. |
| 224 if (desktop_layer_) { | 226 if (desktop_layer_) { |
| 225 ui::Compositor* compositor = desktop_layer_->GetCompositor(); | 227 ui::Compositor* compositor = desktop_layer_->GetCompositor(); |
| 226 if (compositor) | 228 if (compositor) |
| 227 compositor->RemoveObserver(this); | 229 compositor->RemoveObserver(this); |
| 230 desktop_layer_ = NULL; |
| 228 } | 231 } |
| 229 | 232 |
| 230 // Stop timer. | 233 // Stop timer. |
| 231 timer_.Stop(); | 234 timer_.Stop(); |
| 232 | 235 |
| 233 started_ = false; | 236 started_ = false; |
| 234 } | 237 } |
| 235 | 238 |
| 236 void DesktopVideoCaptureMachine::UpdateCaptureSize() { | 239 void DesktopVideoCaptureMachine::UpdateCaptureSize() { |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 const gfx::Rect& old_bounds, | 392 const gfx::Rect& old_bounds, |
| 390 const gfx::Rect& new_bounds) { | 393 const gfx::Rect& new_bounds) { |
| 391 DCHECK(desktop_window_ && window == desktop_window_); | 394 DCHECK(desktop_window_ && window == desktop_window_); |
| 392 | 395 |
| 393 // Post task to update capture size on UI thread. | 396 // Post task to update capture size on UI thread. |
| 394 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 397 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 395 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); | 398 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); |
| 396 } | 399 } |
| 397 | 400 |
| 398 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { | 401 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { |
| 399 DCHECK(desktop_window_ && window == desktop_window_); | 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 400 desktop_window_ = NULL; | |
| 401 desktop_layer_ = NULL; | |
| 402 | 403 |
| 403 // Post task to stop capture on UI thread. | 404 Stop(); |
| 404 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 405 |
| 405 &DesktopVideoCaptureMachine::Stop, AsWeakPtr())); | 406 oracle_proxy_->ReportError(); |
| 406 } | 407 } |
| 407 | 408 |
| 408 void DesktopVideoCaptureMachine::OnCompositingEnded( | 409 void DesktopVideoCaptureMachine::OnCompositingEnded( |
| 409 ui::Compositor* compositor) { | 410 ui::Compositor* compositor) { |
| 410 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 411 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 411 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); | 412 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); |
| 412 } | 413 } |
| 413 | 414 |
| 414 } // namespace | 415 } // namespace |
| 415 | 416 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 433 scoped_ptr<Client> client) { | 434 scoped_ptr<Client> client) { |
| 434 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 435 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 435 impl_->AllocateAndStart(params, client.Pass()); | 436 impl_->AllocateAndStart(params, client.Pass()); |
| 436 } | 437 } |
| 437 | 438 |
| 438 void DesktopCaptureDeviceAura::StopAndDeAllocate() { | 439 void DesktopCaptureDeviceAura::StopAndDeAllocate() { |
| 439 impl_->StopAndDeAllocate(); | 440 impl_->StopAndDeAllocate(); |
| 440 } | 441 } |
| 441 | 442 |
| 442 } // namespace content | 443 } // namespace content |
| OLD | NEW |