OLD | NEW |
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/files/memory_mapped_file.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 bool DataPack::LoadFromFile(base::File file) { | 87 bool DataPack::LoadFromFile(base::File file) { |
88 return LoadFromFileRegion(file.Pass(), | 88 return LoadFromFileRegion(file.Pass(), |
89 base::MemoryMappedFile::Region::kWholeFile); | 89 base::MemoryMappedFile::Region::kWholeFile); |
90 } | 90 } |
91 | 91 |
92 bool DataPack::LoadFromFileRegion( | 92 bool DataPack::LoadFromFileRegion( |
93 base::File file, | 93 base::File file, |
94 const base::MemoryMappedFile::Region& region) { | 94 const base::MemoryMappedFile::Region& region) { |
95 mmap_.reset(new base::MemoryMappedFile); | 95 mmap_.reset(new base::MemoryMappedFile); |
96 if (!mmap_->Initialize(file.Pass(), region)) { | 96 if (!mmap_->Initialize(file.Pass(), region, false)) { |
97 DLOG(ERROR) << "Failed to mmap datapack"; | 97 DLOG(ERROR) << "Failed to mmap datapack"; |
98 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED_FROM_FILE, | 98 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED_FROM_FILE, |
99 LOAD_ERRORS_COUNT); | 99 LOAD_ERRORS_COUNT); |
100 mmap_.reset(); | 100 mmap_.reset(); |
101 return false; | 101 return false; |
102 } | 102 } |
103 return LoadImpl(); | 103 return LoadImpl(); |
104 } | 104 } |
105 | 105 |
106 bool DataPack::LoadImpl() { | 106 bool DataPack::LoadImpl() { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 return false; | 316 return false; |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 base::CloseFile(file); | 320 base::CloseFile(file); |
321 | 321 |
322 return true; | 322 return true; |
323 } | 323 } |
324 | 324 |
325 } // namespace ui | 325 } // namespace ui |
OLD | NEW |