| OLD | NEW |
| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 private: | 72 private: |
| 73 // net::URLFetcherDelegate: | 73 // net::URLFetcherDelegate: |
| 74 void OnURLFetchComplete(const net::URLFetcher* source) override; | 74 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 75 | 75 |
| 76 // Initializes |request_context_getter_| on UI thread. | 76 // Initializes |request_context_getter_| on UI thread. |
| 77 void InitializeRequestContextGetterOnUIThread( | 77 void InitializeRequestContextGetterOnUIThread( |
| 78 content::BrowserContext* browser_context); | 78 content::BrowserContext* browser_context); |
| 79 | 79 |
| 80 // Sends request to WebAPK server to create WebAPK. During a successful | 80 // Sends request to WebAPK server to create WebAPK. During a successful |
| 81 // request the WebAPK server responds with the URL of the generated WebAPK. | 81 // request the WebAPK server responds with the URL of the generated WebAPK. |
| 82 void SendCreateWebApkRequest(); | 82 // |webapk| is the proto to send to the WebAPK server. |
| 83 void SendCreateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto); |
| 83 | 84 |
| 84 // Called with the URL of generated WebAPK and the package name that the | 85 // Called with the URL of generated WebAPK and the package name that the |
| 85 // WebAPK should be installed at. | 86 // WebAPK should be installed at. |
| 86 void OnGotWebApkDownloadUrl(const GURL& download_url, | 87 void OnGotWebApkDownloadUrl(const GURL& download_url, |
| 87 const std::string& package_name); | 88 const std::string& package_name); |
| 88 | 89 |
| 89 // Called once the WebAPK has been downloaded. Installs the WebAPK if the | 90 // Called once the WebAPK has been downloaded. Installs the WebAPK if the |
| 90 // download was successful. | 91 // download was successful. |
| 91 // |file_path| is the file path that the WebAPK was downloaded to. | 92 // |file_path| is the file path that the WebAPK was downloaded to. |
| 92 // |package_name| is the package name that the WebAPK should be installed at. | 93 // |package_name| is the package name that the WebAPK should be installed at. |
| 93 void OnWebApkDownloaded(const base::FilePath& file_path, | 94 void OnWebApkDownloaded(const base::FilePath& file_path, |
| 94 const std::string& package_name, | 95 const std::string& package_name, |
| 95 FileDownloader::Result result); | 96 FileDownloader::Result result); |
| 96 | 97 |
| 97 // Populates webapk::WebApk and returns it. | 98 // Populates webapk::WebApk and returns it. |
| 98 std::unique_ptr<webapk::WebApk> BuildWebApkProto(); | 99 // Must be called on a worker thread. |
| 100 std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(); |
| 99 | 101 |
| 100 // Called when the request to the WebAPK server times out or when the WebAPK | 102 // Called when the request to the WebAPK server times out or when the WebAPK |
| 101 // download times out. | 103 // download times out. |
| 102 void OnTimeout(); | 104 void OnTimeout(); |
| 103 | 105 |
| 104 // Called when the request to install the WebAPK is sent to Google Play. | 106 // Called when the request to install the WebAPK is sent to Google Play. |
| 105 void OnSuccess(); | 107 void OnSuccess(); |
| 106 | 108 |
| 107 // Called if a WebAPK could not be created. WebApkInstaller only tracks the | 109 // Called if a WebAPK could not be created. WebApkInstaller only tracks the |
| 108 // WebAPK creation and the WebAPK download. It does not track the | 110 // WebAPK creation and the WebAPK download. It does not track the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 134 // WebAPK server URL. | 136 // WebAPK server URL. |
| 135 GURL server_url_; | 137 GURL server_url_; |
| 136 | 138 |
| 137 // The number of milliseconds to wait for the WebAPK download URL from the | 139 // The number of milliseconds to wait for the WebAPK download URL from the |
| 138 // WebAPK server. | 140 // WebAPK server. |
| 139 int webapk_download_url_timeout_ms_; | 141 int webapk_download_url_timeout_ms_; |
| 140 | 142 |
| 141 // The number of milliseconds to wait for the WebAPK download to complete. | 143 // The number of milliseconds to wait for the WebAPK download to complete. |
| 142 int download_timeout_ms_; | 144 int download_timeout_ms_; |
| 143 | 145 |
| 144 // Used to get |weak_ptr_| on the IO thread. | 146 // Used to get |weak_ptr_|. |
| 145 base::WeakPtrFactory<WebApkInstaller> io_weak_ptr_factory_; | 147 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; |
| 146 | 148 |
| 147 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); | 149 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); |
| 148 }; | 150 }; |
| 149 | 151 |
| 150 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 152 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
| OLD | NEW |