Index: extensions/browser/content_hash_fetcher.cc |
diff --git a/extensions/browser/content_hash_fetcher.cc b/extensions/browser/content_hash_fetcher.cc |
index b637ce903652ab28c274d43fc92696f60718b2d2..b7e0214d7af26c8322e1a56fe0f76d6958df303c 100644 |
--- a/extensions/browser/content_hash_fetcher.cc |
+++ b/extensions/browser/content_hash_fetcher.cc |
@@ -141,6 +141,7 @@ class ContentHashFetcherJob |
content::BrowserThread::ID creation_thread_; |
// Used for fetching content signatures. |
+ // Created and destroyed on |creation_thread_|. |
std::unique_ptr<net::URLFetcher> url_fetcher_; |
// The key used to validate verified_contents.json. |
@@ -218,6 +219,13 @@ bool ContentHashFetcherJob::IsCancelled() { |
} |
ContentHashFetcherJob::~ContentHashFetcherJob() { |
+ // Destroy |url_fetcher_| on correct thread. |
+ // It was possible for it to be deleted on blocking pool from |
+ // MaybeCreateHashes(). See https://crbug.com/702300 for details. |
+ if (url_fetcher_ && !content::BrowserThread::CurrentlyOn(creation_thread_)) { |
+ content::BrowserThread::DeleteSoon(creation_thread_, FROM_HERE, |
+ url_fetcher_.release()); |
+ } |
} |
bool ContentHashFetcherJob::LoadVerifiedContents(const base::FilePath& path) { |
@@ -292,11 +300,14 @@ void ContentHashFetcherJob::OnURLFetchComplete(const net::URLFetcher* source) { |
VLOG(1) << "URLFetchComplete for " << extension_id_ |
<< " is_success:" << url_fetcher_->GetStatus().is_success() << " " |
<< fetch_url_.possibly_invalid_spec(); |
+ // Delete |url_fetcher_| once we no longer need it. |
lazyboy
2017/04/19 00:19:33
As we discussed on vc, this is the deletion. Howev
|
+ std::unique_ptr<net::URLFetcher> url_fetcher = std::move(url_fetcher_); |
+ |
if (IsCancelled()) |
return; |
std::unique_ptr<std::string> response(new std::string); |
- if (!url_fetcher_->GetStatus().is_success() || |
- !url_fetcher_->GetResponseAsString(response.get())) { |
+ if (!url_fetcher->GetStatus().is_success() || |
+ !url_fetcher->GetResponseAsString(response.get())) { |
DoneFetchingVerifiedContents(false); |
return; |
} |