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

Unified Diff: chrome/browser/android/webapk/webapk_icon_hasher.h

Issue 2231843003: Take Murmur2 hash of untransformed icon when creating WebAPK part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_builder_impl2_hash Created 4 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_icon_hasher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..8fb7e2ed0db288840b85f1554dde5a41bd2dfa6a
--- /dev/null
+++ b/chrome/browser/android/webapk/webapk_icon_hasher.h
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_ICON_HASHER_H_
+#define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_ICON_HASHER_H_
+
+#include <memory>
+#include <string>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+}
+
+class GURL;
+
+// Downloads an icon and takes a Murmur2 hash of the downloaded image.
+class WebApkIconHasher : public net::URLFetcherDelegate {
+ public:
+ using Murmur2HashCallback =
+ base::Callback<void(const std::string& /* icon_murmur2_hash */)>;
+
+ WebApkIconHasher();
+ ~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 (e.g. 404 HTTP error code).
+ void DownloadAndComputeMurmur2Hash(
+ net::URLRequestContextGetter* request_context_getter,
+ const GURL& icon_url,
+ const Murmur2HashCallback& callback);
+
+ private:
+ // net::URLFetcherDelegate:
+ void OnURLFetchComplete(const net::URLFetcher* source) override;
+
+ // Fetches the image.
+ std::unique_ptr<net::URLFetcher> url_fetcher_;
+
+ // Called with the image hash.
+ Murmur2HashCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebApkIconHasher);
+};
+
+#endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_ICON_HASHER_H_
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_icon_hasher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698