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

Side by Side Diff: base/memory/shared_memory.h

Issue 203123009: Disallow calling Map on currently-mapped SharedMemory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/memory/shared_memory_nacl.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 #ifndef BASE_MEMORY_SHARED_MEMORY_H_ 5 #ifndef BASE_MEMORY_SHARED_MEMORY_H_
6 #define BASE_MEMORY_SHARED_MEMORY_H_ 6 #define BASE_MEMORY_SHARED_MEMORY_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool Delete(const std::string& name); 147 bool Delete(const std::string& name);
148 148
149 // Opens a shared memory segment based on a name. 149 // Opens a shared memory segment based on a name.
150 // If read_only is true, opens for read-only access. 150 // If read_only is true, opens for read-only access.
151 // Returns true on success, false on failure. 151 // Returns true on success, false on failure.
152 bool Open(const std::string& name, bool read_only); 152 bool Open(const std::string& name, bool read_only);
153 153
154 // Maps the shared memory into the caller's address space. 154 // Maps the shared memory into the caller's address space.
155 // Returns true on success, false otherwise. The memory address 155 // Returns true on success, false otherwise. The memory address
156 // is accessed via the memory() accessor. The mapped address is guaranteed to 156 // is accessed via the memory() accessor. The mapped address is guaranteed to
157 // have an alignment of at least MAP_MINIMUM_ALIGNMENT. 157 // have an alignment of at least MAP_MINIMUM_ALIGNMENT. This method will fail
158 // if this object is currently mapped.
158 bool Map(size_t bytes) { 159 bool Map(size_t bytes) {
159 return MapAt(0, bytes); 160 return MapAt(0, bytes);
160 } 161 }
161 162
162 // Same as above, but with |offset| to specify from begining of the shared 163 // Same as above, but with |offset| to specify from begining of the shared
163 // memory block to map. 164 // memory block to map.
164 // |offset| must be alignent to value of |SysInfo::VMAllocationGranularity()|. 165 // |offset| must be alignent to value of |SysInfo::VMAllocationGranularity()|.
165 bool MapAt(off_t offset, size_t bytes); 166 bool MapAt(off_t offset, size_t bytes);
166 enum { MAP_MINIMUM_ALIGNMENT = 32 }; 167 enum { MAP_MINIMUM_ALIGNMENT = 32 };
167 168
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 308 }
308 309
309 private: 310 private:
310 SharedMemory* shared_memory_; 311 SharedMemory* shared_memory_;
311 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); 312 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated);
312 }; 313 };
313 314
314 } // namespace base 315 } // namespace base
315 316
316 #endif // BASE_MEMORY_SHARED_MEMORY_H_ 317 #endif // BASE_MEMORY_SHARED_MEMORY_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/shared_memory_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698