diff options
author | twellington <twellington@chromium.org> | 2015-03-26 08:09:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-26 15:10:31 +0000 |
commit | a71414d3412695691b873508377ae67854062fd4 (patch) | |
tree | e1d3f5f91d944aa7a63d79fe762d7e483da17b5d /chrome/utility | |
parent | 358ba325dad3cc11d1f330f652e655f38c12249b (diff) | |
download | chromium_src-a71414d3412695691b873508377ae67854062fd4.zip chromium_src-a71414d3412695691b873508377ae67854062fd4.tar.gz chromium_src-a71414d3412695691b873508377ae67854062fd4.tar.bz2 |
image_decoder has been refactored into a Leaky (accessible from multiple threads) LazyInstance (singleton), that uses one utility process running in batch mode to decode all images.
This CL fixes a performance problem with scrolling in bookmarks on Android.
Previously we were using a new image_decoder and therefore a
new utility process for each image we wanted to decode. Now we
use one shared image_decoder that has one utility process running in batch mode for decoding all images.
BUG=451201
Review URL: https://codereview.chromium.org/931993002
Cr-Commit-Position: refs/heads/master@{#322383}
Diffstat (limited to 'chrome/utility')
-rw-r--r-- | chrome/utility/chrome_content_utility_client.cc | 25 | ||||
-rw-r--r-- | chrome/utility/chrome_content_utility_client.h | 10 | ||||
-rw-r--r-- | chrome/utility/extensions/extensions_handler.cc | 18 | ||||
-rw-r--r-- | chrome/utility/extensions/extensions_handler.h | 1 |
4 files changed, 22 insertions, 32 deletions
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc index 5d5dbfd..1c79cdf 100644 --- a/chrome/utility/chrome_content_utility_client.cc +++ b/chrome/utility/chrome_content_utility_client.cc @@ -238,20 +238,25 @@ SkBitmap ChromeContentUtilityClient::DecodeImage( // static void ChromeContentUtilityClient::DecodeImageAndSend( - const std::vector<unsigned char>& encoded_data, bool shrink_to_fit){ + const std::vector<unsigned char>& encoded_data, + bool shrink_to_fit, + int request_id) { SkBitmap decoded_image = DecodeImage(encoded_data, shrink_to_fit); if (decoded_image.empty()) { - Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); + Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); } else { - Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(decoded_image)); + Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(decoded_image, + request_id)); } ReleaseProcessIfNeeded(); } void ChromeContentUtilityClient::OnDecodeImage( - const std::vector<unsigned char>& encoded_data, bool shrink_to_fit) { - DecodeImageAndSend(encoded_data, shrink_to_fit); + const std::vector<unsigned char>& encoded_data, + bool shrink_to_fit, + int request_id) { + DecodeImageAndSend(encoded_data, shrink_to_fit, request_id); } #if defined(OS_CHROMEOS) @@ -303,19 +308,21 @@ void ChromeContentUtilityClient::OnDetectSeccompSupport() { #endif // defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( - const std::vector<unsigned char>& encoded_data) { + const std::vector<unsigned char>& encoded_data, + int request_id) { // Our robust jpeg decoding is using IJG libjpeg. if (gfx::JPEGCodec::JpegLibraryVariant() == gfx::JPEGCodec::IJG_LIBJPEG && !encoded_data.empty()) { scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode( &encoded_data[0], encoded_data.size())); if (!decoded_image.get() || decoded_image->empty()) { - Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); + Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); } else { - Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image)); + Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image, + request_id)); } } else { - Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); + Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); } ReleaseProcessIfNeeded(); } diff --git a/chrome/utility/chrome_content_utility_client.h b/chrome/utility/chrome_content_utility_client.h index f2eee64..8134fe4 100644 --- a/chrome/utility/chrome_content_utility_client.h +++ b/chrome/utility/chrome_content_utility_client.h @@ -36,7 +36,8 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient { static SkBitmap DecodeImage(const std::vector<unsigned char>& encoded_data, bool shrink_to_fit); static void DecodeImageAndSend(const std::vector<unsigned char>& encoded_data, - bool shrink_to_fit); + bool shrink_to_fit, + int request_id); static void set_max_ipc_message_size_for_test(int64_t max_message_size) { max_ipc_message_size_ = max_message_size; @@ -46,9 +47,10 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient { // IPC message handlers. void OnUnpackWebResource(const std::string& resource_data); void OnDecodeImage(const std::vector<unsigned char>& encoded_data, - bool shrink_to_fit); - void OnRobustJPEGDecodeImage( - const std::vector<unsigned char>& encoded_data); + bool shrink_to_fit, + int request_id); + void OnRobustJPEGDecodeImage(const std::vector<unsigned char>& encoded_data, + int request_id); #if defined(OS_CHROMEOS) void OnCreateZipFile(const base::FilePath& src_dir, diff --git a/chrome/utility/extensions/extensions_handler.cc b/chrome/utility/extensions/extensions_handler.cc index 72930f5..ca6972d 100644 --- a/chrome/utility/extensions/extensions_handler.cc +++ b/chrome/utility/extensions/extensions_handler.cc @@ -80,7 +80,6 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) #if defined(OS_WIN) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, @@ -123,23 +122,6 @@ void ExtensionsHandler::OnUnzipToDir(const base::FilePath& zip_path, ReleaseProcessIfNeeded(); } -void ExtensionsHandler::OnDecodeImageBase64( - const std::string& encoded_string) { - std::string decoded_string; - - if (!base::Base64Decode(encoded_string, &decoded_string)) { - Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); - return; - } - - std::vector<unsigned char> decoded_vector(decoded_string.size()); - for (size_t i = 0; i < decoded_string.size(); ++i) { - decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]); - } - - ChromeContentUtilityClient::DecodeImageAndSend(decoded_vector, false); -} - void ExtensionsHandler::OnCheckMediaFile( int64 milliseconds_of_decoding, const IPC::PlatformFileForTransit& media_file) { diff --git a/chrome/utility/extensions/extensions_handler.h b/chrome/utility/extensions/extensions_handler.h index aeae769..272fee7 100644 --- a/chrome/utility/extensions/extensions_handler.h +++ b/chrome/utility/extensions/extensions_handler.h @@ -36,7 +36,6 @@ class ExtensionsHandler : public UtilityMessageHandler { private: // IPC message handlers. void OnUnzipToDir(const base::FilePath& zip_path, const base::FilePath& dir); - void OnDecodeImageBase64(const std::string& encoded_data); void OnCheckMediaFile(int64 milliseconds_of_decoding, const IPC::PlatformFileForTransit& media_file); |