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

Unified Diff: app/resource_bundle_mac.mm

Issue 288005: First fix to minimize copying of image data. (Closed)
Patch Set: Modify gyp Created 11 years, 2 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: app/resource_bundle_mac.mm
diff --git a/app/resource_bundle_mac.mm b/app/resource_bundle_mac.mm
index 6696617cd1c5b66aa2fe8b979072949a17b2348f..b3066026b8f809db4e20fab5fbdfc99c82f0726f 100644
--- a/app/resource_bundle_mac.mm
+++ b/app/resource_bundle_mac.mm
@@ -71,18 +71,16 @@ void ResourceBundle::LoadThemeResources() {
DCHECK(theme_data_) << "failed to load theme.pak";
}
-/* static */
-bool ResourceBundle::LoadResourceBytes(DataHandle module, int resource_id,
- std::vector<unsigned char>* bytes) {
+// static
+RefCountedStaticMemory* ResourceBundle::LoadResourceBytes(
+ DataHandle module, int resource_id) {
DCHECK(module);
- base::StringPiece data;
- if (!module->Get(resource_id, &data))
- return false;
-
- bytes->resize(data.length());
- memcpy(&(bytes->front()), data.data(), data.length());
+ base::StringPiece bytes;
+ if (!module->Get(resource_id, &bytes))
+ return NULL;
- return true;
+ return new RefCountedStaticMemory(
+ reinterpret_cast<const unsigned char*>(bytes.data()), bytes.length());
}
base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) {

Powered by Google App Engine
This is Rietveld 408576698