summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-24 21:55:45 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-24 21:55:45 +0000
commitc3088cbb5cbd5c91b6c5602750ec327ff7963862 (patch)
tree4aac06d2b2541d9ef2744f719478f6c2c88b00c1
parent47e870bf26f0c01dafe611ec03c0139c735063df (diff)
downloadchromium_src-c3088cbb5cbd5c91b6c5602750ec327ff7963862.zip
chromium_src-c3088cbb5cbd5c91b6c5602750ec327ff7963862.tar.gz
chromium_src-c3088cbb5cbd5c91b6c5602750ec327ff7963862.tar.bz2
base: Move MemoryMappedFile out of file_util.h and into its own header file.
BUG=175002 TEST=base_unittests R=brettw@chromium.org TBR=erikwright@chromium.org,tommi@chromium.org,fischman@chromium.org,ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/12321062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184356 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base.gypi4
-rw-r--r--base/file_util.cc50
-rw-r--r--base/file_util.h53
-rw-r--r--base/file_util_posix.cc40
-rw-r--r--base/file_util_win.cc76
-rw-r--r--base/files/memory_mapped_file.cc58
-rw-r--r--base/files/memory_mapped_file.h76
-rw-r--r--base/files/memory_mapped_file_posix.cc54
-rw-r--r--base/files/memory_mapped_file_win.cc87
-rw-r--r--base/i18n/icu_util.cc3
-rw-r--r--base/test/test_file_util_mac.cc4
-rw-r--r--chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc3
-rw-r--r--chrome/installer/test/resource_updater.cc4
-rw-r--r--chrome/installer/util/move_tree_work_item_unittest.cc3
-rw-r--r--chrome/renderer/spellchecker/hunspell_engine.cc5
-rw-r--r--chrome/renderer/spellchecker/hunspell_engine.h15
-rw-r--r--chrome/renderer/spellchecker/spellcheck.h4
-rw-r--r--chrome_frame/test/navigation_test.cc1
-rw-r--r--chrome_frame/test/test_server.cc5
-rw-r--r--chrome_frame/test/test_server.h5
-rw-r--r--chrome_frame/test/test_with_web_server.cc2
-rw-r--r--chrome_frame/test/ui_test.cc1
-rw-r--r--content/common/gpu/media/h264_parser_unittest.cc4
-rw-r--r--content/renderer/hyphenator/hyphenator.cc4
-rw-r--r--content/renderer/hyphenator/hyphenator.h4
-rw-r--r--courgette/ensemble_apply.cc6
-rw-r--r--media/ffmpeg/ffmpeg_unittest.cc3
-rw-r--r--media/filters/file_data_source.h4
-rw-r--r--media/test/ffmpeg_tests/ffmpeg_tests.cc3
-rw-r--r--media/tools/media_bench/media_bench.cc3
-rw-r--r--ui/base/resource/data_pack.cc5
-rw-r--r--ui/base/resource/data_pack.h7
-rw-r--r--webkit/plugins/npapi/plugin_list_win.cc3
33 files changed, 335 insertions, 264 deletions
diff --git a/base/base.gypi b/base/base.gypi
index 35776f7..6e7013f 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -168,6 +168,10 @@
'files/file_util_proxy.h',
'files/important_file_writer.h',
'files/important_file_writer.cc',
+ 'files/memory_mapped_file.cc',
+ 'files/memory_mapped_file.h',
+ 'files/memory_mapped_file_posix.cc',
+ 'files/memory_mapped_file_win.cc',
'files/scoped_temp_dir.cc',
'files/scoped_temp_dir.h',
'float_util.h',
diff --git a/base/file_util.cc b/base/file_util.cc
index b6cdc98..f951e3b 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -351,56 +351,6 @@ int64 ComputeFilesSize(const FilePath& directory,
}
///////////////////////////////////////////////
-// MemoryMappedFile
-
-MemoryMappedFile::~MemoryMappedFile() {
- CloseHandles();
-}
-
-bool MemoryMappedFile::Initialize(const FilePath& file_name) {
- if (IsValid())
- return false;
-
- if (!MapFileToMemory(file_name)) {
- CloseHandles();
- return false;
- }
-
- return true;
-}
-
-bool MemoryMappedFile::Initialize(base::PlatformFile file) {
- if (IsValid())
- return false;
-
- file_ = file;
-
- if (!MapFileToMemoryInternal()) {
- CloseHandles();
- return false;
- }
-
- return true;
-}
-
-bool MemoryMappedFile::IsValid() const {
- return data_ != NULL;
-}
-
-bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
- file_ = base::CreatePlatformFile(
- file_name, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
- NULL, NULL);
-
- if (file_ == base::kInvalidPlatformFileValue) {
- DLOG(ERROR) << "Couldn't open " << file_name.value();
- return false;
- }
-
- return MapFileToMemoryInternal();
-}
-
-///////////////////////////////////////////////
// FileEnumerator
//
// Note: the main logic is in file_util_<platform>.cc
diff --git a/base/file_util.h b/base/file_util.h
index e36456a..bd4b33d 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -560,59 +560,6 @@ class BASE_EXPORT FileEnumerator {
DISALLOW_COPY_AND_ASSIGN(FileEnumerator);
};
-class BASE_EXPORT MemoryMappedFile {
- public:
- // The default constructor sets all members to invalid/null values.
- MemoryMappedFile();
- ~MemoryMappedFile();
-
- // Opens an existing file and maps it into memory. Access is restricted to
- // read only. If this object already points to a valid memory mapped file
- // then this method will fail and return false. If it cannot open the file,
- // the file does not exist, or the memory mapping fails, it will return false.
- // Later we may want to allow the user to specify access.
- bool Initialize(const base::FilePath& file_name);
- // As above, but works with an already-opened file. MemoryMappedFile will take
- // ownership of |file| and close it when done.
- bool Initialize(base::PlatformFile file);
-
-#if defined(OS_WIN)
- // Opens an existing file and maps it as an image section. Please refer to
- // the Initialize function above for additional information.
- bool InitializeAsImageSection(const base::FilePath& file_name);
-#endif // OS_WIN
-
- const uint8* data() const { return data_; }
- size_t length() const { return length_; }
-
- // Is file_ a valid file handle that points to an open, memory mapped file?
- bool IsValid() const;
-
- private:
- // Open the given file and pass it to MapFileToMemoryInternal().
- bool MapFileToMemory(const base::FilePath& file_name);
-
- // Map the file to memory, set data_ to that memory address. Return true on
- // success, false on any kind of failure. This is a helper for Initialize().
- bool MapFileToMemoryInternal();
-
- // Closes all open handles. Later we may want to make this public.
- void CloseHandles();
-
-#if defined(OS_WIN)
- // MapFileToMemoryInternal calls this function. It provides the ability to
- // pass in flags which control the mapped section.
- bool MapFileToMemoryInternalEx(int flags);
-
- HANDLE file_mapping_;
-#endif
- base::PlatformFile file_;
- uint8* data_;
- size_t length_;
-
- DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile);
-};
-
// Returns whether the file has been modified since a particular date.
BASE_EXPORT bool HasFileBeenModifiedSince(
const FileEnumerator::FindInfo& find_info,
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 974b30d..8b01412 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -859,46 +859,6 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries,
return true;
}
-///////////////////////////////////////////////
-// MemoryMappedFile
-
-MemoryMappedFile::MemoryMappedFile()
- : file_(base::kInvalidPlatformFileValue),
- data_(NULL),
- length_(0) {
-}
-
-bool MemoryMappedFile::MapFileToMemoryInternal() {
- base::ThreadRestrictions::AssertIOAllowed();
-
- struct stat file_stat;
- if (fstat(file_, &file_stat) == base::kInvalidPlatformFileValue) {
- DLOG(ERROR) << "Couldn't fstat " << file_ << ", errno " << errno;
- return false;
- }
- length_ = file_stat.st_size;
-
- data_ = static_cast<uint8*>(
- mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0));
- if (data_ == MAP_FAILED)
- DLOG(ERROR) << "Couldn't mmap " << file_ << ", errno " << errno;
-
- return data_ != MAP_FAILED;
-}
-
-void MemoryMappedFile::CloseHandles() {
- base::ThreadRestrictions::AssertIOAllowed();
-
- if (data_ != NULL)
- munmap(data_, length_);
- if (file_ != base::kInvalidPlatformFileValue)
- ignore_result(HANDLE_EINTR(close(file_)));
-
- data_ = NULL;
- length_ = 0;
- file_ = base::kInvalidPlatformFileValue;
-}
-
bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
const base::Time& cutoff_time) {
return static_cast<time_t>(find_info.stat.st_mtime) >= cutoff_time.ToTimeT();
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 679b108..f7897a0 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -755,82 +755,6 @@ FilePath FileEnumerator::Next() {
return FilePath();
}
-///////////////////////////////////////////////
-// MemoryMappedFile
-
-MemoryMappedFile::MemoryMappedFile()
- : file_(INVALID_HANDLE_VALUE),
- file_mapping_(INVALID_HANDLE_VALUE),
- data_(NULL),
- length_(INVALID_FILE_SIZE) {
-}
-
-bool MemoryMappedFile::InitializeAsImageSection(const FilePath& file_name) {
- if (IsValid())
- return false;
- file_ = base::CreatePlatformFile(
- file_name, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
- NULL, NULL);
-
- if (file_ == base::kInvalidPlatformFileValue) {
- DLOG(ERROR) << "Couldn't open " << file_name.value();
- return false;
- }
-
- if (!MapFileToMemoryInternalEx(SEC_IMAGE)) {
- CloseHandles();
- return false;
- }
-
- return true;
-}
-
-bool MemoryMappedFile::MapFileToMemoryInternal() {
- return MapFileToMemoryInternalEx(0);
-}
-
-bool MemoryMappedFile::MapFileToMemoryInternalEx(int flags) {
- base::ThreadRestrictions::AssertIOAllowed();
-
- if (file_ == INVALID_HANDLE_VALUE)
- return false;
-
- length_ = ::GetFileSize(file_, NULL);
- if (length_ == INVALID_FILE_SIZE)
- return false;
-
- file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY | flags,
- 0, 0, NULL);
- if (!file_mapping_) {
- // According to msdn, system error codes are only reserved up to 15999.
- // http://msdn.microsoft.com/en-us/library/ms681381(v=VS.85).aspx.
- UMA_HISTOGRAM_ENUMERATION("MemoryMappedFile.CreateFileMapping",
- logging::GetLastSystemErrorCode(), 16000);
- return false;
- }
-
- data_ = static_cast<uint8*>(
- ::MapViewOfFile(file_mapping_, FILE_MAP_READ, 0, 0, 0));
- if (!data_) {
- UMA_HISTOGRAM_ENUMERATION("MemoryMappedFile.MapViewOfFile",
- logging::GetLastSystemErrorCode(), 16000);
- }
- return data_ != NULL;
-}
-
-void MemoryMappedFile::CloseHandles() {
- if (data_)
- ::UnmapViewOfFile(data_);
- if (file_mapping_ != INVALID_HANDLE_VALUE)
- ::CloseHandle(file_mapping_);
- if (file_ != INVALID_HANDLE_VALUE)
- ::CloseHandle(file_);
-
- data_ = NULL;
- file_mapping_ = file_ = INVALID_HANDLE_VALUE;
- length_ = INVALID_FILE_SIZE;
-}
-
bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
const base::Time& cutoff_time) {
base::ThreadRestrictions::AssertIOAllowed();
diff --git a/base/files/memory_mapped_file.cc b/base/files/memory_mapped_file.cc
new file mode 100644
index 0000000..9e98bc6
--- /dev/null
+++ b/base/files/memory_mapped_file.cc
@@ -0,0 +1,58 @@
+// 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/file_path.h"
+#include "base/logging.h"
+
+namespace base {
+
+MemoryMappedFile::~MemoryMappedFile() {
+ CloseHandles();
+}
+
+bool MemoryMappedFile::Initialize(const FilePath& file_name) {
+ if (IsValid())
+ return false;
+
+ if (!MapFileToMemory(file_name)) {
+ CloseHandles();
+ return false;
+ }
+
+ return true;
+}
+
+bool MemoryMappedFile::Initialize(PlatformFile file) {
+ if (IsValid())
+ return false;
+
+ file_ = file;
+
+ if (!MapFileToMemoryInternal()) {
+ CloseHandles();
+ return false;
+ }
+
+ return true;
+}
+
+bool MemoryMappedFile::IsValid() const {
+ return data_ != NULL;
+}
+
+bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
+ file_ = CreatePlatformFile(file_name, PLATFORM_FILE_OPEN | PLATFORM_FILE_READ,
+ NULL, NULL);
+
+ if (file_ == kInvalidPlatformFileValue) {
+ DLOG(ERROR) << "Couldn't open " << file_name.AsUTF8Unsafe();
+ return false;
+ }
+
+ return MapFileToMemoryInternal();
+}
+
+} // namespace base
diff --git a/base/files/memory_mapped_file.h b/base/files/memory_mapped_file.h
new file mode 100644
index 0000000..6df1bad
--- /dev/null
+++ b/base/files/memory_mapped_file.h
@@ -0,0 +1,76 @@
+// 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.
+
+#ifndef BASE_FILES_MEMORY_MAPPED_FILE_H_
+#define BASE_FILES_MEMORY_MAPPED_FILE_H_
+
+#include "base/base_export.h"
+#include "base/basictypes.h"
+#include "base/platform_file.h"
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
+namespace base {
+
+class FilePath;
+
+class BASE_EXPORT MemoryMappedFile {
+ public:
+ // The default constructor sets all members to invalid/null values.
+ MemoryMappedFile();
+ ~MemoryMappedFile();
+
+ // Opens an existing file and maps it into memory. Access is restricted to
+ // read only. If this object already points to a valid memory mapped file
+ // then this method will fail and return false. If it cannot open the file,
+ // the file does not exist, or the memory mapping fails, it will return false.
+ // Later we may want to allow the user to specify access.
+ bool Initialize(const FilePath& file_name);
+ // As above, but works with an already-opened file. MemoryMappedFile will take
+ // ownership of |file| and close it when done.
+ bool Initialize(PlatformFile file);
+
+#if defined(OS_WIN)
+ // Opens an existing file and maps it as an image section. Please refer to
+ // the Initialize function above for additional information.
+ bool InitializeAsImageSection(const FilePath& file_name);
+#endif // OS_WIN
+
+ const uint8* data() const { return data_; }
+ size_t length() const { return length_; }
+
+ // Is file_ a valid file handle that points to an open, memory mapped file?
+ bool IsValid() const;
+
+ private:
+ // Open the given file and pass it to MapFileToMemoryInternal().
+ bool MapFileToMemory(const FilePath& file_name);
+
+ // Map the file to memory, set data_ to that memory address. Return true on
+ // success, false on any kind of failure. This is a helper for Initialize().
+ bool MapFileToMemoryInternal();
+
+ // Closes all open handles. Later we may want to make this public.
+ void CloseHandles();
+
+#if defined(OS_WIN)
+ // MapFileToMemoryInternal calls this function. It provides the ability to
+ // pass in flags which control the mapped section.
+ bool MapFileToMemoryInternalEx(int flags);
+
+ HANDLE file_mapping_;
+#endif
+ PlatformFile file_;
+ uint8* data_;
+ size_t length_;
+
+ DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile);
+};
+
+} // namespace base
+
+#endif // BASE_FILES_MEMORY_MAPPED_FILE_H_
diff --git a/base/files/memory_mapped_file_posix.cc b/base/files/memory_mapped_file_posix.cc
new file mode 100644
index 0000000..38b2716
--- /dev/null
+++ b/base/files/memory_mapped_file_posix.cc
@@ -0,0 +1,54 @@
+// 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 <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "base/logging.h"
+#include "base/posix/eintr_wrapper.h"
+#include "base/threading/thread_restrictions.h"
+
+namespace base {
+
+MemoryMappedFile::MemoryMappedFile()
+ : file_(kInvalidPlatformFileValue),
+ data_(NULL),
+ length_(0) {
+}
+
+bool MemoryMappedFile::MapFileToMemoryInternal() {
+ ThreadRestrictions::AssertIOAllowed();
+
+ struct stat file_stat;
+ if (fstat(file_, &file_stat) == kInvalidPlatformFileValue) {
+ DLOG(ERROR) << "Couldn't fstat " << file_ << ", errno " << errno;
+ return false;
+ }
+ length_ = file_stat.st_size;
+
+ data_ = static_cast<uint8*>(
+ mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0));
+ if (data_ == MAP_FAILED)
+ DLOG(ERROR) << "Couldn't mmap " << file_ << ", errno " << errno;
+
+ return data_ != MAP_FAILED;
+}
+
+void MemoryMappedFile::CloseHandles() {
+ ThreadRestrictions::AssertIOAllowed();
+
+ if (data_ != NULL)
+ munmap(data_, length_);
+ if (file_ != kInvalidPlatformFileValue)
+ ignore_result(HANDLE_EINTR(close(file_)));
+
+ data_ = NULL;
+ length_ = 0;
+ file_ = kInvalidPlatformFileValue;
+}
+
+} // namespace base
diff --git a/base/files/memory_mapped_file_win.cc b/base/files/memory_mapped_file_win.cc
new file mode 100644
index 0000000..1a24de2
--- /dev/null
+++ b/base/files/memory_mapped_file_win.cc
@@ -0,0 +1,87 @@
+// 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/file_path.h"
+#include "base/logging.h"
+#include "base/metrics/histogram.h"
+#include "base/string16.h"
+#include "base/threading/thread_restrictions.h"
+
+namespace base {
+
+MemoryMappedFile::MemoryMappedFile()
+ : file_(INVALID_HANDLE_VALUE),
+ file_mapping_(INVALID_HANDLE_VALUE),
+ data_(NULL),
+ length_(INVALID_FILE_SIZE) {
+}
+
+bool MemoryMappedFile::InitializeAsImageSection(const FilePath& file_name) {
+ if (IsValid())
+ return false;
+ file_ = CreatePlatformFile(file_name, PLATFORM_FILE_OPEN | PLATFORM_FILE_READ,
+ NULL, NULL);
+
+ if (file_ == kInvalidPlatformFileValue) {
+ DLOG(ERROR) << "Couldn't open " << file_name.AsUTF8Unsafe();
+ return false;
+ }
+
+ if (!MapFileToMemoryInternalEx(SEC_IMAGE)) {
+ CloseHandles();
+ return false;
+ }
+
+ return true;
+}
+
+bool MemoryMappedFile::MapFileToMemoryInternal() {
+ return MapFileToMemoryInternalEx(0);
+}
+
+bool MemoryMappedFile::MapFileToMemoryInternalEx(int flags) {
+ ThreadRestrictions::AssertIOAllowed();
+
+ if (file_ == INVALID_HANDLE_VALUE)
+ return false;
+
+ length_ = ::GetFileSize(file_, NULL);
+ if (length_ == INVALID_FILE_SIZE)
+ return false;
+
+ file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY | flags,
+ 0, 0, NULL);
+ if (!file_mapping_) {
+ // According to msdn, system error codes are only reserved up to 15999.
+ // http://msdn.microsoft.com/en-us/library/ms681381(v=VS.85).aspx.
+ UMA_HISTOGRAM_ENUMERATION("MemoryMappedFile.CreateFileMapping",
+ logging::GetLastSystemErrorCode(), 16000);
+ return false;
+ }
+
+ data_ = static_cast<uint8*>(
+ ::MapViewOfFile(file_mapping_, FILE_MAP_READ, 0, 0, 0));
+ if (!data_) {
+ UMA_HISTOGRAM_ENUMERATION("MemoryMappedFile.MapViewOfFile",
+ logging::GetLastSystemErrorCode(), 16000);
+ }
+ return data_ != NULL;
+}
+
+void MemoryMappedFile::CloseHandles() {
+ if (data_)
+ ::UnmapViewOfFile(data_);
+ if (file_mapping_ != INVALID_HANDLE_VALUE)
+ ::CloseHandle(file_mapping_);
+ if (file_ != INVALID_HANDLE_VALUE)
+ ::CloseHandle(file_);
+
+ data_ = NULL;
+ file_mapping_ = file_ = INVALID_HANDLE_VALUE;
+ length_ = INVALID_FILE_SIZE;
+}
+
+} // namespace base
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index fed1176..42aa8ad 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -14,6 +14,7 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -111,7 +112,7 @@ bool Initialize() {
// Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever
// be released.
- static file_util::MemoryMappedFile mapped_file;
+ static base::MemoryMappedFile mapped_file;
if (!mapped_file.IsValid()) {
// Assume it is in the framework bundle's Resources directory.
FilePath data_path =
diff --git a/base/test/test_file_util_mac.cc b/base/test/test_file_util_mac.cc
index b52b39c..3af2c10 100644
--- a/base/test/test_file_util_mac.cc
+++ b/base/test/test_file_util_mac.cc
@@ -6,8 +6,10 @@
#include <sys/mman.h>
#include <errno.h>
+
#include "base/logging.h"
#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
namespace file_util {
@@ -30,7 +32,7 @@ bool EvictFileFromSystemCache(const base::FilePath& file) {
return true;
}
- file_util::MemoryMappedFile mapped_file;
+ base::MemoryMappedFile mapped_file;
if (!mapped_file.Initialize(file)) {
DLOG(WARNING) << "failed to memory map " << file.value();
return false;
diff --git a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
index 1a29c5e..5a20a05 100644
--- a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
+++ b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/path_service.h"
@@ -92,7 +93,7 @@ scoped_ptr<DictionaryFile> InitializeDictionaryLocation(
// scoping closes the memory-mapped file before it is opened or deleted.
bool bdict_is_valid;
{
- file_util::MemoryMappedFile map;
+ base::MemoryMappedFile map;
bdict_is_valid = file_util::PathExists(file->path) &&
map.Initialize(file->path) &&
hunspell::BDict::Verify(reinterpret_cast<const char*>(map.data()),
diff --git a/chrome/installer/test/resource_updater.cc b/chrome/installer/test/resource_updater.cc
index c308add..cf05094 100644
--- a/chrome/installer/test/resource_updater.cc
+++ b/chrome/installer/test/resource_updater.cc
@@ -6,8 +6,8 @@
#include <windows.h>
-#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
namespace upgrade_test {
@@ -39,7 +39,7 @@ bool ResourceUpdater::Update(const std::wstring& name,
WORD language_id,
const base::FilePath& input_file) {
DCHECK(handle_ != NULL);
- file_util::MemoryMappedFile input;
+ base::MemoryMappedFile input;
if (input.Initialize(input_file)) {
if (UpdateResource(handle_, type.c_str(), name.c_str(), language_id,
diff --git a/chrome/installer/util/move_tree_work_item_unittest.cc b/chrome/installer/util/move_tree_work_item_unittest.cc
index bead46e..47b2729 100644
--- a/chrome/installer/util/move_tree_work_item_unittest.cc
+++ b/chrome/installer/util/move_tree_work_item_unittest.cc
@@ -8,6 +8,7 @@
#include "base/base_paths.h"
#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/process_util.h"
@@ -412,7 +413,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExistsCheckForDuplicatesFull) {
// Lock one of the files in the to destination directory to prevent moves.
base::FilePath orig_to_file(
to_dir.AppendASCII("From_Dir2").AppendASCII("From_File"));
- file_util::MemoryMappedFile mapped_file;
+ base::MemoryMappedFile mapped_file;
EXPECT_TRUE(mapped_file.Initialize(orig_to_file));
// First check that we can't do the regular Move().
diff --git a/chrome/renderer/spellchecker/hunspell_engine.cc b/chrome/renderer/spellchecker/hunspell_engine.cc
index 34004f7..23706fa 100644
--- a/chrome/renderer/spellchecker/hunspell_engine.cc
+++ b/chrome/renderer/spellchecker/hunspell_engine.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "hunspell_engine.h"
+#include "chrome/renderer/spellchecker/hunspell_engine.h"
#include <algorithm>
#include <iterator>
+#include "base/files/memory_mapped_file.h"
#include "base/metrics/histogram.h"
#include "base/time.h"
#include "chrome/common/spellcheck_common.h"
@@ -58,7 +59,7 @@ void HunspellEngine::InitializeHunspell() {
if (hunspell_.get())
return;
- bdict_file_.reset(new file_util::MemoryMappedFile);
+ bdict_file_.reset(new base::MemoryMappedFile);
if (bdict_file_->Initialize(file_)) {
TimeTicks debug_start_time = base::Histogram::DebugNow();
diff --git a/chrome/renderer/spellchecker/hunspell_engine.h b/chrome/renderer/spellchecker/hunspell_engine.h
index 26d3a39c..bbc9fb4 100644
--- a/chrome/renderer/spellchecker/hunspell_engine.h
+++ b/chrome/renderer/spellchecker/hunspell_engine.h
@@ -5,18 +5,21 @@
#ifndef CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
#define CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
-#include "base/file_util.h"
+#include <string>
+#include <vector>
+
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/spellcheck_common.h"
#include "chrome/renderer/spellchecker/spelling_engine.h"
-#include <string>
-#include <vector>
-
class Hunspell;
+namespace base {
+class MemoryMappedFile;
+}
+
class HunspellEngine : public SpellingEngine {
public:
HunspellEngine();
@@ -36,7 +39,7 @@ class HunspellEngine : public SpellingEngine {
void InitializeHunspell();
// We memory-map the BDict file.
- scoped_ptr<file_util::MemoryMappedFile> bdict_file_;
+ scoped_ptr<base::MemoryMappedFile> bdict_file_;
// The hunspell dictionary in use.
scoped_ptr<Hunspell> hunspell_;
@@ -51,8 +54,6 @@ class HunspellEngine : public SpellingEngine {
// This flags is true if we have requested dictionary.
bool dictionary_requested_;
-
};
#endif // CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
-
diff --git a/chrome/renderer/spellchecker/spellcheck.h b/chrome/renderer/spellchecker/spellcheck.h
index 5812986..8e4c710 100644
--- a/chrome/renderer/spellchecker/spellcheck.h
+++ b/chrome/renderer/spellchecker/spellcheck.h
@@ -21,10 +21,6 @@
struct SpellCheckResult;
-namespace file_util {
-class MemoryMappedFile;
-}
-
namespace WebKit {
class WebTextCheckingCompletion;
struct WebTextCheckingResult;
diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc
index d85edfa..4f83743 100644
--- a/chrome_frame/test/navigation_test.cc
+++ b/chrome_frame/test/navigation_test.cc
@@ -4,6 +4,7 @@
#include <string>
+#include "base/file_util.h"
#include "base/test/test_file_util.h"
#include "base/win/scoped_comptr.h"
#include "base/win/windows_version.h"
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index cca7fe3..643b8ca 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome_frame/test/test_server.h"
+
#include <windows.h>
#include <objbase.h>
#include <urlmon.h>
@@ -14,7 +16,6 @@
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
-#include "chrome_frame/test/test_server.h"
#include "net/base/tcp_listen_socket.h"
#include "net/base/winsock_init.h"
#include "net/http/http_util.h"
@@ -117,7 +118,7 @@ void FileResponse::WriteContents(net::StreamListenSocket* socket) const {
size_t FileResponse::ContentLength() const {
if (file_.get() == NULL) {
- file_.reset(new file_util::MemoryMappedFile());
+ file_.reset(new base::MemoryMappedFile());
if (!file_->Initialize(file_path_)) {
NOTREACHED();
file_.reset();
diff --git a/chrome_frame/test/test_server.h b/chrome_frame/test/test_server.h
index 48fd4b7..d4f9281 100644
--- a/chrome_frame/test/test_server.h
+++ b/chrome_frame/test/test_server.h
@@ -39,7 +39,8 @@
#include <string>
#include "base/basictypes.h"
-#include "base/file_util.h"
+#include "base/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "base/message_loop.h"
#include "net/base/stream_listen_socket.h"
@@ -251,7 +252,7 @@ class FileResponse : public ResponseForPath {
protected:
base::FilePath file_path_;
- mutable scoped_ptr<file_util::MemoryMappedFile> file_;
+ mutable scoped_ptr<base::MemoryMappedFile> file_;
private:
DISALLOW_COPY_AND_ASSIGN(FileResponse);
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index 5247426..23dcc64 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -5,7 +5,9 @@
#include "chrome_frame/test/test_with_web_server.h"
#include "base/base_paths.h"
+#include "base/file_util.h"
#include "base/file_version_info.h"
+#include "base/files/memory_mapped_file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/stringprintf.h"
diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc
index 65112af..275f34c 100644
--- a/chrome_frame/test/ui_test.cc
+++ b/chrome_frame/test/ui_test.cc
@@ -5,6 +5,7 @@
#include <mshtmcid.h>
#include <string>
+#include "base/file_util.h"
#include "base/test/test_file_util.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_bstr.h"
diff --git a/content/common/gpu/media/h264_parser_unittest.cc b/content/common/gpu/media/h264_parser_unittest.cc
index 7c2a757..2aa9f43 100644
--- a/content/common/gpu/media/h264_parser_unittest.cc
+++ b/content/common/gpu/media/h264_parser_unittest.cc
@@ -5,7 +5,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/command_line.h"
-#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "content/common/gpu/media/h264_parser.h"
@@ -20,7 +20,7 @@ int num_nalus = 759;
TEST(H264ParserTest, StreamFileParsing) {
base::FilePath fp(test_stream_filename);
- file_util::MemoryMappedFile stream;
+ base::MemoryMappedFile stream;
CHECK(stream.Initialize(fp)) << "Couldn't open stream file: "
<< test_stream_filename;
DVLOG(1) << "Parsing file: " << test_stream_filename;
diff --git a/content/renderer/hyphenator/hyphenator.cc b/content/renderer/hyphenator/hyphenator.cc
index 4c063ae..163f4c1 100644
--- a/content/renderer/hyphenator/hyphenator.cc
+++ b/content/renderer/hyphenator/hyphenator.cc
@@ -4,7 +4,7 @@
#include "content/renderer/hyphenator/hyphenator.h"
-#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
@@ -203,7 +203,7 @@ bool Hyphenator::Initialize() {
// succeeds, this class does not have to close this file because it is closed
// by the MemoryMappedFile class. To prevent this class from closing this
// file, we reset its handle.
- rule_map_.reset(new file_util::MemoryMappedFile);
+ rule_map_.reset(new base::MemoryMappedFile);
if (!rule_map_->Initialize(rule_file_))
return false;
rule_file_ = base::kInvalidPlatformFileValue;
diff --git a/content/renderer/hyphenator/hyphenator.h b/content/renderer/hyphenator/hyphenator.h
index 517e49f..879f76c 100644
--- a/content/renderer/hyphenator/hyphenator.h
+++ b/content/renderer/hyphenator/hyphenator.h
@@ -14,7 +14,7 @@
#include "content/public/renderer/render_process_observer.h"
#include "ipc/ipc_platform_file.h"
-namespace file_util {
+namespace base {
class MemoryMappedFile;
}
@@ -63,7 +63,7 @@ class CONTENT_EXPORT Hyphenator : public RenderProcessObserver {
// it without opening the file.)
string16 locale_;
base::PlatformFile rule_file_;
- scoped_ptr<file_util::MemoryMappedFile> rule_map_;
+ scoped_ptr<base::MemoryMappedFile> rule_map_;
// A cached result. WebKit often calls ComputeLastHyphenLocation with the same
// word multiple times to find the best hyphenation point when it finds a line
diff --git a/courgette/ensemble_apply.cc b/courgette/ensemble_apply.cc
index 28312f3..61a3602 100644
--- a/courgette/ensemble_apply.cc
+++ b/courgette/ensemble_apply.cc
@@ -8,8 +8,8 @@
#include "base/basictypes.h"
#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
-
#include "courgette/crc.h"
#include "courgette/region.h"
#include "courgette/streams.h"
@@ -378,7 +378,7 @@ Status ApplyEnsemblePatch(const base::FilePath::CharType* old_file_name,
// First read enough of the patch file to validate the header is well-formed.
// A few varint32 numbers should fit in 100.
base::FilePath patch_file_path(patch_file_name);
- file_util::MemoryMappedFile patch_file;
+ base::MemoryMappedFile patch_file;
if (!patch_file.Initialize(patch_file_path))
return C_READ_OPEN_ERROR;
@@ -392,7 +392,7 @@ Status ApplyEnsemblePatch(const base::FilePath::CharType* old_file_name,
// Read the old_file.
base::FilePath old_file_path(old_file_name);
- file_util::MemoryMappedFile old_file;
+ base::MemoryMappedFile old_file;
if (!old_file.Initialize(old_file_path))
return C_READ_ERROR;
diff --git a/media/ffmpeg/ffmpeg_unittest.cc b/media/ffmpeg/ffmpeg_unittest.cc
index a37072e0..15c46eb 100644
--- a/media/ffmpeg/ffmpeg_unittest.cc
+++ b/media/ffmpeg/ffmpeg_unittest.cc
@@ -14,6 +14,7 @@
#include "base/base_paths.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/perftimer.h"
@@ -392,7 +393,7 @@ class FFmpegTest : public testing::TestWithParam<const char*> {
int64 decoded_video_duration_;
int64 duration_;
- file_util::MemoryMappedFile file_data_;
+ base::MemoryMappedFile file_data_;
scoped_ptr<InMemoryUrlProtocol> protocol_;
scoped_ptr<FFmpegGlue> glue_;
diff --git a/media/filters/file_data_source.h b/media/filters/file_data_source.h
index 4c92ba0..85e6f6c 100644
--- a/media/filters/file_data_source.h
+++ b/media/filters/file_data_source.h
@@ -7,8 +7,8 @@
#include <string>
-#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "media/base/data_source.h"
namespace media {
@@ -41,7 +41,7 @@ class MEDIA_EXPORT FileDataSource : public DataSource {
// Informs the host of changes in total and buffered bytes.
void UpdateHostBytes();
- file_util::MemoryMappedFile file_;
+ base::MemoryMappedFile file_;
bool force_read_errors_;
bool force_streaming_;
diff --git a/media/test/ffmpeg_tests/ffmpeg_tests.cc b/media/test/ffmpeg_tests/ffmpeg_tests.cc
index c91b647..7bee621 100644
--- a/media/test/ffmpeg_tests/ffmpeg_tests.cc
+++ b/media/test/ffmpeg_tests/ffmpeg_tests.cc
@@ -15,6 +15,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/md5.h"
#include "base/path_service.h"
@@ -115,7 +116,7 @@ int main(int argc, const char** argv) {
__try {
#endif
- file_util::MemoryMappedFile file_data;
+ base::MemoryMappedFile file_data;
file_data.Initialize(in_path);
media::InMemoryUrlProtocol protocol(
file_data.data(), file_data.length(), false);
diff --git a/media/tools/media_bench/media_bench.cc b/media/tools/media_bench/media_bench.cc
index 8c1f170..858f65d 100644
--- a/media/tools/media_bench/media_bench.cc
+++ b/media/tools/media_bench/media_bench.cc
@@ -16,6 +16,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/md5.h"
#include "base/path_service.h"
@@ -218,7 +219,7 @@ int main(int argc, const char** argv) {
__try {
#endif
- file_util::MemoryMappedFile file_data;
+ base::MemoryMappedFile file_data;
file_data.Initialize(in_path);
media::InMemoryUrlProtocol protocol(
file_data.data(), file_data.length(), false);
diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc
index 793e963..4901a9b 100644
--- a/ui/base/resource/data_pack.cc
+++ b/ui/base/resource/data_pack.cc
@@ -7,6 +7,7 @@
#include <errno.h>
#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram.h"
@@ -72,7 +73,7 @@ DataPack::~DataPack() {
}
bool DataPack::LoadFromPath(const base::FilePath& path) {
- mmap_.reset(new file_util::MemoryMappedFile);
+ mmap_.reset(new base::MemoryMappedFile);
if (!mmap_->Initialize(path)) {
DLOG(ERROR) << "Failed to mmap datapack";
UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED,
@@ -84,7 +85,7 @@ bool DataPack::LoadFromPath(const base::FilePath& path) {
}
bool DataPack::LoadFromFile(base::PlatformFile file) {
- mmap_.reset(new file_util::MemoryMappedFile);
+ mmap_.reset(new base::MemoryMappedFile);
if (!mmap_->Initialize(file)) {
DLOG(ERROR) << "Failed to mmap datapack";
UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED_FROM_FILE,
diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h
index 40913cb..3935e6b 100644
--- a/ui/base/resource/data_pack.h
+++ b/ui/base/resource/data_pack.h
@@ -21,11 +21,8 @@
namespace base {
class FilePath;
-class RefCountedStaticMemory;
-}
-
-namespace file_util {
class MemoryMappedFile;
+class RefCountedStaticMemory;
}
namespace ui {
@@ -63,7 +60,7 @@ class UI_EXPORT DataPack : public ResourceHandle {
bool LoadImpl();
// The memory-mapped data.
- scoped_ptr<file_util::MemoryMappedFile> mmap_;
+ scoped_ptr<base::MemoryMappedFile> mmap_;
// Number of resources in the data.
size_t resource_count_;
diff --git a/webkit/plugins/npapi/plugin_list_win.cc b/webkit/plugins/npapi/plugin_list_win.cc
index 0f19d08..9a8fa31 100644
--- a/webkit/plugins/npapi/plugin_list_win.cc
+++ b/webkit/plugins/npapi/plugin_list_win.cc
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/file_util.h"
+#include "base/files/memory_mapped_file.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/string_number_conversions.h"
@@ -205,7 +206,7 @@ void GetJavaDirectory(std::set<base::FilePath>* plugin_dirs) {
}
bool IsValid32BitImage(const base::FilePath& path) {
- file_util::MemoryMappedFile plugin_image;
+ base::MemoryMappedFile plugin_image;
if (!plugin_image.InitializeAsImageSection(path))
return false;