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

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

Issue 27265002: Implement SharedMemory::NewAnonymousReadOnly(contents). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try to fix Android and Windows Created 7 years, 2 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
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/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 9
10 namespace { 10 namespace {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (memory_ == NULL) 181 if (memory_ == NULL)
182 return false; 182 return false;
183 183
184 UnmapViewOfFile(memory_); 184 UnmapViewOfFile(memory_);
185 memory_ = NULL; 185 memory_ = NULL;
186 return true; 186 return true;
187 } 187 }
188 188
189 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, 189 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
190 SharedMemoryHandle *new_handle, 190 SharedMemoryHandle *new_handle,
191 bool close_self) { 191 bool close_self,
192 ShareMode share_mode) {
192 *new_handle = 0; 193 *new_handle = 0;
193 DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ; 194 DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ;
194 DWORD options = 0; 195 DWORD options = 0;
195 HANDLE mapped_file = mapped_file_; 196 HANDLE mapped_file = mapped_file_;
196 HANDLE result; 197 HANDLE result;
197 if (!read_only_) 198 if (share_mode == SHARE_CURRENT_MODE && !read_only_)
198 access |= FILE_MAP_WRITE; 199 access |= FILE_MAP_WRITE;
199 if (close_self) { 200 if (close_self) {
200 // DUPLICATE_CLOSE_SOURCE causes DuplicateHandle to close mapped_file. 201 // DUPLICATE_CLOSE_SOURCE causes DuplicateHandle to close mapped_file.
201 options = DUPLICATE_CLOSE_SOURCE; 202 options = DUPLICATE_CLOSE_SOURCE;
202 mapped_file_ = NULL; 203 mapped_file_ = NULL;
203 Unmap(); 204 Unmap();
204 } 205 }
205 206
206 if (process == GetCurrentProcess() && close_self) { 207 if (process == GetCurrentProcess() && close_self) {
207 *new_handle = mapped_file; 208 *new_handle = mapped_file;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void SharedMemory::Unlock() { 252 void SharedMemory::Unlock() {
252 DCHECK(lock_ != NULL); 253 DCHECK(lock_ != NULL);
253 ReleaseMutex(lock_); 254 ReleaseMutex(lock_);
254 } 255 }
255 256
256 SharedMemoryHandle SharedMemory::handle() const { 257 SharedMemoryHandle SharedMemory::handle() const {
257 return mapped_file_; 258 return mapped_file_;
258 } 259 }
259 260
260 } // namespace base 261 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698