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

Side by Side Diff: ui/base/resource/resource_bundle.h

Issue 1996723002: Switch ResourceBundle LoadDataResourceBytes to return RefCountedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing iOS trybots 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 unified diff | Download patch
OLDNEW
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 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 13 matching lines...) Expand all
24 #include "ui/base/ui_base_export.h" 24 #include "ui/base/ui_base_export.h"
25 #include "ui/gfx/font_list.h" 25 #include "ui/gfx/font_list.h"
26 #include "ui/gfx/image/image.h" 26 #include "ui/gfx/image/image.h"
27 #include "ui/gfx/native_widget_types.h" 27 #include "ui/gfx/native_widget_types.h"
28 28
29 class SkBitmap; 29 class SkBitmap;
30 30
31 namespace base { 31 namespace base {
32 class File; 32 class File;
33 class Lock; 33 class Lock;
34 class RefCountedStaticMemory; 34 class RefCountedMemory;
35 } 35 }
36 36
37 namespace ui { 37 namespace ui {
38 38
39 class DataPack; 39 class DataPack;
40 class ResourceHandle; 40 class ResourceHandle;
41 41
42 // ResourceBundle is a central facility to load images and other resources, 42 // ResourceBundle is a central facility to load images and other resources,
43 // such as theme graphics. Every resource is loaded only once. 43 // such as theme graphics. Every resource is loaded only once.
44 class UI_BASE_EXPORT ResourceBundle { 44 class UI_BASE_EXPORT ResourceBundle {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const std::string& locale) = 0; 89 const std::string& locale) = 0;
90 90
91 // Return an image resource or an empty value to attempt retrieval of the 91 // Return an image resource or an empty value to attempt retrieval of the
92 // default resource. 92 // default resource.
93 virtual gfx::Image GetImageNamed(int resource_id) = 0; 93 virtual gfx::Image GetImageNamed(int resource_id) = 0;
94 94
95 // Return an image resource or an empty value to attempt retrieval of the 95 // Return an image resource or an empty value to attempt retrieval of the
96 // default resource. 96 // default resource.
97 virtual gfx::Image GetNativeImageNamed(int resource_id) = 0; 97 virtual gfx::Image GetNativeImageNamed(int resource_id) = 0;
98 98
99 // Return a static memory resource or NULL to attempt retrieval of the 99 // Return a static memory resource or NULL to attempt retrieval of the
sadrul 2016/05/24 22:36:59 Update the doc.
smaier 2016/05/25 13:29:14 Done.
100 // default resource. 100 // default resource.
101 virtual base::RefCountedStaticMemory* LoadDataResourceBytes( 101 virtual base::RefCountedMemory* LoadDataResourceBytes(
102 int resource_id, 102 int resource_id,
103 ScaleFactor scale_factor) = 0; 103 ScaleFactor scale_factor) = 0;
104 104
105 // Retrieve a raw data resource. Return true if a resource was provided or 105 // Retrieve a raw data resource. Return true if a resource was provided or
106 // false to attempt retrieval of the default resource. 106 // false to attempt retrieval of the default resource.
107 virtual bool GetRawDataResource(int resource_id, 107 virtual bool GetRawDataResource(int resource_id,
108 ScaleFactor scale_factor, 108 ScaleFactor scale_factor,
109 base::StringPiece* value) = 0; 109 base::StringPiece* value) = 0;
110 110
111 // Retrieve a localized string. Return true if a string was provided or 111 // Retrieve a localized string. Return true if a string was provided or
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Similar to GetImageNamed, but rather than loading the image in Skia format, 209 // Similar to GetImageNamed, but rather than loading the image in Skia format,
210 // it will load in the native platform type. This can avoid conversion from 210 // it will load in the native platform type. This can avoid conversion from
211 // one image type to another. ResourceBundle owns the result. 211 // one image type to another. ResourceBundle owns the result.
212 // 212 //
213 // Note that if the same resource has already been loaded in GetImageNamed(), 213 // Note that if the same resource has already been loaded in GetImageNamed(),
214 // gfx::Image will perform a conversion, rather than using the native image 214 // gfx::Image will perform a conversion, rather than using the native image
215 // loading code of ResourceBundle. 215 // loading code of ResourceBundle.
216 gfx::Image& GetNativeImageNamed(int resource_id); 216 gfx::Image& GetNativeImageNamed(int resource_id);
217 217
218 // Loads the raw bytes of a scale independent data resource. 218 // Loads the raw bytes of a scale independent data resource.
219 base::RefCountedStaticMemory* LoadDataResourceBytes(int resource_id) const; 219 base::RefCountedMemory* LoadDataResourceBytes(int resource_id) const;
220 220
221 // Loads the raw bytes of a data resource nearest the scale factor 221 // Loads the raw bytes of a data resource nearest the scale factor
222 // |scale_factor| into |bytes|, without doing any processing or 222 // |scale_factor| into |bytes|, without doing any processing or
223 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE 223 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE
224 // for scale independent image resources (such as wallpaper). 224 // for scale independent image resources (such as wallpaper).
225 // Returns NULL if we fail to read the resource. 225 // Returns NULL if we fail to read the resource.
226 base::RefCountedStaticMemory* LoadDataResourceBytesForScale( 226 base::RefCountedMemory* LoadDataResourceBytesForScale(
227 int resource_id, 227 int resource_id,
228 ScaleFactor scale_factor) const; 228 ScaleFactor scale_factor) const;
229 229
230 // Return the contents of a scale independent resource in a 230 // Return the contents of a scale independent resource in a
231 // StringPiece given the resource id 231 // StringPiece given the resource id
232 base::StringPiece GetRawDataResource(int resource_id) const; 232 base::StringPiece GetRawDataResource(int resource_id) const;
233 233
234 // Return the contents of a resource in a StringPiece given the resource id 234 // Return the contents of a resource in a StringPiece given the resource id
235 // nearest the scale factor |scale_factor|. 235 // nearest the scale factor |scale_factor|.
236 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources 236 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 444 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
445 }; 445 };
446 446
447 } // namespace ui 447 } // namespace ui
448 448
449 // TODO(beng): Someday, maybe, get rid of this. 449 // TODO(beng): Someday, maybe, get rid of this.
450 using ui::ResourceBundle; 450 using ui::ResourceBundle;
451 451
452 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 452 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698