1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/files/memory_mapped_file.h"
7 #include "base/files/file_path.h"
8 #include "base/logging.h"
12 MemoryMappedFile::~MemoryMappedFile() {
16 bool MemoryMappedFile::Initialize(const FilePath& file_name) {
20 if (!MapFileToMemory(file_name)) {
28 bool MemoryMappedFile::Initialize(PlatformFile file) {
34 if (!MapFileToMemoryInternal()) {
42 bool MemoryMappedFile::IsValid() const {
46 bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
47 file_ = CreatePlatformFile(file_name, PLATFORM_FILE_OPEN | PLATFORM_FILE_READ,
50 if (file_ == kInvalidPlatformFileValue) {
51 DLOG(ERROR) << "Couldn't open " << file_name.AsUTF8Unsafe();
55 return MapFileToMemoryInternal();