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

Unified Diff: base/files/memory_mapped_file.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 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
« no previous file with comments | « base/files/memory_mapped_file.h ('k') | base/files/memory_mapped_file_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/memory_mapped_file.cc
diff --git a/base/files/memory_mapped_file.cc b/base/files/memory_mapped_file.cc
deleted file mode 100644
index 227a41f1cd9e171fd3e4cfaf3beba2540be6eb2b..0000000000000000000000000000000000000000
--- a/base/files/memory_mapped_file.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2013 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/files/memory_mapped_file.h"
-
-#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "base/sys_info.h"
-
-namespace base {
-
-const MemoryMappedFile::Region MemoryMappedFile::Region::kWholeFile = {0, 0};
-
-bool MemoryMappedFile::Region::operator==(
- const MemoryMappedFile::Region& other) const {
- return other.offset == offset && other.size == size;
-}
-
-bool MemoryMappedFile::Region::operator!=(
- const MemoryMappedFile::Region& other) const {
- return other.offset != offset || other.size != size;
-}
-
-MemoryMappedFile::~MemoryMappedFile() {
- CloseHandles();
-}
-
-#if !defined(OS_NACL)
-bool MemoryMappedFile::Initialize(const FilePath& file_name) {
- if (IsValid())
- return false;
-
- file_.Initialize(file_name, File::FLAG_OPEN | File::FLAG_READ);
-
- if (!file_.IsValid()) {
- DLOG(ERROR) << "Couldn't open " << file_name.AsUTF8Unsafe();
- return false;
- }
-
- if (!MapFileRegionToMemory(Region::kWholeFile)) {
- CloseHandles();
- return false;
- }
-
- return true;
-}
-
-bool MemoryMappedFile::Initialize(File file) {
- return Initialize(file.Pass(), Region::kWholeFile);
-}
-
-bool MemoryMappedFile::Initialize(File file, const Region& region) {
- if (IsValid())
- return false;
-
- if (region != Region::kWholeFile) {
- DCHECK_GE(region.offset, 0);
- DCHECK_GT(region.size, 0);
- }
-
- file_ = file.Pass();
-
- if (!MapFileRegionToMemory(region)) {
- CloseHandles();
- return false;
- }
-
- return true;
-}
-
-bool MemoryMappedFile::IsValid() const {
- return data_ != NULL;
-}
-
-// static
-void MemoryMappedFile::CalculateVMAlignedBoundaries(int64 start,
- int64 size,
- int64* aligned_start,
- int64* aligned_size,
- int32* offset) {
- // Sadly, on Windows, the mmap alignment is not just equal to the page size.
- const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1;
- DCHECK_LT(mask, std::numeric_limits<int32>::max());
- *offset = start & mask;
- *aligned_start = start & ~mask;
- *aligned_size = (size + *offset + mask) & ~mask;
-}
-#endif
-
-} // namespace base
« no previous file with comments | « base/files/memory_mapped_file.h ('k') | base/files/memory_mapped_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698