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

Unified Diff: mojo/embedder/simple_platform_shared_buffer_win.cc

Issue 621153003: Move mojo edk into mojo/edk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix checkdeps Created 6 years, 2 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
« no previous file with comments | « mojo/embedder/simple_platform_shared_buffer_unittest.cc ('k') | mojo/embedder/simple_platform_support.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/embedder/simple_platform_shared_buffer_win.cc
diff --git a/mojo/embedder/simple_platform_shared_buffer_win.cc b/mojo/embedder/simple_platform_shared_buffer_win.cc
deleted file mode 100644
index 73a4d6fa0d86774e310da6bf3503efcaaca5d221..0000000000000000000000000000000000000000
--- a/mojo/embedder/simple_platform_shared_buffer_win.cc
+++ /dev/null
@@ -1,94 +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/embedder/simple_platform_shared_buffer.h"
-
-#include <windows.h>
-
-#include <limits>
-
-#include "base/logging.h"
-#include "base/sys_info.h"
-#include "mojo/embedder/platform_handle.h"
-#include "mojo/embedder/scoped_platform_handle.h"
-
-namespace mojo {
-namespace embedder {
-
-// SimplePlatformSharedBuffer --------------------------------------------------
-
-bool SimplePlatformSharedBuffer::Init() {
- DCHECK(!handle_.is_valid());
-
- // TODO(vtl): Currently, we only support mapping up to 2^32-1 bytes.
- if (static_cast<uint64_t>(num_bytes_) >
- static_cast<uint64_t>(std::numeric_limits<DWORD>::max())) {
- return false;
- }
-
- // IMPORTANT NOTE: Unnamed objects are NOT SECURABLE. Thus if we ever want to
- // share read-only to other processes, we'll have to name our file mapping
- // object.
- // TODO(vtl): Unlike |base::SharedMemory|, we don't round up the size (to a
- // multiple of 64 KB). This may cause problems with NaCl. Cross this bridge
- // when we get there. crbug.com/210609
- handle_.reset(PlatformHandle(CreateFileMapping(INVALID_HANDLE_VALUE,
- nullptr,
- PAGE_READWRITE,
- 0,
- static_cast<DWORD>(num_bytes_),
- nullptr)));
- if (!handle_.is_valid()) {
- PLOG(ERROR) << "CreateFileMapping";
- return false;
- }
-
- return true;
-}
-
-bool SimplePlatformSharedBuffer::InitFromPlatformHandle(
- ScopedPlatformHandle platform_handle) {
- DCHECK(!handle_.is_valid());
-
- // TODO(vtl): Implement.
- NOTIMPLEMENTED();
- return false;
-}
-
-scoped_ptr<PlatformSharedBufferMapping> SimplePlatformSharedBuffer::MapImpl(
- size_t offset,
- size_t length) {
- size_t offset_rounding = offset % base::SysInfo::VMAllocationGranularity();
- size_t real_offset = offset - offset_rounding;
- size_t real_length = length + offset_rounding;
-
- // This should hold (since we checked |num_bytes| versus the maximum value of
- // |off_t| on creation, but it never hurts to be paranoid.
- DCHECK_LE(static_cast<uint64_t>(real_offset),
- static_cast<uint64_t>(std::numeric_limits<DWORD>::max()));
-
- void* real_base = MapViewOfFile(handle_.get().handle,
- FILE_MAP_READ | FILE_MAP_WRITE,
- 0,
- static_cast<DWORD>(real_offset),
- real_length);
- if (!real_base) {
- PLOG(ERROR) << "MapViewOfFile";
- return nullptr;
- }
-
- void* base = static_cast<char*>(real_base) + offset_rounding;
- return make_scoped_ptr(new SimplePlatformSharedBufferMapping(
- base, length, real_base, real_length));
-}
-
-// SimplePlatformSharedBufferMapping -------------------------------------------
-
-void SimplePlatformSharedBufferMapping::Unmap() {
- BOOL result = UnmapViewOfFile(real_base_);
- PLOG_IF(ERROR, !result) << "UnmapViewOfFile";
-}
-
-} // namespace embedder
-} // namespace mojo
« no previous file with comments | « mojo/embedder/simple_platform_shared_buffer_unittest.cc ('k') | mojo/embedder/simple_platform_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698