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

Side by Side Diff: chrome/browser/android/webapk/webapk_installer.h

Issue 2528073002: Add a flag in WebAPK's proto when the Web App Manifest is no longer available. (Closed)
Patch Set: Try to fix the compile error. Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <map>
9 #include <memory> 10 #include <memory>
10 11
11 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "chrome/browser/android/shortcut_info.h" 17 #include "chrome/browser/android/shortcut_info.h"
17 #include "chrome/browser/net/file_downloader.h" 18 #include "chrome/browser/net/file_downloader.h"
18 #include "net/url_request/url_fetcher.h" 19 #include "net/url_request/url_fetcher.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const FinishCallback& finish_callback); 57 const FinishCallback& finish_callback);
57 58
58 // Same as InstallAsync() but uses the passed in |request_context_getter|. 59 // Same as InstallAsync() but uses the passed in |request_context_getter|.
59 void InstallAsyncWithURLRequestContextGetter( 60 void InstallAsyncWithURLRequestContextGetter(
60 net::URLRequestContextGetter* request_context_getter, 61 net::URLRequestContextGetter* request_context_getter,
61 const FinishCallback& finish_callback); 62 const FinishCallback& finish_callback);
62 63
63 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to 64 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
64 // the Google Play server to install the downloaded WebAPK. Calls |callback| 65 // the Google Play server to install the downloaded WebAPK. Calls |callback|
65 // after the request to install the WebAPK is sent to the Google Play server. 66 // after the request to install the WebAPK is sent to the Google Play server.
66 void UpdateAsync(content::BrowserContext* browser_context, 67 void UpdateAsync(
67 const FinishCallback& callback, 68 content::BrowserContext* browser_context,
68 const std::string& icon_murmur2_hash, 69 const FinishCallback& callback,
69 const std::string& webapk_package, 70 const std::string& webapk_package,
70 int webapk_version); 71 int webapk_version,
72 bool stale_manifest,
73 const std::map<std::string, std::string>& icon_url_to_murmur2_hash_map);
71 74
72 // Same as UpdateAsync() but uses the passed in |request_context_getter|. 75 // Same as UpdateAsync() but uses the passed in |request_context_getter|.
73 void UpdateAsyncWithURLRequestContextGetter( 76 void UpdateAsyncWithURLRequestContextGetter(
74 net::URLRequestContextGetter* request_context_getter, 77 net::URLRequestContextGetter* request_context_getter,
75 const FinishCallback& callback, 78 const FinishCallback& callback,
76 const std::string& icon_murmur2_hash,
77 const std::string& webapk_package, 79 const std::string& webapk_package,
78 int webapk_version); 80 int webapk_version,
81 bool stale_manifest,
82 const std::map<std::string, std::string>& icon_url_to_murmur2_hash_map);
79 83
80 // Sets the timeout for the server requests. 84 // Sets the timeout for the server requests.
81 void SetTimeoutMs(int timeout_ms); 85 void SetTimeoutMs(int timeout_ms);
82 86
83 // Called once the installation is complete or failed. 87 // Called once the installation is complete or failed.
84 void OnInstallFinished(JNIEnv* env, 88 void OnInstallFinished(JNIEnv* env,
85 const base::android::JavaParamRef<jobject>& obj, 89 const base::android::JavaParamRef<jobject>& obj,
86 jboolean success); 90 jboolean success);
87 91
88 // Registers JNI hooks. 92 // Registers JNI hooks.
(...skipping 25 matching lines...) Expand all
114 // or update request is handled by Google Play. 118 // or update request is handled by Google Play.
115 virtual bool InstallOrUpdateWebApkFromGooglePlay( 119 virtual bool InstallOrUpdateWebApkFromGooglePlay(
116 const std::string& package_name, 120 const std::string& package_name,
117 int version, 121 int version,
118 const std::string& token); 122 const std::string& token);
119 123
120 // Called when the request to install the WebAPK is sent to Google Play. 124 // Called when the request to install the WebAPK is sent to Google Play.
121 void OnSuccess(); 125 void OnSuccess();
122 126
123 private: 127 private:
128 friend class WebApkInstallerRunner;
129
124 enum TaskType { 130 enum TaskType {
125 UNDEFINED, 131 UNDEFINED,
126 INSTALL, 132 INSTALL,
127 UPDATE, 133 UPDATE,
128 }; 134 };
129 135
130 // Create the Java object. 136 // Create the Java object.
131 void CreateJavaRef(); 137 void CreateJavaRef();
132 138
133 // net::URLFetcherDelegate: 139 // net::URLFetcherDelegate:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Called when the request to the WebAPK server times out or when the WebAPK 197 // Called when the request to the WebAPK server times out or when the WebAPK
192 // download times out. 198 // download times out.
193 void OnTimeout(); 199 void OnTimeout();
194 200
195 // Called if a WebAPK could not be created. WebApkInstaller only tracks the 201 // Called if a WebAPK could not be created. WebApkInstaller only tracks the
196 // WebAPK creation and the WebAPK download. It does not track the 202 // WebAPK creation and the WebAPK download. It does not track the
197 // WebAPK installation. OnFailure() is not called if the WebAPK could not be 203 // WebAPK installation. OnFailure() is not called if the WebAPK could not be
198 // installed. 204 // installed.
199 void OnFailure(); 205 void OnFailure();
200 206
207 // Populates webapk::WebApk and returns it.
208 // Must be called on a worker thread because it encodes an SkBitmap.
209 static std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
dominickn 2016/12/15 03:33:40 A private static method with a friended test is ve
pkotwicz 2016/12/15 04:21:52 Dominick, how do you suggest making this cleaner.
dominickn 2016/12/15 04:30:35 Friending a test class is fine - what's ugly here
210 const ShortcutInfo& shortcut_info,
211 const SkBitmap& shortcut_icon,
212 bool stale_manifest,
213 std::map<std::string, std::string> icon_url_to_murmur2_hash_map);
dominickn 2016/12/15 03:33:40 Make this a const reference.
214
201 net::URLRequestContextGetter* request_context_getter_; 215 net::URLRequestContextGetter* request_context_getter_;
202 216
203 // Sends HTTP request to WebAPK server. 217 // Sends HTTP request to WebAPK server.
204 std::unique_ptr<net::URLFetcher> url_fetcher_; 218 std::unique_ptr<net::URLFetcher> url_fetcher_;
205 219
206 // Downloads app icon and computes Murmur2 hash. 220 // Downloads app icon and computes Murmur2 hash.
207 std::unique_ptr<WebApkIconHasher> icon_hasher_; 221 std::unique_ptr<WebApkIconHasher> icon_hasher_;
208 222
209 // Downloads WebAPK. 223 // Downloads WebAPK.
210 std::unique_ptr<FileDownloader> downloader_; 224 std::unique_ptr<FileDownloader> downloader_;
211 225
212 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the 226 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the
213 // download takes too long. 227 // download takes too long.
214 base::OneShotTimer timer_; 228 base::OneShotTimer timer_;
215 229
216 // Callback to call once WebApkInstaller succeeds or fails. 230 // Callback to call once WebApkInstaller succeeds or fails.
217 FinishCallback finish_callback_; 231 FinishCallback finish_callback_;
218 232
219 // Web Manifest info. 233 // Web Manifest info.
220 const ShortcutInfo shortcut_info_; 234 const ShortcutInfo shortcut_info_;
221 235
222 // WebAPK app icon. 236 // WebAPK app icon.
223 const SkBitmap shortcut_icon_; 237 const SkBitmap shortcut_icon_;
224 238
225 // Murmur2 hash of the bitmap at the app icon URL prior to any transformations
226 // being applied to the bitmap (such as encoding/decoding the icon bitmap).
227 std::string shortcut_icon_murmur2_hash_;
228
229 // WebAPK server URL. 239 // WebAPK server URL.
230 GURL server_url_; 240 GURL server_url_;
231 241
232 // The number of milliseconds to wait for the WebAPK download URL from the 242 // The number of milliseconds to wait for the WebAPK download URL from the
233 // WebAPK server. 243 // WebAPK server.
234 int webapk_download_url_timeout_ms_; 244 int webapk_download_url_timeout_ms_;
235 245
236 // The number of milliseconds to wait for the WebAPK download to complete. 246 // The number of milliseconds to wait for the WebAPK download to complete.
237 int download_timeout_ms_; 247 int download_timeout_ms_;
238 248
239 // WebAPK package name. 249 // WebAPK package name.
240 std::string webapk_package_; 250 std::string webapk_package_;
241 251
242 // WebAPK version code. 252 // WebAPK version code.
243 int webapk_version_; 253 int webapk_version_;
244 254
245 // Indicates whether the installer is for installing or updating a WebAPK. 255 // Indicates whether the installer is for installing or updating a WebAPK.
246 TaskType task_type_; 256 TaskType task_type_;
247 257
248 // Points to the Java Object. 258 // Points to the Java Object.
249 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 259 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
250 260
251 // Used to get |weak_ptr_|. 261 // Used to get |weak_ptr_|.
252 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; 262 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_;
253 263
254 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); 264 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
255 }; 265 };
256 266
257 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 267 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/webapk/webapk.proto ('k') | chrome/browser/android/webapk/webapk_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698