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

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: 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_unittest.cc ('k') | chrome/browser/extensions/user_script_master.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) 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (memory_ == NULL) 182 if (memory_ == NULL)
183 return false; 183 return false;
184 184
185 UnmapViewOfFile(memory_); 185 UnmapViewOfFile(memory_);
186 memory_ = NULL; 186 memory_ = NULL;
187 return true; 187 return true;
188 } 188 }
189 189
190 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, 190 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
191 SharedMemoryHandle *new_handle, 191 SharedMemoryHandle *new_handle,
192 bool close_self) { 192 bool close_self,
193 ShareMode share_mode) {
193 *new_handle = 0; 194 *new_handle = 0;
194 DWORD access = FILE_MAP_READ; 195 DWORD access = FILE_MAP_READ;
195 DWORD options = 0; 196 DWORD options = 0;
196 HANDLE mapped_file = mapped_file_; 197 HANDLE mapped_file = mapped_file_;
197 HANDLE result; 198 HANDLE result;
198 if (!read_only_) 199 if (share_mode == SHARE_CURRENT_MODE && !read_only_)
199 access |= FILE_MAP_WRITE; 200 access |= FILE_MAP_WRITE;
200 if (close_self) { 201 if (close_self) {
201 // DUPLICATE_CLOSE_SOURCE causes DuplicateHandle to close mapped_file. 202 // DUPLICATE_CLOSE_SOURCE causes DuplicateHandle to close mapped_file.
202 options = DUPLICATE_CLOSE_SOURCE; 203 options = DUPLICATE_CLOSE_SOURCE;
203 mapped_file_ = NULL; 204 mapped_file_ = NULL;
204 Unmap(); 205 Unmap();
205 } 206 }
206 207
207 if (process == GetCurrentProcess() && close_self) { 208 if (process == GetCurrentProcess() && close_self) {
208 *new_handle = mapped_file; 209 *new_handle = mapped_file;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void SharedMemory::Unlock() { 253 void SharedMemory::Unlock() {
253 DCHECK(lock_ != NULL); 254 DCHECK(lock_ != NULL);
254 ReleaseMutex(lock_); 255 ReleaseMutex(lock_);
255 } 256 }
256 257
257 SharedMemoryHandle SharedMemory::handle() const { 258 SharedMemoryHandle SharedMemory::handle() const {
258 return mapped_file_; 259 return mapped_file_;
259 } 260 }
260 261
261 } // namespace base 262 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | chrome/browser/extensions/user_script_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698