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

Side by Side 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 'webapk_builder_impl2_directory' 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_ICON_HASHER_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_ICON_HASHER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/time/time.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15
16 namespace net {
17 class URLFetcher;
18 class URLRequestContextGetter;
19 }
20
21 class GURL;
22
23 // Downloads an icon and takes a Murmur2 hash of the downloaded image.
24 class WebApkIconHasher : public net::URLFetcherDelegate {
25 public:
26 using Murmur2HashCallback =
27 base::Callback<void(const std::string& /* icon_murmur2_hash */)>;
28
29 WebApkIconHasher();
30 ~WebApkIconHasher() override;
31
32 // Downloads |icon_url|. Calls |callback| with the Murmur2 hash of the
33 // downloaded image. The hash is taken over the raw image bytes (no image
34 // encoding/decoding beforehand). |callback| is called with an empty string if
35 // the image cannot not be downloaded (e.g. 404 HTTP error code).
36 void DownloadAndGetMurmur2Hash(
37 net::URLRequestContextGetter* request_context_getter,
38 const GURL& icon_url,
39 const Murmur2HashCallback& callback);
40
41 private:
42 // net::URLFetcherDelegate:
43 void OnURLFetchComplete(const net::URLFetcher* source) override;
44
45 // Fetches the image.
46 std::unique_ptr<net::URLFetcher> url_fetcher_;
47
48 // Called with the image hash.
49 Murmur2HashCallback callback_;
50
51 DISALLOW_COPY_AND_ASSIGN(WebApkIconHasher);
52 };
53
54 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_ICON_HASHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_icon_hasher.cc » ('j') | chrome/browser/android/webapk/webapk_installer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698