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

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

Issue 931993002: Make image_decoder a Leaky LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor webstore_install_helper to use ImageDecoder, remove DecodeBase64 support Created 5 years, 9 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/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..e56cddc3c51115578ea4564a2645c91e527f531e 100644
--- a/chrome/browser/extensions/webstore_install_helper.cc
+++ b/chrome/browser/extensions/webstore_install_helper.cc
@@ -32,13 +32,11 @@ WebstoreInstallHelper::WebstoreInstallHelper(
Delegate* delegate,
const std::string& id,
const std::string& manifest,
- const std::string& icon_data,
const GURL& icon_url,
net::URLRequestContextGetter* context_getter)
: delegate_(delegate),
id_(id),
manifest_(manifest),
- icon_base64_data_(icon_data),
icon_url_(icon_url),
context_getter_(context_getter),
icon_decode_complete_(false),
@@ -49,9 +47,8 @@ WebstoreInstallHelper::~WebstoreInstallHelper() {}
void WebstoreInstallHelper::Start() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- CHECK(icon_base64_data_.empty() || icon_url_.is_empty());
- if (icon_base64_data_.empty() && icon_url_.is_empty())
+ if (icon_url_.is_empty())
icon_decode_complete_ = true;
BrowserThread::PostTask(
@@ -78,10 +75,6 @@ void WebstoreInstallHelper::StartWorkOnIOThread() {
this, base::MessageLoopProxy::current().get())->AsWeakPtr();
utility_host_->StartBatchMode();
- if (!icon_base64_data_.empty())
- utility_host_->Send(
- new ChromeUtilityMsg_DecodeImageBase64(icon_base64_data_));
-
utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_));
}
@@ -94,8 +87,7 @@ void WebstoreInstallHelper::OnURLFetchComplete(
if (!source->GetStatus().is_success() ||
response_code / 100 == 4 || response_code / 100 == 5) {
BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
+ BrowserThread::IO, FROM_HERE,
base::Bind(&WebstoreInstallHelper::OnDecodeImageFailed, this));
} else {
std::string response_data;
@@ -113,19 +105,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));
+ ImageDecoder::GetInstance()->Start(
+ this, std::string(fetched_icon_data_.begin(), fetched_icon_data_.end()),
asargent_no_longer_on_chrome 2015/03/12 21:40:08 I think we should just change fetched_icon_data_ t
Theresa 2015/03/12 22:19:10 Good catch :) Instead of doing that, I removed thi
+ ImageDecoder::DEFAULT_CODEC,
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::IO),
+ false);
}
-
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,9 +125,7 @@ bool WebstoreInstallHelper::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-
-void WebstoreInstallHelper::OnDecodeImageSucceeded(
- const SkBitmap& decoded_image) {
+void WebstoreInstallHelper::OnImageDecoded(const SkBitmap& decoded_image) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
icon_ = decoded_image;
icon_decode_complete_ = true;

Powered by Google App Engine
This is Rietveld 408576698