| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // Writes a pack file containing |resources| to |path|. If there are any | 45 // Writes a pack file containing |resources| to |path|. If there are any |
| 46 // text resources to be written, their encoding must already agree to the | 46 // text resources to be written, their encoding must already agree to the |
| 47 // |textEncodingType| specified. If no text resources are present, please | 47 // |textEncodingType| specified. If no text resources are present, please |
| 48 // indicate BINARY. | 48 // indicate BINARY. |
| 49 static bool WritePack(const base::FilePath& path, | 49 static bool WritePack(const base::FilePath& path, |
| 50 const std::map<uint16, base::StringPiece>& resources, | 50 const std::map<uint16, base::StringPiece>& resources, |
| 51 TextEncodingType textEncodingType); | 51 TextEncodingType textEncodingType); |
| 52 | 52 |
| 53 // ResourceHandle implementation: | 53 // ResourceHandle implementation: |
| 54 virtual bool HasResource(uint16 resource_id) const OVERRIDE; | 54 virtual bool HasResource(uint16 resource_id) const override; |
| 55 virtual bool GetStringPiece(uint16 resource_id, | 55 virtual bool GetStringPiece(uint16 resource_id, |
| 56 base::StringPiece* data) const OVERRIDE; | 56 base::StringPiece* data) const override; |
| 57 virtual base::RefCountedStaticMemory* GetStaticMemory( | 57 virtual base::RefCountedStaticMemory* GetStaticMemory( |
| 58 uint16 resource_id) const OVERRIDE; | 58 uint16 resource_id) const override; |
| 59 virtual TextEncodingType GetTextEncodingType() const OVERRIDE; | 59 virtual TextEncodingType GetTextEncodingType() const override; |
| 60 virtual ui::ScaleFactor GetScaleFactor() const OVERRIDE; | 60 virtual ui::ScaleFactor GetScaleFactor() const override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Does the actual loading of a pack file. Called by Load and LoadFromFile. | 63 // Does the actual loading of a pack file. Called by Load and LoadFromFile. |
| 64 bool LoadImpl(); | 64 bool LoadImpl(); |
| 65 | 65 |
| 66 // The memory-mapped data. | 66 // The memory-mapped data. |
| 67 scoped_ptr<base::MemoryMappedFile> mmap_; | 67 scoped_ptr<base::MemoryMappedFile> mmap_; |
| 68 | 68 |
| 69 // Number of resources in the data. | 69 // Number of resources in the data. |
| 70 size_t resource_count_; | 70 size_t resource_count_; |
| 71 | 71 |
| 72 // Type of encoding for text resources. | 72 // Type of encoding for text resources. |
| 73 TextEncodingType text_encoding_type_; | 73 TextEncodingType text_encoding_type_; |
| 74 | 74 |
| 75 // The scale of the image in this resource pack relative to images in the 1x | 75 // The scale of the image in this resource pack relative to images in the 1x |
| 76 // resource pak. | 76 // resource pak. |
| 77 ui::ScaleFactor scale_factor_; | 77 ui::ScaleFactor scale_factor_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(DataPack); | 79 DISALLOW_COPY_AND_ASSIGN(DataPack); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace ui | 82 } // namespace ui |
| 83 | 83 |
| 84 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ | 84 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ |
| OLD | NEW |