| 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 // Implementation notes about interactions with VideoCaptureImpl. | 5 // Implementation notes about interactions with VideoCaptureImpl. |
| 6 // | 6 // |
| 7 // How is VideoCaptureImpl used: | 7 // How is VideoCaptureImpl used: |
| 8 // | 8 // |
| 9 // VideoCaptureImpl is an IO thread object while VideoCaptureImplManager | 9 // VideoCaptureImpl is an IO thread object while VideoCaptureImplManager |
| 10 // lives only on the render thread. It is only possible to access an | 10 // lives only on the render thread. It is only possible to access an |
| 11 // object of VideoCaptureImpl via a task on the IO thread. | 11 // object of VideoCaptureImpl via a task on the IO thread. |
| 12 // | 12 // |
| 13 // How is VideoCaptureImpl deleted: | 13 // How is VideoCaptureImpl deleted: |
| 14 // | 14 // |
| 15 // A task is posted to the IO thread to delete a VideoCaptureImpl. | 15 // A task is posted to the IO thread to delete a VideoCaptureImpl. |
| 16 // Immediately after that the pointer to it is dropped. This means no | 16 // Immediately after that the pointer to it is dropped. This means no |
| 17 // access to this VideoCaptureImpl object is possible on the render | 17 // access to this VideoCaptureImpl object is possible on the render |
| 18 // thread. Also note that VideoCaptureImpl does not post task to itself. | 18 // thread. Also note that VideoCaptureImpl does not post task to itself. |
| 19 // | 19 // |
| 20 // The use of Unretained: | 20 // The use of Unretained: |
| 21 // | 21 // |
| 22 // We make sure deletion is the last task on the IO thread for a | 22 // We make sure deletion is the last task on the IO thread for a |
| 23 // VideoCaptureImpl object. This allows the use of Unretained() binding. | 23 // VideoCaptureImpl object. This allows the use of Unretained() binding. |
| 24 | 24 |
| 25 #include "content/renderer/media/video_capture_impl_manager.h" | 25 #include "content/renderer/media/video_capture_impl_manager.h" |
| 26 | 26 |
| 27 #include "base/bind.h" | 27 #include "base/bind.h" |
| 28 #include "base/bind_helpers.h" | 28 #include "base/bind_helpers.h" |
| 29 #include "base/location.h" | 29 #include "base/location.h" |
| 30 #include "base/thread_task_runner_handle.h" | 30 #include "base/threading/thread_task_runner_handle.h" |
| 31 #include "content/child/child_process.h" | 31 #include "content/child/child_process.h" |
| 32 #include "content/renderer/media/video_capture_impl.h" | 32 #include "content/renderer/media/video_capture_impl.h" |
| 33 #include "content/renderer/media/video_capture_message_filter.h" | 33 #include "content/renderer/media/video_capture_message_filter.h" |
| 34 #include "media/base/bind_to_current_loop.h" | 34 #include "media/base/bind_to_current_loop.h" |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| 37 | 37 |
| 38 VideoCaptureImplManager::VideoCaptureImplManager() | 38 VideoCaptureImplManager::VideoCaptureImplManager() |
| 39 : next_client_id_(0), | 39 : next_client_id_(0), |
| 40 filter_(new VideoCaptureMessageFilter()), | 40 filter_(new VideoCaptureMessageFilter()), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 DCHECK(render_main_task_runner_->BelongsToCurrentThread()); | 174 DCHECK(render_main_task_runner_->BelongsToCurrentThread()); |
| 175 for (const auto& device : devices_) { | 175 for (const auto& device : devices_) { |
| 176 VideoCaptureImpl* const impl = device.second.second; | 176 VideoCaptureImpl* const impl = device.second.second; |
| 177 ChildProcess::current()->io_task_runner()->PostTask( | 177 ChildProcess::current()->io_task_runner()->PostTask( |
| 178 FROM_HERE, base::Bind(&VideoCaptureImpl::SuspendCapture, | 178 FROM_HERE, base::Bind(&VideoCaptureImpl::SuspendCapture, |
| 179 base::Unretained(impl), suspend)); | 179 base::Unretained(impl), suspend)); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace content | 183 } // namespace content |
| OLD | NEW |