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_ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ui::ScaleFactor GetScaleFactor() const override; | 68 ui::ScaleFactor GetScaleFactor() const override; |
69 | 69 |
70 #if DCHECK_IS_ON() | 70 #if DCHECK_IS_ON() |
71 // Checks to see if any resource in this DataPack already exists in the list | 71 // Checks to see if any resource in this DataPack already exists in the list |
72 // of resources. | 72 // of resources. |
73 void CheckForDuplicateResources( | 73 void CheckForDuplicateResources( |
74 const std::vector<std::unique_ptr<ResourceHandle>>& packs); | 74 const std::vector<std::unique_ptr<ResourceHandle>>& packs); |
75 #endif | 75 #endif |
76 | 76 |
77 private: | 77 private: |
| 78 struct Entry; |
| 79 struct Alias; |
78 class DataSource; | 80 class DataSource; |
79 class BufferDataSource; | 81 class BufferDataSource; |
80 class MemoryMappedDataSource; | 82 class MemoryMappedDataSource; |
81 | 83 |
82 // Does the actual loading of a pack file. | 84 // Does the actual loading of a pack file. |
83 // Called by Load and LoadFromFile and LoadFromBuffer. | 85 // Called by Load and LoadFromFile and LoadFromBuffer. |
84 bool LoadImpl(std::unique_ptr<DataSource> data_source); | 86 bool LoadImpl(std::unique_ptr<DataSource> data_source); |
| 87 const Entry* LookupEntryById(uint16_t resource_id) const; |
85 | 88 |
86 std::unique_ptr<DataSource> data_source_; | 89 std::unique_ptr<DataSource> data_source_; |
87 | 90 |
88 // Number of resources in the data. | 91 const Entry* resource_table_; |
89 size_t resource_count_; | 92 size_t resource_count_; |
| 93 const Alias* alias_table_; |
| 94 size_t alias_count_; |
90 | 95 |
91 // Type of encoding for text resources. | 96 // Type of encoding for text resources. |
92 TextEncodingType text_encoding_type_; | 97 TextEncodingType text_encoding_type_; |
93 | 98 |
94 // The scale of the image in this resource pack relative to images in the 1x | 99 // The scale of the image in this resource pack relative to images in the 1x |
95 // resource pak. | 100 // resource pak. |
96 ui::ScaleFactor scale_factor_; | 101 ui::ScaleFactor scale_factor_; |
97 | 102 |
98 DISALLOW_COPY_AND_ASSIGN(DataPack); | 103 DISALLOW_COPY_AND_ASSIGN(DataPack); |
99 }; | 104 }; |
100 | 105 |
101 } // namespace ui | 106 } // namespace ui |
102 | 107 |
103 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ | 108 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ |
OLD | NEW |