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

Side by Side Diff: base/shared_memory_win.cc

Issue 8585002: Give base::SharedMemory::CreateAnonymous an executable flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2011 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/shared_memory.h" 5 #include "base/shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 9
10 namespace base { 10 namespace base {
11 11
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return NULL; 64 return NULL;
65 } 65 }
66 66
67 // static 67 // static
68 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { 68 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
69 DCHECK(handle != NULL); 69 DCHECK(handle != NULL);
70 ::CloseHandle(handle); 70 ::CloseHandle(handle);
71 } 71 }
72 72
73 bool SharedMemory::CreateAndMapAnonymous(uint32 size) { 73 bool SharedMemory::CreateAndMapAnonymous(uint32 size) {
74 return CreateAnonymous(size) && Map(size); 74 return CreateAnonymous(size, flase) && Map(size);
75 } 75 }
76 76
77 bool SharedMemory::CreateAnonymous(uint32 size) { 77 bool SharedMemory::CreateAnonymous(uint32 size, bool executable) {
78 return CreateNamed("", false, size); 78 return CreateNamed("", false, size, executable);
79 } 79 }
80 80
81 bool SharedMemory::CreateNamed(const std::string& name, 81 bool SharedMemory::CreateNamed(const std::string& name, bool open_existing,
82 bool open_existing, uint32 size) { 82 uint32 size, bool executable) {
83 DCHECK(!executable);
83 DCHECK(!mapped_file_); 84 DCHECK(!mapped_file_);
84 if (size == 0) 85 if (size == 0)
85 return false; 86 return false;
86 87
87 // NaCl's memory allocator requires 0mod64K alignment and size for 88 // NaCl's memory allocator requires 0mod64K alignment and size for
88 // shared memory objects. To allow passing shared memory to NaCl, 89 // shared memory objects. To allow passing shared memory to NaCl,
89 // therefore we round the size actually created to the nearest 64K unit. 90 // therefore we round the size actually created to the nearest 64K unit.
90 // To avoid client impact, we continue to retain the size as the 91 // To avoid client impact, we continue to retain the size as the
91 // actual requested size. 92 // actual requested size.
92 uint32 rounded_size = (size + 0xffff) & ~0xffff; 93 uint32 rounded_size = (size + 0xffff) & ~0xffff;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void SharedMemory::Unlock() { 220 void SharedMemory::Unlock() {
220 DCHECK(lock_ != NULL); 221 DCHECK(lock_ != NULL);
221 ReleaseMutex(lock_); 222 ReleaseMutex(lock_);
222 } 223 }
223 224
224 SharedMemoryHandle SharedMemory::handle() const { 225 SharedMemoryHandle SharedMemory::handle() const {
225 return mapped_file_; 226 return mapped_file_;
226 } 227 }
227 228
228 } // namespace base 229 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698