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