Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: remoting/host/desktop_session_agent.cc

Issue 1509063003: Remoting: Remove references to POSIX shared memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp57_base
Patch Set: Rebase. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/chromoting_messages.h ('k') | remoting/host/desktop_session_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } // namespace 71 } // namespace
72 72
73 // webrtc::SharedMemory implementation that notifies creating 73 // webrtc::SharedMemory implementation that notifies creating
74 // DesktopSessionAgent when it's deleted. 74 // DesktopSessionAgent when it's deleted.
75 class DesktopSessionAgent::SharedBuffer : public webrtc::SharedMemory { 75 class DesktopSessionAgent::SharedBuffer : public webrtc::SharedMemory {
76 public: 76 public:
77 static scoped_ptr<SharedBuffer> Create(DesktopSessionAgent* agent, 77 static scoped_ptr<SharedBuffer> Create(DesktopSessionAgent* agent,
78 size_t size, 78 size_t size,
79 int id) { 79 int id) {
80 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory()); 80 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory());
81 #if defined(OS_MACOSX) && !defined(OS_IOS)
82 // Remoting does not yet support Mach primitive backed SharedMemory, so
83 // force the underlying primitive to be a POSIX fd.
84 // https://crbug.com/547247.
85 if (!memory->CreateAndMapAnonymousPosix(size))
86 return nullptr;
87 #else
88 if (!memory->CreateAndMapAnonymous(size)) 81 if (!memory->CreateAndMapAnonymous(size))
89 return nullptr; 82 return nullptr;
90 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
91 return make_scoped_ptr( 83 return make_scoped_ptr(
92 new SharedBuffer(agent, std::move(memory), size, id)); 84 new SharedBuffer(agent, std::move(memory), size, id));
93 } 85 }
94 86
95 ~SharedBuffer() override { agent_->OnSharedBufferDeleted(id()); } 87 ~SharedBuffer() override { agent_->OnSharedBufferDeleted(id()); }
96 88
97 base::SharedMemory* shared_memory() { return shared_memory_.get(); } 89 base::SharedMemory* shared_memory() { return shared_memory_.get(); }
98 90
99 private: 91 private:
100 SharedBuffer(DesktopSessionAgent* agent, 92 SharedBuffer(DesktopSessionAgent* agent,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // |next_shared_buffer_id_| starts from 1 and incrementing it by 2 makes 189 // |next_shared_buffer_id_| starts from 1 and incrementing it by 2 makes
198 // sure it is always odd and therefore zero is never used as a valid buffer 190 // sure it is always odd and therefore zero is never used as a valid buffer
199 // ID. 191 // ID.
200 // 192 //
201 // It is very unlikely (though theoretically possible) to allocate the same 193 // It is very unlikely (though theoretically possible) to allocate the same
202 // ID for two different buffers due to integer overflow. It should take 194 // ID for two different buffers due to integer overflow. It should take
203 // about a year of allocating 100 new buffers every second. Practically 195 // about a year of allocating 100 new buffers every second. Practically
204 // speaking it never happens. 196 // speaking it never happens.
205 next_shared_buffer_id_ += 2; 197 next_shared_buffer_id_ += 2;
206 198
207 IPC::PlatformFileForTransit handle;
208 #if defined(OS_WIN)
209 handle = buffer->shared_memory()->handle().GetHandle(),
210 #else
211 handle =
212 base::FileDescriptor(base::SharedMemory::GetFdFromSharedMemoryHandle(
213 buffer->shared_memory()->handle()), false);
214 #endif
215 SendToNetwork(new ChromotingDesktopNetworkMsg_CreateSharedBuffer( 199 SendToNetwork(new ChromotingDesktopNetworkMsg_CreateSharedBuffer(
216 buffer->id(), handle, buffer->size())); 200 buffer->id(), buffer->shared_memory()->handle(), buffer->size()));
217 } 201 }
218 202
219 return buffer.release(); 203 return buffer.release();
220 } 204 }
221 205
222 DesktopSessionAgent::~DesktopSessionAgent() { 206 DesktopSessionAgent::~DesktopSessionAgent() {
223 DCHECK(!audio_capturer_); 207 DCHECK(!audio_capturer_);
224 DCHECK(!desktop_environment_); 208 DCHECK(!desktop_environment_);
225 DCHECK(!network_channel_); 209 DCHECK(!network_channel_);
226 DCHECK(!screen_controls_); 210 DCHECK(!screen_controls_);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 void DesktopSessionAgent::OnSharedBufferDeleted(int id) { 589 void DesktopSessionAgent::OnSharedBufferDeleted(int id) {
606 DCHECK(video_capture_task_runner_->BelongsToCurrentThread()); 590 DCHECK(video_capture_task_runner_->BelongsToCurrentThread());
607 DCHECK(id != 0); 591 DCHECK(id != 0);
608 592
609 shared_buffers_--; 593 shared_buffers_--;
610 DCHECK_GE(shared_buffers_, 0); 594 DCHECK_GE(shared_buffers_, 0);
611 SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id)); 595 SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id));
612 } 596 }
613 597
614 } // namespace remoting 598 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_messages.h ('k') | remoting/host/desktop_session_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698