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

Unified Diff: chrome/browser/dom_ui/fileicon_source.cc

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: chrome/browser/dom_ui/fileicon_source.cc
diff --git a/chrome/browser/dom_ui/fileicon_source.cc b/chrome/browser/dom_ui/fileicon_source.cc
index 247f8c536b0eb90d131633e2047edcbc512aa956..7a423d066fb2ec06071de3861c98aa62f912daa7 100644
--- a/chrome/browser/dom_ui/fileicon_source.cc
+++ b/chrome/browser/dom_ui/fileicon_source.cc
@@ -39,10 +39,9 @@ void FileIconSource::StartDataRequest(const std::string& path,
SkBitmap* icon = im->LookupIcon(escaped_filepath, IconLoader::NORMAL);
if (icon) {
- std::vector<unsigned char> png_bytes;
- gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &png_bytes);
+ scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes;
+ gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data);
- scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes(png_bytes);
SendResponse(request_id, icon_data);
} else {
// Icon was not in cache, go fetch it slowly.
@@ -62,10 +61,9 @@ void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle,
int request_id = cancelable_consumer_.GetClientData(im, handle);
if (icon) {
- std::vector<unsigned char> png_bytes;
- gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &png_bytes);
+ scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes;
+ gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data);
- scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes(png_bytes);
SendResponse(request_id, icon_data);
} else {
// TODO(glen): send a dummy icon.

Powered by Google App Engine
This is Rietveld 408576698