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

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

Issue 865543002: WIP: Browser image decoding using Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and add DecodeImageBase64. Created 5 years, 11 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/extensions/webstore_install_helper.h ('k') | chrome/browser/image_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/webstore_install_helper.cc
diff --git a/chrome/browser/extensions/webstore_install_helper.cc b/chrome/browser/extensions/webstore_install_helper.cc
index 47926c6954258886f6a7ae4154a9f3638552dccc..df70163e8078bad25cffd5804ddbc25ab27b70ca 100644
--- a/chrome/browser/extensions/webstore_install_helper.cc
+++ b/chrome/browser/extensions/webstore_install_helper.cc
@@ -8,10 +8,12 @@
#include "base/bind.h"
#include "base/values.h"
+#include "chrome/browser/image_decoder.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/extensions/chrome_utility_extensions_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
+#include "content/public/common/service_registry.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
@@ -73,14 +75,22 @@ void WebstoreInstallHelper::Start() {
}
void WebstoreInstallHelper::StartWorkOnIOThread() {
+ LOG(INFO) << "WebstoreInstallHelper::StartWorkOnIOThread";
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
utility_host_ = UtilityProcessHost::Create(
this, base::MessageLoopProxy::current().get())->AsWeakPtr();
+ utility_host_->StartMojoMode();
utility_host_->StartBatchMode();
-
- if (!icon_base64_data_.empty())
- utility_host_->Send(
- new ChromeUtilityMsg_DecodeImageBase64(icon_base64_data_));
+ content::ServiceRegistry* service_registry =
+ utility_host_->GetServiceRegistry();
+ service_registry->ConnectToRemoteService(&image_decoder_);
+
+ if (!icon_base64_data_.empty()) {
+ LOG(INFO) << "DecodeImageBase64";
+ image_decoder_->DecodeImageBase64(
+ icon_base64_data_,
+ base::Bind(&WebstoreInstallHelper::OnDecodeImageDone, this));
+ }
utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_));
}
@@ -96,7 +106,10 @@ void WebstoreInstallHelper::OnURLFetchComplete(
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&WebstoreInstallHelper::OnDecodeImageFailed, this));
+ base::Bind(&WebstoreInstallHelper::OnDecodeImageDone,
+ this,
+ false,
+ nullptr));
} else {
std::string response_data;
source->GetResponseAsString(&response_data);
@@ -114,18 +127,17 @@ void WebstoreInstallHelper::OnURLFetchComplete(
void WebstoreInstallHelper::StartFetchedImageDecode() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
CHECK(utility_host_.get());
- utility_host_->Send(new ChromeUtilityMsg_DecodeImage(fetched_icon_data_,
- false));
+ image_decoder_->DecodeImage(
+ mojo::Array<uint8_t>::From(fetched_icon_data_),
+ false,
+ false,
+ base::Bind(&WebstoreInstallHelper::OnDecodeImageDone, this));
}
bool WebstoreInstallHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebstoreInstallHelper, message)
- IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Succeeded,
- OnDecodeImageSucceeded)
- IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Failed,
- OnDecodeImageFailed)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded,
OnJSONParseSucceeded)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Failed,
@@ -135,20 +147,17 @@ bool WebstoreInstallHelper::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-
-void WebstoreInstallHelper::OnDecodeImageSucceeded(
- const SkBitmap& decoded_image) {
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- icon_ = decoded_image;
- icon_decode_complete_ = true;
- ReportResultsIfComplete();
-}
-
-void WebstoreInstallHelper::OnDecodeImageFailed() {
+void WebstoreInstallHelper::OnDecodeImageDone(bool success,
+ content::ImageDataPtr image) {
+ LOG(INFO) << "WebstoreInstallHelper::OnDecodeImageDone: " << success;
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (success && image) {
+ icon_ = image.To<SkBitmap>();
+ } else {
+ error_ = kImageDecodeError;
+ parse_error_ = Delegate::ICON_ERROR;
+ }
icon_decode_complete_ = true;
- error_ = kImageDecodeError;
- parse_error_ = Delegate::ICON_ERROR;
ReportResultsIfComplete();
}
@@ -186,6 +195,7 @@ void WebstoreInstallHelper::ReportResultsIfComplete() {
if (utility_host_.get()) {
utility_host_->EndBatchMode();
utility_host_.reset();
+ image_decoder_.reset();
}
BrowserThread::PostTask(
« no previous file with comments | « chrome/browser/extensions/webstore_install_helper.h ('k') | chrome/browser/image_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698