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 <utility> |
| 8 |
7 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include "ipc/ipc_channel_proxy.h" | 14 #include "ipc/ipc_channel_proxy.h" |
13 #include "ipc/ipc_message.h" | 15 #include "ipc/ipc_message.h" |
14 #include "ipc/ipc_message_macros.h" | 16 #include "ipc/ipc_message_macros.h" |
15 #include "remoting/base/auto_thread_task_runner.h" | 17 #include "remoting/base/auto_thread_task_runner.h" |
16 #include "remoting/base/constants.h" | 18 #include "remoting/base/constants.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #if defined(OS_MACOSX) && !defined(OS_IOS) | 81 #if defined(OS_MACOSX) && !defined(OS_IOS) |
80 // Remoting does not yet support Mach primitive backed SharedMemory, so | 82 // Remoting does not yet support Mach primitive backed SharedMemory, so |
81 // force the underlying primitive to be a POSIX fd. | 83 // force the underlying primitive to be a POSIX fd. |
82 // https://crbug.com/547247. | 84 // https://crbug.com/547247. |
83 if (!memory->CreateAndMapAnonymousPosix(size)) | 85 if (!memory->CreateAndMapAnonymousPosix(size)) |
84 return nullptr; | 86 return nullptr; |
85 #else | 87 #else |
86 if (!memory->CreateAndMapAnonymous(size)) | 88 if (!memory->CreateAndMapAnonymous(size)) |
87 return nullptr; | 89 return nullptr; |
88 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 90 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
89 return make_scoped_ptr(new SharedBuffer(agent, memory.Pass(), size, id)); | 91 return make_scoped_ptr( |
| 92 new SharedBuffer(agent, std::move(memory), size, id)); |
90 } | 93 } |
91 | 94 |
92 ~SharedBuffer() override { agent_->OnSharedBufferDeleted(id()); } | 95 ~SharedBuffer() override { agent_->OnSharedBufferDeleted(id()); } |
93 | 96 |
94 base::SharedMemory* shared_memory() { return shared_memory_.get(); } | 97 base::SharedMemory* shared_memory() { return shared_memory_.get(); } |
95 | 98 |
96 private: | 99 private: |
97 SharedBuffer(DesktopSessionAgent* agent, | 100 SharedBuffer(DesktopSessionAgent* agent, |
98 scoped_ptr<base::SharedMemory> memory, | 101 scoped_ptr<base::SharedMemory> memory, |
99 size_t size, | 102 size_t size, |
100 int id) | 103 int id) |
101 : SharedMemory(memory->memory(), size, 0, id), | 104 : SharedMemory(memory->memory(), size, 0, id), |
102 agent_(agent), | 105 agent_(agent), |
103 shared_memory_(memory.Pass()) {} | 106 shared_memory_(std::move(memory)) {} |
104 | 107 |
105 DesktopSessionAgent* agent_; | 108 DesktopSessionAgent* agent_; |
106 scoped_ptr<base::SharedMemory> shared_memory_; | 109 scoped_ptr<base::SharedMemory> shared_memory_; |
107 | 110 |
108 DISALLOW_COPY_AND_ASSIGN(SharedBuffer); | 111 DISALLOW_COPY_AND_ASSIGN(SharedBuffer); |
109 }; | 112 }; |
110 | 113 |
111 DesktopSessionAgent::Delegate::~Delegate() { | 114 DesktopSessionAgent::Delegate::~Delegate() { |
112 } | 115 } |
113 | 116 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 292 |
290 #if defined(OS_WIN) | 293 #if defined(OS_WIN) |
291 // LocalInputMonitorWin filters out an echo of the injected input before it | 294 // LocalInputMonitorWin filters out an echo of the injected input before it |
292 // reaches |remote_input_filter_|. | 295 // reaches |remote_input_filter_|. |
293 remote_input_filter_->SetExpectLocalEcho(false); | 296 remote_input_filter_->SetExpectLocalEcho(false); |
294 #endif // defined(OS_WIN) | 297 #endif // defined(OS_WIN) |
295 | 298 |
296 // Start the input injector. | 299 // Start the input injector. |
297 scoped_ptr<protocol::ClipboardStub> clipboard_stub( | 300 scoped_ptr<protocol::ClipboardStub> clipboard_stub( |
298 new DesktopSesssionClipboardStub(this)); | 301 new DesktopSesssionClipboardStub(this)); |
299 input_injector_->Start(clipboard_stub.Pass()); | 302 input_injector_->Start(std::move(clipboard_stub)); |
300 | 303 |
301 // Start the audio capturer. | 304 // Start the audio capturer. |
302 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { | 305 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { |
303 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); | 306 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); |
304 audio_capture_task_runner_->PostTask( | 307 audio_capture_task_runner_->PostTask( |
305 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); | 308 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); |
306 } | 309 } |
307 | 310 |
308 // Start the video capturer and mouse cursor monitor. | 311 // Start the video capturer and mouse cursor monitor. |
309 video_capturer_ = desktop_environment_->CreateVideoCapturer(); | 312 video_capturer_ = desktop_environment_->CreateVideoCapturer(); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 void DesktopSessionAgent::OnSharedBufferDeleted(int id) { | 605 void DesktopSessionAgent::OnSharedBufferDeleted(int id) { |
603 DCHECK(video_capture_task_runner_->BelongsToCurrentThread()); | 606 DCHECK(video_capture_task_runner_->BelongsToCurrentThread()); |
604 DCHECK(id != 0); | 607 DCHECK(id != 0); |
605 | 608 |
606 shared_buffers_--; | 609 shared_buffers_--; |
607 DCHECK_GE(shared_buffers_, 0); | 610 DCHECK_GE(shared_buffers_, 0); |
608 SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id)); | 611 SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id)); |
609 } | 612 } |
610 | 613 |
611 } // namespace remoting | 614 } // namespace remoting |
OLD | NEW |