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

Side by Side Diff: base/memory/shared_memory_nacl.cc

Issue 27265002: Implement SharedMemory::NewAnonymousReadOnly(contents). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mark's comments Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/memory/shared_memory_android.cc ('k') | base/memory/shared_memory_posix.cc » ('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 "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void SharedMemory::Lock() { 133 void SharedMemory::Lock() {
134 NOTIMPLEMENTED(); 134 NOTIMPLEMENTED();
135 } 135 }
136 136
137 void SharedMemory::Unlock() { 137 void SharedMemory::Unlock() {
138 NOTIMPLEMENTED(); 138 NOTIMPLEMENTED();
139 } 139 }
140 140
141 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, 141 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
142 SharedMemoryHandle *new_handle, 142 SharedMemoryHandle *new_handle,
143 bool close_self) { 143 bool close_self,
144 ShareMode share_mode) {
145 if (share_mode == SHARE_READONLY) {
146 // Untrusted code can't create descriptors or handles, which is needed to
147 // drop permissions.
148 return false;
149 }
144 const int new_fd = dup(mapped_file_); 150 const int new_fd = dup(mapped_file_);
145 if (new_fd < 0) { 151 if (new_fd < 0) {
146 DPLOG(ERROR) << "dup() failed."; 152 DPLOG(ERROR) << "dup() failed.";
147 return false; 153 return false;
148 } 154 }
149 155
150 new_handle->fd = new_fd; 156 new_handle->fd = new_fd;
151 new_handle->auto_close = true; 157 new_handle->auto_close = true;
152 158
153 if (close_self) 159 if (close_self)
154 Close(); 160 Close();
155 return true; 161 return true;
156 } 162 }
157 163
158 } // namespace base 164 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_android.cc ('k') | base/memory/shared_memory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698