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

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: 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 be63f3336b527ed22685a4e02160717cb112cacb..017d9ff1ffba0da8d5b55f1093481c6a874c0c5b 100644
--- a/chrome/browser/android/webapk/webapk_installer.h
+++ b/chrome/browser/android/webapk/webapk_installer.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_BUILDER_H_
-#define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_BUILDER_H_
+#ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
+#define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
#include <jni.h>
#include <memory>
@@ -25,6 +25,12 @@ namespace content {
class BrowserContext;
}
+namespace google {
+namespace protobuf {
+class MessageLite;
+}
+}
+
namespace net {
class URLFetcher;
class URLRequestContextGetter;
@@ -32,17 +38,25 @@ class URLRequestContextGetter;
namespace webapk {
class CreateWebApkRequest;
+class UpdateWebApkRequest;
+class WebApk;
+class WebApkResponse;
pkotwicz 2016/08/03 19:09:34 This forward declaration does not seem necessary a
Xi Han 2016/08/03 20:22:46 Except WebApk, other classes are removed.
}
// Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the
// 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.
using FinishCallback = base::Callback<void(bool)>;
WebApkInstaller(content::BrowserContext* browser_context,
- const ShortcutInfo& shortcut_info,
- const SkBitmap& shorcut_icon);
+ const ShortcutInfo& shortcut_info,
+ const SkBitmap& shorcut_icon);
+
~WebApkInstaller() override;
// Register JNI methods.
@@ -53,6 +67,14 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// request to install the WebAPK is sent to Google Play.
void InstallAsync(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(const FinishCallback& callback,
+ const std::string& webapk_package,
+ int version);
+
private:
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
@@ -60,10 +82,18 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// Initializes |request_context_getter_| on UI thread.
void InitializeRequestContextGetterOnUIThread();
- // 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.
+ void SendRequest(
+ std::unique_ptr<::google::protobuf::MessageLite> request_proto);
+
// Called with the URL of generated WebAPK and the package name that the
// WebAPK should be installed at.
void OnGotWebApkDownloadUrl(const std::string& download_url,
@@ -77,8 +107,8 @@ class WebApkInstaller : public net::URLFetcherDelegate {
const std::string& package_name,
FileDownloader::Result result);
- // Populates webapk::CreateWebApkRequest and returns it.
- std::unique_ptr<webapk::CreateWebApkRequest> BuildCreateWebApkRequest();
+ // Populate the |webapk| field of a request.
+ void PopulateWebApkProto(webapk::WebApk* webapk);
// Called when the request to the WebAPK server times out or when the WebAPK
// download times out.
@@ -118,10 +148,16 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// WebAPK server URL.
GURL server_url_;
+ // WebAPK package name.
+ std::string webapk_package_;
+
+ // WebAPK version code.
+ int version_;
+
// Used to get |weak_ptr_| on the IO thread.
base::WeakPtrFactory<WebApkInstaller> io_weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
};
-#endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_BUILDER_H_
+#endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_

Powered by Google App Engine
This is Rietveld 408576698