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

Side by Side Diff: base/shared_memory_posix.cc

Issue 115396: Fix a memory leak in ResourceDispatcher... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « base/shared_memory.h ('k') | base/shared_memory_win.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/shared_memory.h" 5 #include "base/shared_memory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // static 63 // static
64 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { 64 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
65 return handle.fd >= 0; 65 return handle.fd >= 0;
66 } 66 }
67 67
68 // static 68 // static
69 SharedMemoryHandle SharedMemory::NULLHandle() { 69 SharedMemoryHandle SharedMemory::NULLHandle() {
70 return SharedMemoryHandle(); 70 return SharedMemoryHandle();
71 } 71 }
72 72
73 // static
74 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
75 DCHECK(handle.fd >= 0);
76 close(handle.fd);
77 }
78
73 bool SharedMemory::Create(const std::wstring &name, bool read_only, 79 bool SharedMemory::Create(const std::wstring &name, bool read_only,
74 bool open_existing, size_t size) { 80 bool open_existing, size_t size) {
75 read_only_ = read_only; 81 read_only_ = read_only;
76 82
77 int posix_flags = 0; 83 int posix_flags = 0;
78 posix_flags |= read_only ? O_RDONLY : O_RDWR; 84 posix_flags |= read_only ? O_RDONLY : O_RDWR;
79 if (!open_existing || mapped_file_ <= 0) 85 if (!open_existing || mapped_file_ <= 0)
80 posix_flags |= O_CREAT; 86 posix_flags |= O_CREAT;
81 87
82 if (!CreateOrOpen(name, posix_flags, size)) 88 if (!CreateOrOpen(name, posix_flags, size))
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 309
304 void SharedMemory::Unlock() { 310 void SharedMemory::Unlock() {
305 LockOrUnlockCommon(F_ULOCK); 311 LockOrUnlockCommon(F_ULOCK);
306 } 312 }
307 313
308 SharedMemoryHandle SharedMemory::handle() const { 314 SharedMemoryHandle SharedMemory::handle() const {
309 return FileDescriptor(mapped_file_, false); 315 return FileDescriptor(mapped_file_, false);
310 } 316 }
311 317
312 } // namespace base 318 } // namespace base
OLDNEW
« no previous file with comments | « base/shared_memory.h ('k') | base/shared_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698