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

Side by Side Diff: base/shared_memory_android.cc

Issue 8585002: Give base::SharedMemory::CreateAnonymous an executable flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
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/shared_memory.h" 5 #include "base/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"
11 11
12 namespace base { 12 namespace base {
13 13
14 // For Android, we use ashmem to implement SharedMemory. ashmem_create_region 14 // For Android, we use ashmem to implement SharedMemory. ashmem_create_region
15 // will automatically pin the region. We never explicitly call pin/unpin. When 15 // will automatically pin the region. We never explicitly call pin/unpin. When
16 // all the file descriptors from different processes associated with the region 16 // all the file descriptors from different processes associated with the region
17 // are closed, the memory buffer will go away. 17 // are closed, the memory buffer will go away.
18 18
19 bool SharedMemory::CreateNamed(const std::string& name, 19 bool SharedMemory::CreateNamed(const std::string& name, bool open_existing,
20 bool open_existing, uint32 size) { 20 uint32 size, bool executable) {
21 DCHECK_EQ(-1, mapped_file_ ); 21 DCHECK_EQ(-1, mapped_file_ );
22 22
23 // "name" is just a label in ashmem. It is visible in /proc/pid/maps. 23 // "name" is just a label in ashmem. It is visible in /proc/pid/maps.
24 mapped_file_ = ashmem_create_region(name.c_str(), size); 24 mapped_file_ = ashmem_create_region(name.c_str(), size);
25 if (-1 == mapped_file_) { 25 if (-1 == mapped_file_) {
26 DLOG(ERROR) << "Shared memory creation failed"; 26 DLOG(ERROR) << "Shared memory creation failed";
27 return false; 27 return false;
28 } 28 }
29 29
30 int err = ashmem_set_prot_region(mapped_file_, 30 int err = ashmem_set_prot_region(mapped_file_,
(...skipping 13 matching lines...) Expand all
44 return true; 44 return true;
45 } 45 }
46 46
47 bool SharedMemory::Open(const std::string& name, bool read_only) { 47 bool SharedMemory::Open(const std::string& name, bool read_only) {
48 // ashmem doesn't support name mapping 48 // ashmem doesn't support name mapping
49 NOTIMPLEMENTED(); 49 NOTIMPLEMENTED();
50 return false; 50 return false;
51 } 51 }
52 52
53 } // namespace base 53 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698