Index: chrome/browser/android/webapk/webapk_icon_hasher.h |
diff --git a/chrome/browser/android/webapk/webapk_icon_hasher.h b/chrome/browser/android/webapk/webapk_icon_hasher.h |
index 4a337106990f5d977c70017b18143d053a1906c2..ff54b97738a5bb4dd1ec64c5dc1203fe00d2e1b2 100644 |
--- a/chrome/browser/android/webapk/webapk_icon_hasher.h |
+++ b/chrome/browser/android/webapk/webapk_icon_hasher.h |
@@ -25,30 +25,31 @@ class WebApkIconHasher : public net::URLFetcherDelegate { |
using Murmur2HashCallback = |
base::Callback<void(const std::string& /* icon_murmur2_hash */)>; |
+ // Creates a self-owned WebApkIconHasher instance. The instance downloads |
+ // |icon_url| and calls |callback| with the Murmur2 hash of the downloaded |
+ // image. The hash is taken over the raw image bytes (no image |
+ // encoding/decoding beforehand). |callback| is called with an empty string if |
+ // the image cannot not be downloaded in time (e.g. 404 HTTP error code). |
+ static void DownloadAndComputeMurmur2Hash( |
+ net::URLRequestContextGetter* request_context_getter, |
+ const GURL& icon_url, |
+ const Murmur2HashCallback& callback); |
+ |
+ private: |
WebApkIconHasher( |
net::URLRequestContextGetter* request_context_getter, |
const GURL& icon_url, |
const Murmur2HashCallback& callback); |
~WebApkIconHasher() override; |
- // Downloads |icon_url_|. Calls |callback_| with the Murmur2 hash of the |
- // downloaded image. The hash is taken over the raw image bytes (no image |
- // encoding/decoding beforehand). |callback_| is called with an empty string |
- // if the image cannot not be downloaded in time (e.g. 404 HTTP error code). |
- void DownloadAndComputeMurmur2Hash(); |
- |
- private: |
// net::URLFetcherDelegate: |
void OnURLFetchComplete(const net::URLFetcher* source) override; |
// Called if downloading the icon takes too long. |
void OnDownloadTimedOut(); |
- // For retrieving URLRequestContext. Owned by the caller of this class. |
- net::URLRequestContextGetter* url_request_context_getter_; |
- |
- // The icon URL. |
- GURL icon_url_; |
+ // Calls |callback_| with |icon_murmur2_hash|. Also deletes the instance. |
+ void RunCallback(const std::string& icon_murmur2_hash); |
// Called with the image hash. |
Murmur2HashCallback callback_; |