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

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

Issue 2641973003: Implement server-suggested update check backoff (Closed)
Patch Set: Nits. Created 3 years, 9 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_INSTALL_SERVICE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ 6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/android/webapk/webapk_installer.h"
15 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace content { 19 namespace content {
19 class BrowserContext; 20 class BrowserContext;
20 } 21 }
21 22
22 struct ShortcutInfo; 23 struct ShortcutInfo;
23 class SkBitmap; 24 class SkBitmap;
24 25
25 // Service which talks to Chrome WebAPK server and Google Play to generate a 26 // Service which talks to Chrome WebAPK server and Google Play to generate a
26 // WebAPK on the server, download it, and install it. 27 // WebAPK on the server, download it, and install it.
27 class WebApkInstallService : public KeyedService { 28 class WebApkInstallService : public KeyedService {
28 public: 29 public:
29 // Called when the creation/updating of a WebAPK is finished or failed. 30 using FinishCallback = WebApkInstaller::FinishCallback;
30 // Parameters:
31 // - whether the process succeeds.
32 // - the package name of the WebAPK.
33 using FinishCallback = base::Callback<void(bool, const std::string&)>;
34 31
35 static WebApkInstallService* Get(content::BrowserContext* browser_context); 32 static WebApkInstallService* Get(content::BrowserContext* browser_context);
36 33
37 explicit WebApkInstallService(content::BrowserContext* browser_context); 34 explicit WebApkInstallService(content::BrowserContext* browser_context);
38 ~WebApkInstallService() override; 35 ~WebApkInstallService() override;
39 36
40 // Returns whether an install for |web_manifest_url| is in progress. 37 // Returns whether an install for |web_manifest_url| is in progress.
41 bool IsInstallInProgress(const GURL& web_manifest_url); 38 bool IsInstallInProgress(const GURL& web_manifest_url);
42 39
43 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to 40 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to
(...skipping 13 matching lines...) Expand all
57 int webapk_version, 54 int webapk_version,
58 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, 55 const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
59 bool is_manifest_stale, 56 bool is_manifest_stale,
60 const FinishCallback& finish_callback); 57 const FinishCallback& finish_callback);
61 58
62 private: 59 private:
63 // Called once the install/update completed or failed. 60 // Called once the install/update completed or failed.
64 void OnFinishedInstall(const GURL& web_manifest_url, 61 void OnFinishedInstall(const GURL& web_manifest_url,
65 const FinishCallback& finish_callback, 62 const FinishCallback& finish_callback,
66 bool success, 63 bool success,
64 bool relax_updates,
67 const std::string& webapk_package_name); 65 const std::string& webapk_package_name);
68 66
69 content::BrowserContext* browser_context_; 67 content::BrowserContext* browser_context_;
70 68
71 // In progress installs. 69 // In progress installs.
72 std::set<GURL> installs_; 70 std::set<GURL> installs_;
73 71
74 // Used to get |weak_ptr_|. 72 // Used to get |weak_ptr_|.
75 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_; 73 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_;
76 74
77 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService); 75 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService);
78 }; 76 };
79 77
80 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ 78 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698