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

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: Created 4 years, 5 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..e17a4cfbfa0d672941a5eccb9177e7bce189b580 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_
pkotwicz 2016/08/03 01:07:06 😲 Thanks for catching this!
Xi Han 2016/08/03 17:30:05 I used a refactoring tool which is super cool to m
pkotwicz 2016/08/03 19:09:34 Awesome! 😀 I will try it out some time
#include <jni.h>
#include <memory>
@@ -32,17 +32,30 @@ class URLRequestContextGetter;
namespace webapk {
class CreateWebApkRequest;
+class UpdateWebApkRequest;
+class WebApkResponse;
}
// 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:
- using FinishCallback = base::Callback<void(bool)>;
+ // 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.
+ // - the package name of the WebAPK, empty for a request of creating a WebAPK.
+ using FinishCallback = base::Callback<void(bool, const std::string&)>;
WebApkInstaller(content::BrowserContext* browser_context,
- const ShortcutInfo& shortcut_info,
- const SkBitmap& shorcut_icon);
+ const ShortcutInfo& shortcut_info,
+ const SkBitmap& shorcut_icon);
+
+ WebApkInstaller(content::BrowserContext* browser_context,
+ const ShortcutInfo& shortcut_info,
+ const SkBitmap& shortcut_icon,
+ const std::string& WebApkPackageName);
pkotwicz 2016/08/03 01:07:06 Nit: |webapk_package_name| and |webapk_version_cod
Xi Han 2016/08/03 17:30:05 Done.
+
~WebApkInstaller() override;
// Register JNI methods.
@@ -53,17 +66,36 @@ 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);
+
private:
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
- // Initializes |request_context_getter_| on UI thread.
- void InitializeRequestContextGetterOnUIThread();
+ // Initializes |request_context_getter_| on UI thread when requests to create
+ // a WebAPK.
+ void InitializeCreateRequestContextGetterOnUIThread();
- // Sends request to WebAPK server to create WebAPK. During a successful
- // request the WebAPK server responds with the URL of the generated WebAPK.
+ // Initializes |request_context_getter_| on UI thread when requests to update
+ // a WebAPK.
+ void InitializeUpdateRequestContextGetterOnUIThread();
+
+ // Sends request to WebAPK server to create WebAPK.
void SendCreateWebApkRequest();
+ // Sends request to WebAPK server to update a WebAPK.
+ void SendUpdateWebApkRequest();
+
+ // Sends a templated 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.
+ template <class RequestProto>
+ void SendRequest(std::unique_ptr<RequestProto> 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 +109,10 @@ 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 a templated request and returns it.
+ template <class RequestProto>
+ std::unique_ptr<RequestProto> BuildRequest(
+ std::unique_ptr<RequestProto> request);
// Called when the request to the WebAPK server times out or when the WebAPK
// download times out.
@@ -118,10 +152,12 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// WebAPK server URL.
GURL server_url_;
+ std::string webapk_package_;
+
// 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