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

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

Issue 27265002: Implement SharedMemory::NewAnonymousReadOnly(contents). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mark's comments Created 7 years, 1 month 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/memory/shared_memory.h ('k') | base/memory/shared_memory_nacl.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) 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 <sys/mman.h> 7 #include <sys/mman.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "third_party/ashmem/ashmem.h" 10 #include "third_party/ashmem/ashmem.h"
(...skipping 19 matching lines...) Expand all
30 DLOG(ERROR) << "Shared memory creation failed"; 30 DLOG(ERROR) << "Shared memory creation failed";
31 return false; 31 return false;
32 } 32 }
33 33
34 int err = ashmem_set_prot_region(mapped_file_, 34 int err = ashmem_set_prot_region(mapped_file_,
35 PROT_READ | PROT_WRITE | PROT_EXEC); 35 PROT_READ | PROT_WRITE | PROT_EXEC);
36 if (err < 0) { 36 if (err < 0) {
37 DLOG(ERROR) << "Error " << err << " when setting protection of ashmem"; 37 DLOG(ERROR) << "Error " << err << " when setting protection of ashmem";
38 return false; 38 return false;
39 } 39 }
40
41 // Android doesn't appear to have a way to drop write access on an ashmem
42 // segment for a single descriptor. http://crbug.com/320865
43 readonly_mapped_file_ = dup(mapped_file_);
44 if (-1 == readonly_mapped_file_) {
45 DPLOG(ERROR) << "dup() failed";
46 return false;
47 }
48
40 requested_size_ = options.size; 49 requested_size_ = options.size;
41 50
42 return true; 51 return true;
43 } 52 }
44 53
45 bool SharedMemory::Delete(const std::string& name) { 54 bool SharedMemory::Delete(const std::string& name) {
46 // Like on Windows, this is intentionally returning true as ashmem will 55 // Like on Windows, this is intentionally returning true as ashmem will
47 // automatically releases the resource when all FDs on it are closed. 56 // automatically releases the resource when all FDs on it are closed.
48 return true; 57 return true;
49 } 58 }
50 59
51 bool SharedMemory::Open(const std::string& name, bool read_only) { 60 bool SharedMemory::Open(const std::string& name, bool read_only) {
52 // ashmem doesn't support name mapping 61 // ashmem doesn't support name mapping
53 NOTIMPLEMENTED(); 62 NOTIMPLEMENTED();
54 return false; 63 return false;
55 } 64 }
56 65
57 } // namespace base 66 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory.h ('k') | base/memory/shared_memory_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698