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

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

Issue 950993003: On Windows, if intention for shared memory name is empty then we pass NULL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | 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/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 // Windows ignores DACLs on certain unnamed objects (like shared sections). 138 // Windows ignores DACLs on certain unnamed objects (like shared sections).
139 // So, we generate a random name when we need to enforce read-only. 139 // So, we generate a random name when we need to enforce read-only.
140 uint64_t rand_values[4]; 140 uint64_t rand_values[4];
141 RandBytes(&rand_values, sizeof(rand_values)); 141 RandBytes(&rand_values, sizeof(rand_values));
142 name_ = StringPrintf(L"CrSharedMem_%016x%016x%016x%016x", 142 name_ = StringPrintf(L"CrSharedMem_%016x%016x%016x%016x",
143 rand_values[0], rand_values[1], 143 rand_values[0], rand_values[1],
144 rand_values[2], rand_values[3]); 144 rand_values[2], rand_values[3]);
145 } 145 }
146 mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, 146 mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, &sa,
147 PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size), name_.c_str()); 147 PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size),
148 name_.empty() ? nullptr : name_.c_str());
148 if (!mapped_file_) 149 if (!mapped_file_)
149 return false; 150 return false;
150 151
151 requested_size_ = options.size; 152 requested_size_ = options.size;
152 153
153 // Check if the shared memory pre-exists. 154 // Check if the shared memory pre-exists.
154 if (GetLastError() == ERROR_ALREADY_EXISTS) { 155 if (GetLastError() == ERROR_ALREADY_EXISTS) {
155 // If the file already existed, set requested_size_ to 0 to show that 156 // If the file already existed, set requested_size_ to 0 to show that
156 // we don't know the size. 157 // we don't know the size.
157 requested_size_ = 0; 158 requested_size_ = 0;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void SharedMemory::UnlockDeprecated() { 275 void SharedMemory::UnlockDeprecated() {
275 DCHECK(lock_ != NULL); 276 DCHECK(lock_ != NULL);
276 ReleaseMutex(lock_); 277 ReleaseMutex(lock_);
277 } 278 }
278 279
279 SharedMemoryHandle SharedMemory::handle() const { 280 SharedMemoryHandle SharedMemory::handle() const {
280 return mapped_file_; 281 return mapped_file_;
281 } 282 }
282 283
283 } // namespace base 284 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698