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

Side by Side Diff: base/files/memory_mapped_file.cc

Issue 12321062: base: Move MemoryMappedFile out of file_util.h and into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome_frame again Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/files/memory_mapped_file.h"
6
7 #include "base/file_path.h"
8 #include "base/logging.h"
9
10 namespace base {
11
12 MemoryMappedFile::~MemoryMappedFile() {
13 CloseHandles();
14 }
15
16 bool MemoryMappedFile::Initialize(const FilePath& file_name) {
17 if (IsValid())
18 return false;
19
20 if (!MapFileToMemory(file_name)) {
21 CloseHandles();
22 return false;
23 }
24
25 return true;
26 }
27
28 bool MemoryMappedFile::Initialize(PlatformFile file) {
29 if (IsValid())
30 return false;
31
32 file_ = file;
33
34 if (!MapFileToMemoryInternal()) {
35 CloseHandles();
36 return false;
37 }
38
39 return true;
40 }
41
42 bool MemoryMappedFile::IsValid() const {
43 return data_ != NULL;
44 }
45
46 bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
47 file_ = CreatePlatformFile(file_name, PLATFORM_FILE_OPEN | PLATFORM_FILE_READ,
48 NULL, NULL);
49
50 if (file_ == kInvalidPlatformFileValue) {
51 DLOG(ERROR) << "Couldn't open " << file_name.AsUTF8Unsafe();
52 return false;
53 }
54
55 return MapFileToMemoryInternal();
56 }
57
58 } // namespace base
OLDNEW
« 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