| 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 // DataPack represents a read-only view onto an on-disk file that contains | 5 // DataPack represents a read-only view onto an on-disk file that contains |
| 6 // (key, value) pairs of data. It's used to store static resources like | 6 // (key, value) pairs of data. It's used to store static resources like |
| 7 // translation strings and images. | 7 // translation strings and images. |
| 8 | 8 |
| 9 #ifndef UI_BASE_RESOURCE_DATA_PACK_H_ | 9 #ifndef UI_BASE_RESOURCE_DATA_PACK_H_ |
| 10 #define UI_BASE_RESOURCE_DATA_PACK_H_ | 10 #define UI_BASE_RESOURCE_DATA_PACK_H_ |
| 11 | 11 |
| 12 #include <stddef.h> | 12 #include <stddef.h> |
| 13 #include <stdint.h> | 13 #include <stdint.h> |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 #include <memory> |
| 16 | 17 |
| 17 #include "base/files/file.h" | 18 #include "base/files/file.h" |
| 18 #include "base/files/memory_mapped_file.h" | 19 #include "base/files/memory_mapped_file.h" |
| 19 #include "base/macros.h" | 20 #include "base/macros.h" |
| 20 #include "base/memory/scoped_ptr.h" | |
| 21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "base/strings/string_piece.h" | 22 #include "base/strings/string_piece.h" |
| 23 #include "ui/base/resource/data_pack_export.h" | 23 #include "ui/base/resource/data_pack_export.h" |
| 24 #include "ui/base/resource/resource_handle.h" | 24 #include "ui/base/resource/resource_handle.h" |
| 25 | 25 |
| 26 namespace base { | 26 namespace base { |
| 27 class FilePath; | 27 class FilePath; |
| 28 class RefCountedStaticMemory; | 28 class RefCountedStaticMemory; |
| 29 } | 29 } |
| 30 | 30 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Checks to see if any resource in this DataPack already exists in the list | 72 // Checks to see if any resource in this DataPack already exists in the list |
| 73 // of resources. | 73 // of resources. |
| 74 void CheckForDuplicateResources(const ScopedVector<ResourceHandle>& packs); | 74 void CheckForDuplicateResources(const ScopedVector<ResourceHandle>& packs); |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Does the actual loading of a pack file. Called by Load and LoadFromFile. | 78 // Does the actual loading of a pack file. Called by Load and LoadFromFile. |
| 79 bool LoadImpl(); | 79 bool LoadImpl(); |
| 80 | 80 |
| 81 // The memory-mapped data. | 81 // The memory-mapped data. |
| 82 scoped_ptr<base::MemoryMappedFile> mmap_; | 82 std::unique_ptr<base::MemoryMappedFile> mmap_; |
| 83 | 83 |
| 84 // Number of resources in the data. | 84 // Number of resources in the data. |
| 85 size_t resource_count_; | 85 size_t resource_count_; |
| 86 | 86 |
| 87 // Type of encoding for text resources. | 87 // Type of encoding for text resources. |
| 88 TextEncodingType text_encoding_type_; | 88 TextEncodingType text_encoding_type_; |
| 89 | 89 |
| 90 // The scale of the image in this resource pack relative to images in the 1x | 90 // The scale of the image in this resource pack relative to images in the 1x |
| 91 // resource pak. | 91 // resource pak. |
| 92 ui::ScaleFactor scale_factor_; | 92 ui::ScaleFactor scale_factor_; |
| 93 | 93 |
| 94 // Set to true if the only resources contained within this DataPack are | 94 // Set to true if the only resources contained within this DataPack are |
| 95 // material design image assets. | 95 // material design image assets. |
| 96 bool has_only_material_design_assets_; | 96 bool has_only_material_design_assets_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(DataPack); | 98 DISALLOW_COPY_AND_ASSIGN(DataPack); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace ui | 101 } // namespace ui |
| 102 | 102 |
| 103 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ | 103 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ |
| OLD | NEW |