OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/device_monitor_mac.h" | 5 #include "content/browser/device_monitor_mac.h" |
6 | 6 |
7 #import <QTKit/QTKit.h> | 7 #import <QTKit/QTKit.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 base::Closure on_device_changed_callback = | 291 base::Closure on_device_changed_callback = |
292 base::Bind(&SuspendObserverDelegate::OnDeviceChanged, | 292 base::Bind(&SuspendObserverDelegate::OnDeviceChanged, |
293 this, device_thread); | 293 this, device_thread); |
294 suspend_observer_.reset([[CrAVFoundationDeviceObserver alloc] | 294 suspend_observer_.reset([[CrAVFoundationDeviceObserver alloc] |
295 initWithOnChangedCallback:on_device_changed_callback]); | 295 initWithOnChangedCallback:on_device_changed_callback]); |
296 | 296 |
297 // Enumerate the devices in Device thread and post the observers start to be | 297 // Enumerate the devices in Device thread and post the observers start to be |
298 // done on UI thread. The devices array is retained in |device_thread| and | 298 // done on UI thread. The devices array is retained in |device_thread| and |
299 // released in DoStartObserver(). | 299 // released in DoStartObserver(). |
300 base::PostTaskAndReplyWithResult(device_thread, FROM_HERE, | 300 base::PostTaskAndReplyWithResult( |
| 301 device_thread.get(), |
| 302 FROM_HERE, |
301 base::BindBlock(^{ return [[AVCaptureDeviceGlue devices] retain]; }), | 303 base::BindBlock(^{ return [[AVCaptureDeviceGlue devices] retain]; }), |
302 base::Bind(&SuspendObserverDelegate::DoStartObserver, this)); | 304 base::Bind(&SuspendObserverDelegate::DoStartObserver, this)); |
303 } | 305 } |
304 | 306 |
305 void SuspendObserverDelegate::OnDeviceChanged( | 307 void SuspendObserverDelegate::OnDeviceChanged( |
306 const scoped_refptr<base::SingleThreadTaskRunner>& device_thread) { | 308 const scoped_refptr<base::SingleThreadTaskRunner>& device_thread) { |
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
308 // Enumerate the devices in Device thread and post the consolidation of the | 310 // Enumerate the devices in Device thread and post the consolidation of the |
309 // new devices and the old ones to be done on UI thread. The devices array | 311 // new devices and the old ones to be done on UI thread. The devices array |
310 // is retained in |device_thread| and released in DoOnDeviceChanged(). | 312 // is retained in |device_thread| and released in DoOnDeviceChanged(). |
311 PostTaskAndReplyWithResult(device_thread, FROM_HERE, | 313 PostTaskAndReplyWithResult( |
| 314 device_thread.get(), |
| 315 FROM_HERE, |
312 base::BindBlock(^{ return [[AVCaptureDeviceGlue devices] retain]; }), | 316 base::BindBlock(^{ return [[AVCaptureDeviceGlue devices] retain]; }), |
313 base::Bind(&SuspendObserverDelegate::DoOnDeviceChanged, this)); | 317 base::Bind(&SuspendObserverDelegate::DoOnDeviceChanged, this)); |
314 } | 318 } |
315 | 319 |
316 void SuspendObserverDelegate::ResetDeviceMonitor() { | 320 void SuspendObserverDelegate::ResetDeviceMonitor() { |
317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
318 avfoundation_monitor_impl_ = NULL; | 322 avfoundation_monitor_impl_ = NULL; |
319 [suspend_observer_ clearOnDeviceChangedCallback]; | 323 [suspend_observer_ clearOnDeviceChangedCallback]; |
320 } | 324 } |
321 | 325 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 } | 536 } |
533 | 537 |
534 void DeviceMonitorMac::NotifyDeviceChanged( | 538 void DeviceMonitorMac::NotifyDeviceChanged( |
535 base::SystemMonitor::DeviceType type) { | 539 base::SystemMonitor::DeviceType type) { |
536 DCHECK(thread_checker_.CalledOnValidThread()); | 540 DCHECK(thread_checker_.CalledOnValidThread()); |
537 // TODO(xians): Remove the global variable for SystemMonitor. | 541 // TODO(xians): Remove the global variable for SystemMonitor. |
538 base::SystemMonitor::Get()->ProcessDevicesChanged(type); | 542 base::SystemMonitor::Get()->ProcessDevicesChanged(type); |
539 } | 543 } |
540 | 544 |
541 } // namespace content | 545 } // namespace content |
OLD | NEW |