| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/host/desktop_capturer_proxy.h" | 5 #include "remoting/host/desktop_capturer_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/location.h" | 12 #include "base/location.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 14 #include "remoting/proto/control.pb.h" | 16 #include "remoting/proto/control.pb.h" |
| 15 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 17 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 16 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 18 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 17 | 19 |
| 18 namespace remoting { | 20 namespace remoting { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 40 | 42 |
| 41 DISALLOW_COPY_AND_ASSIGN(Core); | 43 DISALLOW_COPY_AND_ASSIGN(Core); |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 DesktopCapturerProxy::Core::Core( | 46 DesktopCapturerProxy::Core::Core( |
| 45 base::WeakPtr<DesktopCapturerProxy> proxy, | 47 base::WeakPtr<DesktopCapturerProxy> proxy, |
| 46 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 48 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 47 scoped_ptr<webrtc::DesktopCapturer> capturer) | 49 scoped_ptr<webrtc::DesktopCapturer> capturer) |
| 48 : proxy_(proxy), | 50 : proxy_(proxy), |
| 49 caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 51 caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 50 capturer_(capturer.Pass()) { | 52 capturer_(std::move(capturer)) { |
| 51 thread_checker_.DetachFromThread(); | 53 thread_checker_.DetachFromThread(); |
| 52 } | 54 } |
| 53 | 55 |
| 54 DesktopCapturerProxy::Core::~Core() { | 56 DesktopCapturerProxy::Core::~Core() { |
| 55 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void DesktopCapturerProxy::Core::Start() { | 60 void DesktopCapturerProxy::Core::Start() { |
| 59 DCHECK(thread_checker_.CalledOnValidThread()); | 61 DCHECK(thread_checker_.CalledOnValidThread()); |
| 60 capturer_->Start(this); | 62 capturer_->Start(this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 80 DCHECK(thread_checker_.CalledOnValidThread()); | 82 DCHECK(thread_checker_.CalledOnValidThread()); |
| 81 | 83 |
| 82 caller_task_runner_->PostTask( | 84 caller_task_runner_->PostTask( |
| 83 FROM_HERE, base::Bind(&DesktopCapturerProxy::OnFrameCaptured, proxy_, | 85 FROM_HERE, base::Bind(&DesktopCapturerProxy::OnFrameCaptured, proxy_, |
| 84 base::Passed(make_scoped_ptr(frame)))); | 86 base::Passed(make_scoped_ptr(frame)))); |
| 85 } | 87 } |
| 86 | 88 |
| 87 DesktopCapturerProxy::DesktopCapturerProxy( | 89 DesktopCapturerProxy::DesktopCapturerProxy( |
| 88 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 90 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 89 scoped_ptr<webrtc::DesktopCapturer> capturer) | 91 scoped_ptr<webrtc::DesktopCapturer> capturer) |
| 90 : capture_task_runner_(capture_task_runner), | 92 : capture_task_runner_(capture_task_runner), weak_factory_(this) { |
| 91 weak_factory_(this) { | |
| 92 core_.reset(new Core(weak_factory_.GetWeakPtr(), capture_task_runner, | 93 core_.reset(new Core(weak_factory_.GetWeakPtr(), capture_task_runner, |
| 93 capturer.Pass())); | 94 std::move(capturer))); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void DesktopCapturerProxy::Start(Callback* callback) { | 97 void DesktopCapturerProxy::Start(Callback* callback) { |
| 97 DCHECK(thread_checker_.CalledOnValidThread()); | 98 DCHECK(thread_checker_.CalledOnValidThread()); |
| 98 | 99 |
| 99 callback_ = callback; | 100 callback_ = callback; |
| 100 | 101 |
| 101 capture_task_runner_->PostTask( | 102 capture_task_runner_->PostTask( |
| 102 FROM_HERE, base::Bind(&Core::Start, base::Unretained(core_.get()))); | 103 FROM_HERE, base::Bind(&Core::Start, base::Unretained(core_.get()))); |
| 103 } | 104 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 } | 121 } |
| 121 | 122 |
| 122 void DesktopCapturerProxy::OnFrameCaptured( | 123 void DesktopCapturerProxy::OnFrameCaptured( |
| 123 scoped_ptr<webrtc::DesktopFrame> frame) { | 124 scoped_ptr<webrtc::DesktopFrame> frame) { |
| 124 DCHECK(thread_checker_.CalledOnValidThread()); | 125 DCHECK(thread_checker_.CalledOnValidThread()); |
| 125 | 126 |
| 126 callback_->OnCaptureCompleted(frame.release()); | 127 callback_->OnCaptureCompleted(frame.release()); |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace remoting | 130 } // namespace remoting |
| OLD | NEW |