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

Side by Side Diff: ui/base/resource/data_pack.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, 9 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 | « ui/base/resource/data_pack.h ('k') | webkit/plugins/npapi/plugin_list_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/resource/data_pack.h" 5 #include "ui/base/resource/data_pack.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/memory_mapped_file.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/string_piece.h" 14 #include "base/string_piece.h"
14 15
15 // For details of the file layout, see 16 // For details of the file layout, see
16 // http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalize dstrings 17 // http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalize dstrings
17 18
18 namespace { 19 namespace {
19 20
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 DataPack::DataPack(ui::ScaleFactor scale_factor) 66 DataPack::DataPack(ui::ScaleFactor scale_factor)
66 : resource_count_(0), 67 : resource_count_(0),
67 text_encoding_type_(BINARY), 68 text_encoding_type_(BINARY),
68 scale_factor_(scale_factor) { 69 scale_factor_(scale_factor) {
69 } 70 }
70 71
71 DataPack::~DataPack() { 72 DataPack::~DataPack() {
72 } 73 }
73 74
74 bool DataPack::LoadFromPath(const base::FilePath& path) { 75 bool DataPack::LoadFromPath(const base::FilePath& path) {
75 mmap_.reset(new file_util::MemoryMappedFile); 76 mmap_.reset(new base::MemoryMappedFile);
76 if (!mmap_->Initialize(path)) { 77 if (!mmap_->Initialize(path)) {
77 DLOG(ERROR) << "Failed to mmap datapack"; 78 DLOG(ERROR) << "Failed to mmap datapack";
78 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED, 79 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED,
79 LOAD_ERRORS_COUNT); 80 LOAD_ERRORS_COUNT);
80 mmap_.reset(); 81 mmap_.reset();
81 return false; 82 return false;
82 } 83 }
83 return LoadImpl(); 84 return LoadImpl();
84 } 85 }
85 86
86 bool DataPack::LoadFromFile(base::PlatformFile file) { 87 bool DataPack::LoadFromFile(base::PlatformFile file) {
87 mmap_.reset(new file_util::MemoryMappedFile); 88 mmap_.reset(new base::MemoryMappedFile);
88 if (!mmap_->Initialize(file)) { 89 if (!mmap_->Initialize(file)) {
89 DLOG(ERROR) << "Failed to mmap datapack"; 90 DLOG(ERROR) << "Failed to mmap datapack";
90 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED_FROM_FILE, 91 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED_FROM_FILE,
91 LOAD_ERRORS_COUNT); 92 LOAD_ERRORS_COUNT);
92 mmap_.reset(); 93 mmap_.reset();
93 return false; 94 return false;
94 } 95 }
95 return LoadImpl(); 96 return LoadImpl();
96 } 97 }
97 98
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return false; 297 return false;
297 } 298 }
298 } 299 }
299 300
300 file_util::CloseFile(file); 301 file_util::CloseFile(file);
301 302
302 return true; 303 return true;
303 } 304 }
304 305
305 } // namespace ui 306 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | webkit/plugins/npapi/plugin_list_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698