Chromium Code Reviews| Index: ui/base/resource/data_pack.h |
| diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h |
| index 46578186f23161a22b61e0924ad6a84d82d95c1b..8c089f1a3f7c9b4ded44d2a4f2ed88b0cb67f9d2 100644 |
| --- a/ui/base/resource/data_pack.h |
| +++ b/ui/base/resource/data_pack.h |
| @@ -31,6 +31,14 @@ class RefCountedStaticMemory; |
| namespace ui { |
| enum ScaleFactor : int; |
| +class DataSource { |
|
sadrul
2016/05/19 18:28:26
I suppose this class could move into DataPack, sin
altimin
2016/05/19 19:23:30
Done.
|
| + public: |
| + virtual ~DataSource(){}; |
| + |
| + virtual size_t Length() const = 0; |
| + virtual const uint8_t* Data() const = 0; |
| +}; |
| + |
| class UI_DATA_PACK_EXPORT DataPack : public ResourceHandle { |
| public: |
| explicit DataPack(ui::ScaleFactor scale_factor); |
| @@ -50,6 +58,9 @@ class UI_DATA_PACK_EXPORT DataPack : public ResourceHandle { |
| bool LoadFromFileRegion(base::File file, |
| const base::MemoryMappedFile::Region& region); |
| + // Loads a pack file from |buffer|, returning false on error. |
| + bool LoadFromBuffer(base::StringPiece buffer); |
| + |
| // Writes a pack file containing |resources| to |path|. If there are any |
| // text resources to be written, their encoding must already agree to the |
| // |textEncodingType| specified. If no text resources are present, please |
| @@ -75,11 +86,11 @@ class UI_DATA_PACK_EXPORT DataPack : public ResourceHandle { |
| #endif |
| private: |
| - // Does the actual loading of a pack file. Called by Load and LoadFromFile. |
| + // Does the actual loading of a pack file. |
| + // Called by Load and LoadFromFile and LoadFromBuffer. |
| bool LoadImpl(); |
| - // The memory-mapped data. |
| - std::unique_ptr<base::MemoryMappedFile> mmap_; |
| + std::unique_ptr<DataSource> data_source_; |
| // Number of resources in the data. |
| size_t resource_count_; |