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

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

Issue 2641973003: Implement server-suggested update check backoff (Closed)
Patch Set: Created 3 years, 10 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
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 <map>
10 #include <memory> 10 #include <memory>
(...skipping 21 matching lines...) Expand all
32 class WebApk; 32 class WebApk;
33 } 33 }
34 34
35 class WebApkIconHasher; 35 class WebApkIconHasher;
36 36
37 // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the 37 // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the
38 // server, download it, and install it. The native WebApkInstaller owns the 38 // server, download it, and install it. The native WebApkInstaller owns the
39 // Java WebApkInstaller counterpart. 39 // Java WebApkInstaller counterpart.
40 class WebApkInstaller : public net::URLFetcherDelegate { 40 class WebApkInstaller : public net::URLFetcherDelegate {
41 public: 41 public:
42 // This struct is passed to an FinishCallback when a WebAPK install or update
43 // is finished. TODO.
44 struct FinishCallbackData {
pkotwicz 2017/02/10 02:51:22 Can we change FinishCallback to have three argumen
Xi Han 2017/02/13 22:56:15 Done.
45 // The package name of the WebAPK installed or updated.
46 const std::string& webapk_package_name;
47
48 // True if Chrome received a "don't update so frequently" directive from the
49 // WebAPK server.
50 const bool infrequent_updates;
51 };
52
42 // Called when the creation/updating of a WebAPK is finished or failed. 53 // Called when the creation/updating of a WebAPK is finished or failed.
43 // Parameters: 54 // Parameters:
44 // - whether the process succeeds. 55 // - whether the process succeeds.
45 // - the package name of the WebAPK. 56 // - the package name of the WebAPK.
46 using FinishCallback = base::Callback<void(bool, const std::string&)>; 57 using FinishCallback = base::Callback<void(bool, const FinishCallbackData&)>;
47 58
48 ~WebApkInstaller() override; 59 ~WebApkInstaller() override;
49 60
50 // Creates a self-owned WebApkInstaller instance and talks to the Chrome 61 // Creates a self-owned WebApkInstaller instance and talks to the Chrome
51 // WebAPK server to generate a WebAPK on the server and to Google Play to 62 // WebAPK server to generate a WebAPK on the server and to Google Play to
52 // install the downloaded WebAPK. Calls |callback| once the install completed 63 // install the downloaded WebAPK. Calls |callback| once the install completed
53 // or failed. 64 // or failed.
54 static void InstallAsync(content::BrowserContext* context, 65 static void InstallAsync(content::BrowserContext* context,
55 const ShortcutInfo& shortcut_info, 66 const ShortcutInfo& shortcut_info,
56 const SkBitmap& shortcut_icon, 67 const SkBitmap& shortcut_icon,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // The number of milliseconds to wait for the WebAPK download URL from the 274 // The number of milliseconds to wait for the WebAPK download URL from the
264 // WebAPK server. 275 // WebAPK server.
265 int webapk_download_url_timeout_ms_; 276 int webapk_download_url_timeout_ms_;
266 277
267 // The number of milliseconds to wait for the WebAPK download to complete. 278 // The number of milliseconds to wait for the WebAPK download to complete.
268 int download_timeout_ms_; 279 int download_timeout_ms_;
269 280
270 // WebAPK package name. 281 // WebAPK package name.
271 std::string webapk_package_; 282 std::string webapk_package_;
272 283
284 // Whether to update an WebAPK less frequently.
pkotwicz 2017/02/10 02:51:22 How about: "Whether the server wants the WebAPK to
Xi Han 2017/02/13 22:56:14 Done.
285 bool infrequent_updates_;
286
273 // WebAPK version code. 287 // WebAPK version code.
274 int webapk_version_; 288 int webapk_version_;
275 289
276 // Indicates whether the installer is for installing or updating a WebAPK. 290 // Indicates whether the installer is for installing or updating a WebAPK.
277 TaskType task_type_; 291 TaskType task_type_;
278 292
279 // Points to the Java Object. 293 // Points to the Java Object.
280 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 294 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
281 295
282 // Used to get |weak_ptr_|. 296 // Used to get |weak_ptr_|.
283 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; 297 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_;
284 298
285 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); 299 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
286 }; 300 };
287 301
288 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 302 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698