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

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

Issue 2859843002: Add a GUID to base::SharedMemoryHandle. (Closed)
Patch Set: fix guid on android. Created 3 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
« no previous file with comments | « base/memory/shared_memory.h ('k') | base/memory/shared_memory_handle.h » ('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) 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 <stddef.h> 7 #include <stddef.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 24 matching lines...) Expand all
35 35
36 int err = ashmem_set_prot_region(shm_.GetHandle(), 36 int err = ashmem_set_prot_region(shm_.GetHandle(),
37 PROT_READ | PROT_WRITE | PROT_EXEC); 37 PROT_READ | PROT_WRITE | PROT_EXEC);
38 if (err < 0) { 38 if (err < 0) {
39 DLOG(ERROR) << "Error " << err << " when setting protection of ashmem"; 39 DLOG(ERROR) << "Error " << err << " when setting protection of ashmem";
40 return false; 40 return false;
41 } 41 }
42 42
43 // Android doesn't appear to have a way to drop write access on an ashmem 43 // Android doesn't appear to have a way to drop write access on an ashmem
44 // segment for a single descriptor. http://crbug.com/320865 44 // segment for a single descriptor. http://crbug.com/320865
45 readonly_shm_ = SharedMemoryHandle::ImportHandle(dup(shm_.GetHandle())); 45 readonly_shm_ = SharedMemoryHandle(
46 base::FileDescriptor(dup(shm_.GetHandle()), false), shm_.GetGUID());
46 if (!readonly_shm_.IsValid()) { 47 if (!readonly_shm_.IsValid()) {
47 DPLOG(ERROR) << "dup() failed"; 48 DPLOG(ERROR) << "dup() failed";
48 return false; 49 return false;
49 } 50 }
50 51
51 requested_size_ = options.size; 52 requested_size_ = options.size;
52 53
53 return true; 54 return true;
54 } 55 }
55 56
56 bool SharedMemory::Delete(const std::string& name) { 57 bool SharedMemory::Delete(const std::string& name) {
57 // Like on Windows, this is intentionally returning true as ashmem will 58 // Like on Windows, this is intentionally returning true as ashmem will
58 // automatically releases the resource when all FDs on it are closed. 59 // automatically releases the resource when all FDs on it are closed.
59 return true; 60 return true;
60 } 61 }
61 62
62 bool SharedMemory::Open(const std::string& name, bool read_only) { 63 bool SharedMemory::Open(const std::string& name, bool read_only) {
63 // ashmem doesn't support name mapping 64 // ashmem doesn't support name mapping
64 NOTIMPLEMENTED(); 65 NOTIMPLEMENTED();
65 return false; 66 return false;
66 } 67 }
67 68
68 } // namespace base 69 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory.h ('k') | base/memory/shared_memory_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698