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 "remoting/host/desktop_session_agent.h" | 5 #include "remoting/host/desktop_session_agent.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ipc/ipc_channel_proxy.h" | 8 #include "ipc/ipc_channel_proxy.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
11 #include "remoting/base/auto_thread_task_runner.h" | 11 #include "remoting/base/auto_thread_task_runner.h" |
12 #include "remoting/base/capture_data.h" | 12 #include "remoting/base/capture_data.h" |
13 #include "remoting/host/chromoting_messages.h" | 13 #include "remoting/host/chromoting_messages.h" |
14 #include "remoting/proto/control.pb.h" | 14 #include "remoting/proto/control.pb.h" |
15 #include "third_party/skia/include/core/SkRegion.h" | 15 #include "third_party/skia/include/core/SkRegion.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
19 DesktopSessionAgent::~DesktopSessionAgent() { | 19 DesktopSessionAgent::~DesktopSessionAgent() { |
| 20 DCHECK(!network_channel_); |
20 DCHECK(!video_capturer_); | 21 DCHECK(!video_capturer_); |
21 } | 22 } |
22 | 23 |
23 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { | 24 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { |
24 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 25 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
25 | 26 |
26 bool handled = true; | 27 bool handled = true; |
27 IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message) | 28 IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message) |
28 IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame, | 29 IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame, |
29 OnCaptureFrame) | 30 OnCaptureFrame) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 135 |
135 // Start the video capturer. | 136 // Start the video capturer. |
136 video_capture_task_runner()->PostTask( | 137 video_capture_task_runner()->PostTask( |
137 FROM_HERE, base::Bind(&DesktopSessionAgent::StartVideoCapturer, this)); | 138 FROM_HERE, base::Bind(&DesktopSessionAgent::StartVideoCapturer, this)); |
138 return true; | 139 return true; |
139 } | 140 } |
140 | 141 |
141 void DesktopSessionAgent::Stop() { | 142 void DesktopSessionAgent::Stop() { |
142 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 143 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
143 | 144 |
| 145 // Make sure the channel is closed. |
| 146 network_channel_.reset(); |
| 147 |
144 // Stop the video capturer. | 148 // Stop the video capturer. |
145 video_capture_task_runner()->PostTask( | 149 video_capture_task_runner()->PostTask( |
146 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); | 150 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); |
147 } | 151 } |
148 | 152 |
149 void DesktopSessionAgent::OnCaptureFrame() { | 153 void DesktopSessionAgent::OnCaptureFrame() { |
150 if (!video_capture_task_runner()->BelongsToCurrentThread()) { | 154 if (!video_capture_task_runner()->BelongsToCurrentThread()) { |
151 video_capture_task_runner()->PostTask( | 155 video_capture_task_runner()->PostTask( |
152 FROM_HERE, | 156 FROM_HERE, |
153 base::Bind(&DesktopSessionAgent::OnCaptureFrame, this)); | 157 base::Bind(&DesktopSessionAgent::OnCaptureFrame, this)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 251 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
248 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) | 252 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) |
249 : caller_task_runner_(caller_task_runner), | 253 : caller_task_runner_(caller_task_runner), |
250 io_task_runner_(io_task_runner), | 254 io_task_runner_(io_task_runner), |
251 video_capture_task_runner_(video_capture_task_runner), | 255 video_capture_task_runner_(video_capture_task_runner), |
252 next_shared_buffer_id_(1) { | 256 next_shared_buffer_id_(1) { |
253 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 257 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
254 } | 258 } |
255 | 259 |
256 } // namespace remoting | 260 } // namespace remoting |
OLD | NEW |