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

Side by Side Diff: base/shared_memory_win.cc

Issue 10827400: Advertise a minimum alignment for SharedMemory::Map(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« base/shared_memory.h ('K') | « base/shared_memory_unittest.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return false; 129 return false;
130 } 130 }
131 131
132 bool SharedMemory::Map(uint32 bytes) { 132 bool SharedMemory::Map(uint32 bytes) {
133 if (mapped_file_ == NULL) 133 if (mapped_file_ == NULL)
134 return false; 134 return false;
135 135
136 memory_ = MapViewOfFile(mapped_file_, 136 memory_ = MapViewOfFile(mapped_file_,
137 read_only_ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS, 0, 0, bytes); 137 read_only_ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS, 0, 0, bytes);
138 if (memory_ != NULL) { 138 if (memory_ != NULL) {
139 DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
140 (SharedMemory::kMapMinimumAlignment - 1));
139 return true; 141 return true;
140 } 142 }
141 return false; 143 return false;
142 } 144 }
143 145
144 bool SharedMemory::Unmap() { 146 bool SharedMemory::Unmap() {
145 if (memory_ == NULL) 147 if (memory_ == NULL)
146 return false; 148 return false;
147 149
148 UnmapViewOfFile(memory_); 150 UnmapViewOfFile(memory_);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void SharedMemory::Unlock() { 217 void SharedMemory::Unlock() {
216 DCHECK(lock_ != NULL); 218 DCHECK(lock_ != NULL);
217 ReleaseMutex(lock_); 219 ReleaseMutex(lock_);
218 } 220 }
219 221
220 SharedMemoryHandle SharedMemory::handle() const { 222 SharedMemoryHandle SharedMemory::handle() const {
221 return mapped_file_; 223 return mapped_file_;
222 } 224 }
223 225
224 } // namespace base 226 } // namespace base
OLDNEW
« base/shared_memory.h ('K') | « base/shared_memory_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698