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

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

Issue 1968993002: Compressing .pak resources with new option: "type=GZIPPABLE_BINDATA" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating comments Created 4 years, 7 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
Index: ui/base/resource/resource_bundle.h
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index f58b1269fc8c9f2e3e18f786dff23ab19b5e28ac..af8f97b2d0198c60c707dbf07120e91fd24787c5 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -50,6 +50,8 @@ class UI_BASE_EXPORT ResourceBundle {
static const int kMediumFontDelta = 3;
static const int kLargeFontDelta = 8;
+ static constexpr const char* CUSTOM_GZIP_HEADER = "\xff\x1f\x8b";
+
// Legacy font style mappings. TODO(tapted): Phase these out in favour of
// client code providing their own constant with the desired font size delta.
enum FontStyle {
@@ -216,25 +218,33 @@ class UI_BASE_EXPORT ResourceBundle {
gfx::Image& GetNativeImageNamed(int resource_id);
// Loads the raw bytes of a scale independent data resource.
+ // Will perform gzip decompression on any resource which has
+ // ResourceBundle::CUSTOM_GZIP_HEADER as its first 3 bytes.
agrieve 2016/05/27 17:40:00 nit: can you also add here that you can enable thi
smaier 2016/05/27 17:48:47 Done.
base::RefCountedMemory* LoadDataResourceBytes(int resource_id) const;
// Loads the raw bytes of a data resource nearest the scale factor
// |scale_factor| into |bytes|, without doing any processing or
// interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE
// for scale independent image resources (such as wallpaper).
+ // Will perform gzip decompression on any resource which has
+ // ResourceBundle::CUSTOM_GZIP_HEADER as its first 3 bytes.
// Returns NULL if we fail to read the resource.
base::RefCountedMemory* LoadDataResourceBytesForScale(
int resource_id,
ScaleFactor scale_factor) const;
// Return the contents of a scale independent resource in a
- // StringPiece given the resource id
+ // StringPiece given the resource id.
+ // NOTE: CHECKs to ensure this is not called on a resource which has
+ // ResourceBundle::CUSTOM_GZIP_HEADER as its first 3 bytes.
base::StringPiece GetRawDataResource(int resource_id) const;
// Return the contents of a resource in a StringPiece given the resource id
// nearest the scale factor |scale_factor|.
// Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources
// (such as wallpaper).
+ // NOTE: CHECKs to ensure this is not called on a resource which has
+ // ResourceBundle::CUSTOM_GZIP_HEADER as its first 3 bytes.
base::StringPiece GetRawDataResourceForScale(int resource_id,
ScaleFactor scale_factor) const;
@@ -382,6 +392,15 @@ class UI_BASE_EXPORT ResourceBundle {
SkBitmap* bitmap,
bool* fell_back_to_1x) const;
+ // Loads the raw bytes of a data resource nearest the scale factor
+ // |scale_factor| into |bytes|, without doing any processing or
+ // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE
+ // for scale independent image resources (such as wallpaper).
+ // Returns NULL if we fail to read the resource.
+ base::StringPiece DoGetRawDataResourceForScale(
+ int resource_id,
+ ScaleFactor scale_factor) const;
+
// Returns true if missing scaled resources should be visually indicated when
// drawing the fallback (e.g., by tinting the image).
static bool ShouldHighlightMissingScaledResources();

Powered by Google App Engine
This is Rietveld 408576698