| Index: chrome/browser/android/webapk/webapk_icon_hasher.cc
|
| diff --git a/chrome/browser/android/webapk/webapk_icon_hasher.cc b/chrome/browser/android/webapk/webapk_icon_hasher.cc
|
| index 2a1a4133f1ef3ee1ce3ccbb7bea2b35a9fb421be..b7356225f0e50f2f24521883e0c1063d866cc0fb 100644
|
| --- a/chrome/browser/android/webapk/webapk_icon_hasher.cc
|
| +++ b/chrome/browser/android/webapk/webapk_icon_hasher.cc
|
| @@ -44,6 +44,17 @@ WebApkIconHasher::WebApkIconHasher(
|
|
|
| WebApkIconHasher::~WebApkIconHasher() {}
|
|
|
| +// static
|
| +void WebApkIconHasher::DownloadAndComputeMurmur2Hash(
|
| + net::URLRequestContextGetter* request_context_getter,
|
| + const GURL& icon_url,
|
| + const Murmur2HashCallback& callback) {
|
| + // The icon hasher will delete itself when it is done.
|
| + WebApkIconHasher* webapk_icon_hasher =
|
| + new WebApkIconHasher(request_context_getter, icon_url, callback);
|
| + webapk_icon_hasher->DownloadAndComputeMurmur2Hash();
|
| +}
|
| +
|
| void WebApkIconHasher::DownloadAndComputeMurmur2Hash() {
|
| if (!icon_url_.is_valid()) {
|
| base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| @@ -80,6 +91,7 @@ void WebApkIconHasher::OnURLFetchComplete(const net::URLFetcher* source) {
|
| if (!source->GetStatus().is_success() ||
|
| source->GetResponseCode() != net::HTTP_OK) {
|
| callback_.Run("");
|
| + delete this;
|
| return;
|
| }
|
|
|
| @@ -90,6 +102,7 @@ void WebApkIconHasher::OnURLFetchComplete(const net::URLFetcher* source) {
|
| std::string raw_image_data;
|
| source->GetResponseAsString(&raw_image_data);
|
| callback_.Run(ComputeMurmur2Hash(raw_image_data));
|
| + delete this;
|
| }
|
|
|
| void WebApkIconHasher::OnDownloadTimedOut() {
|
| @@ -97,4 +110,5 @@ void WebApkIconHasher::OnDownloadTimedOut() {
|
|
|
| base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| base::Bind(callback_, ""));
|
| + delete this;
|
| }
|
|
|