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

Unified Diff: chrome/browser/image_decoder.cc

Issue 2177833003: Avoid unnecessary copies in ImageDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change ArcWallpaperHandler to use new API. Created 4 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/image_decoder.h ('k') | chrome/browser/image_decoder_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/image_decoder.cc
diff --git a/chrome/browser/image_decoder.cc b/chrome/browser/image_decoder.cc
index f09bd87be187a661b04f201bc71fa03f503ea920..a1380707aa737d343f1d508a30e200628c2f5060 100644
--- a/chrome/browser/image_decoder.cc
+++ b/chrome/browser/image_decoder.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/image_decoder.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
@@ -70,21 +72,39 @@ ImageDecoder::ImageRequest::~ImageRequest() {
// static
void ImageDecoder::Start(ImageRequest* image_request,
+ std::vector<uint8_t> image_data) {
+ StartWithOptions(image_request, std::move(image_data), DEFAULT_CODEC, false);
+}
+
+// static
+void ImageDecoder::Start(ImageRequest* image_request,
const std::string& image_data) {
- StartWithOptions(image_request, image_data, DEFAULT_CODEC, false);
+ Start(image_request,
+ std::vector<uint8_t>(image_data.begin(), image_data.end()));
}
// static
void ImageDecoder::StartWithOptions(ImageRequest* image_request,
- const std::string& image_data,
+ std::vector<uint8_t> image_data,
ImageCodec image_codec,
bool shrink_to_fit) {
- g_decoder.Pointer()->StartWithOptionsImpl(image_request, image_data,
+ g_decoder.Pointer()->StartWithOptionsImpl(image_request,
+ std::move(image_data),
image_codec, shrink_to_fit);
}
+// static
+void ImageDecoder::StartWithOptions(ImageRequest* image_request,
+ const std::string& image_data,
+ ImageCodec image_codec,
+ bool shrink_to_fit) {
+ StartWithOptions(image_request,
+ std::vector<uint8_t>(image_data.begin(), image_data.end()),
+ image_codec, shrink_to_fit);
+}
+
void ImageDecoder::StartWithOptionsImpl(ImageRequest* image_request,
- const std::string& image_data,
+ std::vector<uint8_t> image_data,
ImageCodec image_codec,
bool shrink_to_fit) {
DCHECK(image_request);
@@ -102,7 +122,7 @@ void ImageDecoder::StartWithOptionsImpl(ImageRequest* image_request,
base::Bind(
&ImageDecoder::DecodeImageInSandbox,
g_decoder.Pointer(), request_id,
- std::vector<unsigned char>(image_data.begin(), image_data.end()),
+ base::Passed(std::move(image_data)),
image_codec, shrink_to_fit));
}
@@ -114,7 +134,7 @@ void ImageDecoder::Cancel(ImageRequest* image_request) {
void ImageDecoder::DecodeImageInSandbox(
int request_id,
- const std::vector<unsigned char>& image_data,
+ std::vector<uint8_t> image_data,
ImageCodec image_codec,
bool shrink_to_fit) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -154,7 +174,7 @@ void ImageDecoder::DecodeImageInSandbox(
mojo_codec = mojom::ImageCodec::ROBUST_PNG;
#endif // defined(OS_CHROMEOS)
decoder_->DecodeImage(
- mojo::Array<uint8_t>::From(image_data),
+ mojo::Array<uint8_t>(std::move(image_data)),
mojo_codec,
shrink_to_fit,
base::Bind(&OnDecodeImageDone,
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | chrome/browser/image_decoder_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698