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

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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 | « chrome/browser/browser_signin.cc ('k') | chrome/browser/favicon/favicon_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index c546adfc351de50d09d9b4f9b081f80c81eb8c43..f7d2deac5dd3bc254f9a70a8cbcdc357f15d0984 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -9,6 +9,7 @@
#include "base/base64.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -1264,7 +1265,7 @@ void CaptureVisibleTabFunction::Observe(int type,
// and call SendResponse().
void CaptureVisibleTabFunction::SendResultFromBitmap(
const SkBitmap& screen_capture) {
- scoped_refptr<RefCountedBytes> image_data(new RefCountedBytes);
+ std::vector<unsigned char> data;
SkAutoLockPixels screen_capture_lock(screen_capture);
bool encoded = false;
std::string mime_type;
@@ -1277,14 +1278,14 @@ void CaptureVisibleTabFunction::SendResultFromBitmap(
screen_capture.height(),
static_cast<int>(screen_capture.rowBytes()),
image_quality_,
- &image_data->data);
+ &data);
mime_type = keys::kMimeTypeJpeg;
break;
case FORMAT_PNG:
encoded = gfx::PNGCodec::EncodeBGRASkBitmap(
screen_capture,
true, // Discard transparency.
- &image_data->data);
+ &data);
mime_type = keys::kMimeTypePng;
break;
default:
@@ -1298,11 +1299,8 @@ void CaptureVisibleTabFunction::SendResultFromBitmap(
}
std::string base64_result;
- std::string stream_as_string;
- stream_as_string.resize(image_data->data.size());
- memcpy(&stream_as_string[0],
- reinterpret_cast<const char*>(&image_data->data[0]),
- image_data->data.size());
+ base::StringPiece stream_as_string(
+ reinterpret_cast<const char*>(vector_as_array(&data)), data.size());
base::Base64Encode(stream_as_string, &base64_result);
base64_result.insert(0, base::StringPrintf("data:%s;base64,",
« no previous file with comments | « chrome/browser/browser_signin.cc ('k') | chrome/browser/favicon/favicon_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698