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

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

Issue 1153143002: Fix race condition in WebstoreInstallHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 948d9954134fe6b38718be0cd34471830942c63a..4ad14e9ce3526cd8c3cde1ebbae64dcde5eef8ea 100644
--- a/chrome/browser/extensions/webstore_install_helper.cc
+++ b/chrome/browser/extensions/webstore_install_helper.cc
@@ -51,6 +51,15 @@ WebstoreInstallHelper::~WebstoreInstallHelper() {}
void WebstoreInstallHelper::Start() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&WebstoreInstallHelper::StartWorkOnIOThread, this));
+}
+
+void WebstoreInstallHelper::StartWorkOnIOThread() {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
if (icon_url_.is_empty()) {
icon_decode_complete_ = true;
} else {
@@ -64,14 +73,6 @@ void WebstoreInstallHelper::Start() {
net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES);
}
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&WebstoreInstallHelper::StartWorkOnIOThread, this));
-}
-
-void WebstoreInstallHelper::StartWorkOnIOThread() {
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
utility_host_ = UtilityProcessHost::Create(
this, base::ThreadTaskRunnerHandle::Get().get())->AsWeakPtr();
utility_host_->SetName(l10n_util::GetStringUTF16(
@@ -95,7 +96,7 @@ bool WebstoreInstallHelper::OnMessageReceived(const IPC::Message& message) {
void WebstoreInstallHelper::OnFetchComplete(const GURL& url,
const SkBitmap* image) {
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// OnFetchComplete should only be called as icon_fetcher_ delegate to avoid
// unbalanced Release().
CHECK(icon_fetcher_.get());
@@ -108,11 +109,8 @@ void WebstoreInstallHelper::OnFetchComplete(const GURL& url,
parse_error_ = Delegate::ICON_ERROR;
}
icon_fetcher_.reset();
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&WebstoreInstallHelper::ReportResultsIfComplete, this));
- Release(); // Balanced in Start().
+ Release(); // Balanced in StartWorkOnIOThread().
+ ReportResultsIfComplete();
}
void WebstoreInstallHelper::OnJSONParseSucceeded(

Powered by Google App Engine
This is Rietveld 408576698