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

Side by Side Diff: base/shared_memory_posix.cc

Issue 48005: Port visitedlink tests to Linux. Also make them pass on Linux, which (Closed)
Patch Set: GetInvalidHandle -> NULLHandle Created 11 years, 9 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 | « 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 SharedMemory::~SharedMemory() { 59 SharedMemory::~SharedMemory() {
60 Close(); 60 Close();
61 } 61 }
62 62
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
69 SharedMemoryHandle SharedMemory::NULLHandle() {
70 return SharedMemoryHandle();
71 }
72
68 bool SharedMemory::Create(const std::wstring &name, bool read_only, 73 bool SharedMemory::Create(const std::wstring &name, bool read_only,
69 bool open_existing, size_t size) { 74 bool open_existing, size_t size) {
70 read_only_ = read_only; 75 read_only_ = read_only;
71 76
72 int posix_flags = 0; 77 int posix_flags = 0;
73 posix_flags |= read_only ? O_RDONLY : O_RDWR; 78 posix_flags |= read_only ? O_RDONLY : O_RDWR;
74 if (!open_existing || mapped_file_ <= 0) 79 if (!open_existing || mapped_file_ <= 0)
75 posix_flags |= O_CREAT; 80 posix_flags |= O_CREAT;
76 81
77 if (!CreateOrOpen(name, posix_flags, size)) 82 if (!CreateOrOpen(name, posix_flags, size))
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 306
302 void SharedMemory::Unlock() { 307 void SharedMemory::Unlock() {
303 LockOrUnlockCommon(F_ULOCK); 308 LockOrUnlockCommon(F_ULOCK);
304 } 309 }
305 310
306 SharedMemoryHandle SharedMemory::handle() const { 311 SharedMemoryHandle SharedMemory::handle() const {
307 return FileDescriptor(mapped_file_, false); 312 return FileDescriptor(mapped_file_, false);
308 } 313 }
309 314
310 } // namespace base 315 } // 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