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

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

Issue 2184913005: Add calls to the server to request WebAPK updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and pkotwicz@'s comments. 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
Index: chrome/browser/android/webapk/webapk_installer.h
diff --git a/chrome/browser/android/webapk/webapk_installer.h b/chrome/browser/android/webapk/webapk_installer.h
index 0aac26e96a522b7b08c106179e9d5f8f8a42e361..b5541744ec79c97f1bb7c882bf84c432179c800c 100644
--- a/chrome/browser/android/webapk/webapk_installer.h
+++ b/chrome/browser/android/webapk/webapk_installer.h
@@ -15,6 +15,7 @@
#include "base/timer/timer.h"
#include "chrome/browser/android/shortcut_info.h"
#include "chrome/browser/net/file_downloader.h"
+#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -26,11 +27,6 @@ namespace content {
class BrowserContext;
}
-namespace net {
-class URLFetcher;
-class URLRequestContextGetter;
-}
-
namespace webapk {
class WebApk;
}
@@ -39,10 +35,15 @@ class WebApk;
// server, download it, and install it.
class WebApkInstaller : public net::URLFetcherDelegate {
public:
+ // Called when either a request of creating or updating WebAPK has been sent
+ // or the creation process of the WebAPK on the server side fails.
+ // Parameters:
+ // - whether the request succeeds.
pkotwicz 2016/08/09 14:35:43 How about: "Called when either a request for creat
Xi Han 2016/08/11 19:01:15 Done.
using FinishCallback = base::Callback<void(bool)>;
WebApkInstaller(const ShortcutInfo& shortcut_info,
const SkBitmap& shorcut_icon);
+
~WebApkInstaller() override;
// Talks to the Chrome WebAPK server to generate a WebAPK on the server and to
@@ -56,6 +57,15 @@ class WebApkInstaller : public net::URLFetcherDelegate {
net::URLRequestContextGetter* request_context_getter,
const FinishCallback& callback);
+ // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
+ // the Google Play server to download and install the generated WebAPK. Calls
+ // |callback| after the request to download and install the WebAPK is sent to
+ // the Google Play server.
+ void UpdateAsync(content::BrowserContext* browser_context,
+ const FinishCallback& callback,
+ const std::string& webapk_package,
+ int version);
+
// Sets the timeout for the server requests.
void SetTimeoutMs(int timeout_ms);
@@ -70,6 +80,12 @@ class WebApkInstaller : public net::URLFetcherDelegate {
const base::android::ScopedJavaLocalRef<jstring>& java_package_name);
private:
+ enum TaskType {
+ UNDEFINED,
+ INSTALL,
+ UPDATE,
+ };
+
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
@@ -77,10 +93,20 @@ class WebApkInstaller : public net::URLFetcherDelegate {
void InitializeRequestContextGetterOnUIThread(
content::BrowserContext* browser_context);
- // Sends request to WebAPK server to create WebAPK. During a successful
- // request the WebAPK server responds with the URL of the generated WebAPK.
+ // Sends request to WebAPK server to create WebAPK.
void SendCreateWebApkRequest();
+ // Sends request to WebAPK server to update a WebAPK.
+ void SendUpdateWebApkRequest();
+
+ // Sends a request to WebAPK server. During a successful request the
+ // WebAPK server responds with a URL to send to Google Play to
+ // download and install the generated WebAPK.
pkotwicz 2016/08/09 14:35:43 Nit: The comment is incorrect. WebApkInstaller doe
Xi Han 2016/08/11 19:01:15 Done.
+ void SendRequest(
+ std::unique_ptr<webapk::WebApk> request_proto,
+ net::URLFetcher::RequestType request_type,
+ const GURL& server_url);
+
// Called with the URL of generated WebAPK and the package name that the
// WebAPK should be installed at.
void OnGotWebApkDownloadUrl(const GURL& download_url,
@@ -141,6 +167,16 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// The number of milliseconds to wait for the WebAPK download to complete.
int download_timeout_ms_;
+ // WebAPK package name.
+ std::string webapk_package_;
+
+ // WebAPK version code.
+ int webapk_version_;
+
+ // A flag to indicate whether the installer is for installing or updating a
+ // WebAPK.
pkotwicz 2016/08/09 14:35:43 How about: "Indicates whether the installer ..."
Xi Han 2016/08/11 19:01:15 Done.
+ TaskType task_type_;
+
// Used to get |weak_ptr_| on the IO thread.
base::WeakPtrFactory<WebApkInstaller> io_weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698