diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 17:46:23 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 17:46:23 +0000 |
commit | 99873aabefb3a7ea6e99f73a5e52916b0ea08309 (patch) | |
tree | 98e669f3ca6643b2cb7fbb505be79345123cc245 /base/shared_memory_android.cc | |
parent | e142919c2528aa81275e64f40be83dd7a2f3e852 (diff) | |
download | chromium_src-99873aabefb3a7ea6e99f73a5e52916b0ea08309.zip chromium_src-99873aabefb3a7ea6e99f73a5e52916b0ea08309.tar.gz chromium_src-99873aabefb3a7ea6e99f73a5e52916b0ea08309.tar.bz2 |
Move shared_memory into base/memory subdirectory.
This leaves a forwarding header in place so all calling code can be updated asynchronously.
BUG=
Review URL: https://codereview.chromium.org/13044024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/shared_memory_android.cc')
-rw-r--r-- | base/shared_memory_android.cc | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/base/shared_memory_android.cc b/base/shared_memory_android.cc deleted file mode 100644 index 084904a..0000000 --- a/base/shared_memory_android.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/shared_memory.h" - -#include <sys/mman.h> - -#include "base/logging.h" -#include "third_party/ashmem/ashmem.h" - -namespace base { - -// For Android, we use ashmem to implement SharedMemory. ashmem_create_region -// will automatically pin the region. We never explicitly call pin/unpin. When -// all the file descriptors from different processes associated with the region -// are closed, the memory buffer will go away. - -bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { - DCHECK_EQ(-1, mapped_file_ ); - - if (options.size > static_cast<size_t>(std::numeric_limits<int>::max())) - return false; - - // "name" is just a label in ashmem. It is visible in /proc/pid/maps. - mapped_file_ = ashmem_create_region( - options.name == NULL ? "" : options.name->c_str(), - options.size); - if (-1 == mapped_file_) { - DLOG(ERROR) << "Shared memory creation failed"; - return false; - } - - int err = ashmem_set_prot_region(mapped_file_, - PROT_READ | PROT_WRITE | PROT_EXEC); - if (err < 0) { - DLOG(ERROR) << "Error " << err << " when setting protection of ashmem"; - return false; - } - requested_size_ = options.size; - - return true; -} - -bool SharedMemory::Delete(const std::string& name) { - // Like on Windows, this is intentionally returning true as ashmem will - // automatically releases the resource when all FDs on it are closed. - return true; -} - -bool SharedMemory::Open(const std::string& name, bool read_only) { - // ashmem doesn't support name mapping - NOTIMPLEMENTED(); - return false; -} - -} // namespace base |