OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/media/capture/desktop_capture_device.h" | 5 #include "content/browser/media/capture/desktop_capture_device.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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 | 459 |
460 void DesktopCaptureDevice::StopAndDeAllocate() { | 460 void DesktopCaptureDevice::StopAndDeAllocate() { |
461 if (core_) { | 461 if (core_) { |
462 thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, core_.release()); | 462 thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, core_.release()); |
463 thread_.Stop(); | 463 thread_.Stop(); |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 void DesktopCaptureDevice::SetNotificationWindowId( | 467 void DesktopCaptureDevice::SetNotificationWindowId( |
468 gfx::NativeViewId window_id) { | 468 gfx::NativeViewId window_id) { |
469 thread_.message_loop_proxy()->PostTask( | 469 // This may be called after the capturer has been stopped. |
470 FROM_HERE, | 470 if (thread_.message_loop_proxy()) { |
Sergey Ulanov
2015/02/03 17:49:18
I'd prefer checking that core_ is not nullptr here
jiayl
2015/02/03 17:54:09
Done.
| |
471 base::Bind(&Core::SetNotificationWindowId, base::Unretained(core_.get()), | 471 thread_.message_loop_proxy()->PostTask( |
472 window_id)); | 472 FROM_HERE, |
473 base::Bind(&Core::SetNotificationWindowId, | |
474 base::Unretained(core_.get()), | |
475 window_id)); | |
476 } | |
473 } | 477 } |
474 | 478 |
475 DesktopCaptureDevice::DesktopCaptureDevice( | 479 DesktopCaptureDevice::DesktopCaptureDevice( |
476 scoped_ptr<webrtc::DesktopCapturer> capturer, | 480 scoped_ptr<webrtc::DesktopCapturer> capturer, |
477 DesktopMediaID::Type type) | 481 DesktopMediaID::Type type) |
478 : thread_("desktopCaptureThread") { | 482 : thread_("desktopCaptureThread") { |
479 #if defined(OS_WIN) | 483 #if defined(OS_WIN) |
480 // On Windows the thread must be a UI thread. | 484 // On Windows the thread must be a UI thread. |
481 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_UI; | 485 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_UI; |
482 #else | 486 #else |
483 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 487 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; |
484 #endif | 488 #endif |
485 | 489 |
486 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 490 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); |
487 | 491 |
488 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type)); | 492 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type)); |
489 } | 493 } |
490 | 494 |
491 } // namespace content | 495 } // namespace content |
OLD | NEW |