Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: ui/base/resource/data_pack.h

Issue 1969313005: [headless] Embed pak file into binary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated years in copyright Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/util/embedded_file.h ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/data_pack.h
diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h
index 26b94c2b4b7c98670a8eb418f9c927a3c21f84bc..8bb5e5c3c8e36dea502af46e8a7704ee485892c9 100644
--- a/ui/base/resource/data_pack.h
+++ b/ui/base/resource/data_pack.h
@@ -46,6 +46,10 @@ 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.
+ // Data is not copied, |buffer| should stay alive during |DataPack| lifetime.
+ 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
@@ -70,11 +74,15 @@ class UI_DATA_PACK_EXPORT DataPack : public ResourceHandle {
#endif
private:
- // Does the actual loading of a pack file. Called by Load and LoadFromFile.
- bool LoadImpl();
+ class DataSource;
+ class BufferDataSource;
+ class MemoryMappedDataSource;
+
+ // Does the actual loading of a pack file.
+ // Called by Load and LoadFromFile and LoadFromBuffer.
+ bool LoadImpl(std::unique_ptr<DataSource> data_source);
- // 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_;
« no previous file with comments | « headless/lib/util/embedded_file.h ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698