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

Unified Diff: mojo/edk/embedder/simple_platform_shared_buffer_android.cc

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: mojo/edk/embedder/simple_platform_shared_buffer_android.cc
diff --git a/mojo/edk/embedder/simple_platform_shared_buffer_android.cc b/mojo/edk/embedder/simple_platform_shared_buffer_android.cc
deleted file mode 100644
index 3517db37cba3cecd16054f0d408ec895b1d1b737..0000000000000000000000000000000000000000
--- a/mojo/edk/embedder/simple_platform_shared_buffer_android.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2014 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 "mojo/edk/embedder/simple_platform_shared_buffer.h"
-
-#include <stdint.h>
-#include <sys/mman.h> // For |mmap()|/|munmap()|.
-#include <sys/types.h> // For |off_t|.
-#include <unistd.h>
-
-#include <limits>
-
-#include "base/files/scoped_file.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "mojo/edk/embedder/platform_handle.h"
-#include "third_party/ashmem/ashmem.h"
-
-namespace mojo {
-namespace embedder {
-
-// SimplePlatformSharedBuffer --------------------------------------------------
-
-bool SimplePlatformSharedBuffer::Init() {
- DCHECK(!handle_.is_valid());
-
- if (static_cast<uint64_t>(num_bytes_) >
- static_cast<uint64_t>(std::numeric_limits<off_t>::max())) {
- return false;
- }
-
- base::ScopedFD fd(ashmem_create_region(nullptr, num_bytes_));
- if (!fd.is_valid()) {
- DPLOG(ERROR) << "ashmem_create_region()";
- return false;
- }
-
- if (ashmem_set_prot_region(fd.get(), PROT_READ | PROT_WRITE) < 0) {
- DPLOG(ERROR) << "ashmem_set_prot_region()";
- return false;
- }
-
- handle_.reset(PlatformHandle(fd.release()));
- return true;
-}
-
-bool SimplePlatformSharedBuffer::InitFromPlatformHandle(
- ScopedPlatformHandle platform_handle) {
- DCHECK(!handle_.is_valid());
-
- if (static_cast<uint64_t>(num_bytes_) >
- static_cast<uint64_t>(std::numeric_limits<off_t>::max())) {
- return false;
- }
-
- int size = ashmem_get_size_region(platform_handle.get().fd);
-
- if (size < 0) {
- DPLOG(ERROR) << "ashmem_get_size_region()";
- return false;
- }
-
- if (static_cast<size_t>(size) != num_bytes_) {
- LOG(ERROR) << "Shared memory region has the wrong size";
- return false;
- }
-
- handle_ = platform_handle.Pass();
- return true;
-}
-
-} // namespace embedder
-} // namespace mojo
« no previous file with comments | « mojo/edk/embedder/simple_platform_shared_buffer.cc ('k') | mojo/edk/embedder/simple_platform_shared_buffer_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698