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

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

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 6 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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 9
10 namespace { 10 namespace {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 SharedMemoryHandle SharedMemory::NULLHandle() { 80 SharedMemoryHandle SharedMemory::NULLHandle() {
81 return NULL; 81 return NULL;
82 } 82 }
83 83
84 // static 84 // static
85 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { 85 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
86 DCHECK(handle != NULL); 86 DCHECK(handle != NULL);
87 ::CloseHandle(handle); 87 ::CloseHandle(handle);
88 } 88 }
89 89
90 //static
91 SharedMemoryHandle SharedMemory::DuplicateHandle(
92 const SharedMemoryHandle& handle) {
93 HANDLE result;
94 BOOL success = ::DuplicateHandle(::GetCurrentProcess(), handle,
95 ::GetCurrentProcess(), &result,
96 0, TRUE, DUPLICATE_SAME_ACCESS);
97 if (!success)
98 return NULLHandle();
99 return result;
100 }
101
90 // static 102 // static
91 size_t SharedMemory::GetHandleLimit() { 103 size_t SharedMemory::GetHandleLimit() {
92 // Rounded down from value reported here: 104 // Rounded down from value reported here:
93 // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx 105 // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx
94 return static_cast<size_t>(1 << 23); 106 return static_cast<size_t>(1 << 23);
95 } 107 }
96 108
97 bool SharedMemory::CreateAndMapAnonymous(size_t size) { 109 bool SharedMemory::CreateAndMapAnonymous(size_t size) {
98 return CreateAnonymous(size) && Map(size); 110 return CreateAnonymous(size) && Map(size);
99 } 111 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 options = DUPLICATE_CLOSE_SOURCE; 213 options = DUPLICATE_CLOSE_SOURCE;
202 mapped_file_ = NULL; 214 mapped_file_ = NULL;
203 Unmap(); 215 Unmap();
204 } 216 }
205 217
206 if (process == GetCurrentProcess() && close_self) { 218 if (process == GetCurrentProcess() && close_self) {
207 *new_handle = mapped_file; 219 *new_handle = mapped_file;
208 return true; 220 return true;
209 } 221 }
210 222
211 if (!DuplicateHandle(GetCurrentProcess(), mapped_file, process, 223 if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process,
212 &result, access, FALSE, options)) 224 &result, access, FALSE, options))
213 return false; 225 return false;
214 *new_handle = result; 226 *new_handle = result;
215 return true; 227 return true;
216 } 228 }
217 229
218 230
219 void SharedMemory::Close() { 231 void SharedMemory::Close() {
220 if (memory_ != NULL) { 232 if (memory_ != NULL) {
221 UnmapViewOfFile(memory_); 233 UnmapViewOfFile(memory_);
222 memory_ = NULL; 234 memory_ = NULL;
(...skipping 28 matching lines...) Expand all
251 void SharedMemory::Unlock() { 263 void SharedMemory::Unlock() {
252 DCHECK(lock_ != NULL); 264 DCHECK(lock_ != NULL);
253 ReleaseMutex(lock_); 265 ReleaseMutex(lock_);
254 } 266 }
255 267
256 SharedMemoryHandle SharedMemory::handle() const { 268 SharedMemoryHandle SharedMemory::handle() const {
257 return mapped_file_; 269 return mapped_file_;
258 } 270 }
259 271
260 } // namespace base 272 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698