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

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

Issue 1122163002: Ensure that the DirectWrite font cache works in Chrome canary on Windows 8+ with AppContainer prote… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 11 matching lines...) Expand all
22 return memory_info.RegionSize - (static_cast<char*>(address) - 22 return memory_info.RegionSize - (static_cast<char*>(address) -
23 static_cast<char*>(memory_info.AllocationBase)); 23 static_cast<char*>(memory_info.AllocationBase));
24 } 24 }
25 25
26 } // namespace. 26 } // namespace.
27 27
28 namespace base { 28 namespace base {
29 29
30 SharedMemory::SharedMemory() 30 SharedMemory::SharedMemory()
31 : mapped_file_(NULL), 31 : mapped_file_(NULL),
32 inheritable_(false),
32 memory_(NULL), 33 memory_(NULL),
33 read_only_(false), 34 read_only_(false),
34 mapped_size_(0), 35 mapped_size_(0),
35 requested_size_(0), 36 requested_size_(0),
36 lock_(NULL) { 37 lock_(NULL) {
37 } 38 }
38 39
39 SharedMemory::SharedMemory(const std::wstring& name) 40 SharedMemory::SharedMemory(const std::wstring& name)
40 : mapped_file_(NULL), 41 : mapped_file_(NULL),
42 inheritable_(false),
41 memory_(NULL), 43 memory_(NULL),
42 read_only_(false), 44 read_only_(false),
43 requested_size_(0), 45 requested_size_(0),
44 mapped_size_(0), 46 mapped_size_(0),
45 lock_(NULL), 47 lock_(NULL),
46 name_(name) { 48 name_(name) {
47 } 49 }
48 50
49 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only) 51 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only)
50 : mapped_file_(handle), 52 : mapped_file_(handle),
53 inheritable_(false),
51 memory_(NULL), 54 memory_(NULL),
52 read_only_(read_only), 55 read_only_(read_only),
53 requested_size_(0), 56 requested_size_(0),
54 mapped_size_(0), 57 mapped_size_(0),
55 lock_(NULL) { 58 lock_(NULL) {
56 } 59 }
57 60
58 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only, 61 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only,
59 ProcessHandle process) 62 ProcessHandle process)
60 : mapped_file_(NULL), 63 : mapped_file_(NULL),
64 inheritable_(false),
61 memory_(NULL), 65 memory_(NULL),
62 read_only_(read_only), 66 read_only_(read_only),
63 requested_size_(0), 67 requested_size_(0),
64 mapped_size_(0), 68 mapped_size_(0),
65 lock_(NULL) { 69 lock_(NULL) {
66 ::DuplicateHandle(process, handle, 70 ::DuplicateHandle(process, handle,
67 GetCurrentProcess(), &mapped_file_, 71 GetCurrentProcess(), &mapped_file_,
68 read_only_ ? FILE_MAP_READ : FILE_MAP_READ | 72 read_only_ ? FILE_MAP_READ : FILE_MAP_READ |
69 FILE_MAP_WRITE, 73 FILE_MAP_WRITE,
70 FALSE, 0); 74 FALSE, 0);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return true; 174 return true;
171 } 175 }
172 176
173 bool SharedMemory::Open(const std::string& name, bool read_only) { 177 bool SharedMemory::Open(const std::string& name, bool read_only) {
174 DCHECK(!mapped_file_); 178 DCHECK(!mapped_file_);
175 179
176 name_ = ASCIIToUTF16(name); 180 name_ = ASCIIToUTF16(name);
177 read_only_ = read_only; 181 read_only_ = read_only;
178 mapped_file_ = OpenFileMapping( 182 mapped_file_ = OpenFileMapping(
179 read_only_ ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE, 183 read_only_ ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE,
180 false, name_.empty() ? NULL : name_.c_str()); 184 inheritable_, name_.empty() ? NULL : name_.c_str());
181 if (mapped_file_ != NULL) { 185 if (mapped_file_ != NULL) {
182 // Note: size_ is not set in this case. 186 // Note: size_ is not set in this case.
183 return true; 187 return true;
184 } 188 }
185 return false; 189 return false;
186 } 190 }
187 191
188 bool SharedMemory::MapAt(off_t offset, size_t bytes) { 192 bool SharedMemory::MapAt(off_t offset, size_t bytes) {
189 if (mapped_file_ == NULL) 193 if (mapped_file_ == NULL)
190 return false; 194 return false;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void SharedMemory::UnlockDeprecated() { 279 void SharedMemory::UnlockDeprecated() {
276 DCHECK(lock_ != NULL); 280 DCHECK(lock_ != NULL);
277 ReleaseMutex(lock_); 281 ReleaseMutex(lock_);
278 } 282 }
279 283
280 SharedMemoryHandle SharedMemory::handle() const { 284 SharedMemoryHandle SharedMemory::handle() const {
281 return mapped_file_; 285 return mapped_file_;
282 } 286 }
283 287
284 } // namespace base 288 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698