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

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

Issue 2932593005: Simplify WebAPK proto building code (Closed)
Patch Set: Merge branch 'master' into background_updates000 Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_installer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const FinishCallback& callback); 80 const FinishCallback& callback);
81 81
82 // Sets the timeout for the server requests. 82 // Sets the timeout for the server requests.
83 void SetTimeoutMs(int timeout_ms); 83 void SetTimeoutMs(int timeout_ms);
84 84
85 // Called once the installation is complete or failed. 85 // Called once the installation is complete or failed.
86 void OnInstallFinished(JNIEnv* env, 86 void OnInstallFinished(JNIEnv* env,
87 const base::android::JavaParamRef<jobject>& obj, 87 const base::android::JavaParamRef<jobject>& obj,
88 jint result); 88 jint result);
89 89
90 // Creates a WebApk install or update request. 90 // Asynchronously builds the WebAPK proto on a background thread for an update
91 // Should be used only for testing. 91 // or install request. Runs |callback| on the calling thread when complete.
92 void BuildWebApkProtoInBackgroundForTesting( 92 static void BuildProto(
93 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, 93 const ShortcutInfo& shortcut_info,
94 const SkBitmap& primary_icon,
95 const SkBitmap& badge_icon,
96 const std::string& package_name,
97 const std::string& version,
94 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, 98 const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
95 bool is_manifest_stale); 99 bool is_manifest_stale,
100 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback);
96 101
97 // Registers JNI hooks. 102 // Registers JNI hooks.
98 static bool Register(JNIEnv* env); 103 static bool Register(JNIEnv* env);
99 104
100 protected: 105 protected:
101 WebApkInstaller(content::BrowserContext* browser_context, 106 WebApkInstaller(content::BrowserContext* browser_context,
102 const ShortcutInfo& shortcut_info, 107 const ShortcutInfo& shortcut_info,
103 const SkBitmap& primary_icon, 108 const SkBitmap& primary_icon,
104 const SkBitmap& badge_icon); 109 const SkBitmap& badge_icon);
105 110
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Called with the computed Murmur2 hash for the primary icon. 148 // Called with the computed Murmur2 hash for the primary icon.
144 void OnGotPrimaryIconMurmur2Hash(const std::string& primary_icon_hash); 149 void OnGotPrimaryIconMurmur2Hash(const std::string& primary_icon_hash);
145 150
146 // Called with the computed Murmur2 hash for the badge icon, and 151 // Called with the computed Murmur2 hash for the badge icon, and
147 // |did_fetch_badge_icon| to indicate whether there was an attempt to fetch 152 // |did_fetch_badge_icon| to indicate whether there was an attempt to fetch
148 // badge icon. 153 // badge icon.
149 void OnGotBadgeIconMurmur2Hash(bool did_fetch_badge_icon, 154 void OnGotBadgeIconMurmur2Hash(bool did_fetch_badge_icon,
150 const std::string& primary_icon_hash, 155 const std::string& primary_icon_hash,
151 const std::string& badge_icon_hash); 156 const std::string& badge_icon_hash);
152 157
153 // Sends request to WebAPK server to create WebAPK. During a successful
154 // request the WebAPK server responds with the URL of the generated WebAPK.
155 // |webapk| is the proto to send to the WebAPK server.
156 void SendCreateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto);
157
158 // Sends request to WebAPK server to update a WebAPK. During a successful
159 // request the WebAPK server responds with the URL of the generated WebAPK.
160 // |webapk| is the proto to send to the WebAPK server.
161 void SendUpdateWebApkRequest(int webapk_version,
162 std::unique_ptr<webapk::WebApk> webapk_proto);
163
164 // Sends a request to WebAPK server to create/update WebAPK. During a 158 // Sends a request to WebAPK server to create/update WebAPK. During a
165 // successful request the WebAPK server responds with the URL of the generated 159 // successful request the WebAPK server responds with the URL of the generated
166 // WebAPK. 160 // WebAPK.
167 void SendRequest(std::unique_ptr<webapk::WebApk> request_proto, 161 void SendRequest(std::unique_ptr<webapk::WebApk> request_proto);
168 const GURL& server_url);
169 162
170 net::URLRequestContextGetter* request_context_getter_; 163 net::URLRequestContextGetter* request_context_getter_;
171 164
172 // Sends HTTP request to WebAPK server. 165 // Sends HTTP request to WebAPK server.
173 std::unique_ptr<net::URLFetcher> url_fetcher_; 166 std::unique_ptr<net::URLFetcher> url_fetcher_;
174 167
175 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the 168 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the
176 // download takes too long. 169 // download takes too long.
177 base::OneShotTimer timer_; 170 base::OneShotTimer timer_;
178 171
(...skipping 17 matching lines...) Expand all
196 189
197 // The number of milliseconds to wait for the WebAPK server to respond. 190 // The number of milliseconds to wait for the WebAPK server to respond.
198 int webapk_server_timeout_ms_; 191 int webapk_server_timeout_ms_;
199 192
200 // WebAPK package name. 193 // WebAPK package name.
201 std::string webapk_package_; 194 std::string webapk_package_;
202 195
203 // Whether the server wants the WebAPK to request updates less frequently. 196 // Whether the server wants the WebAPK to request updates less frequently.
204 bool relax_updates_; 197 bool relax_updates_;
205 198
206
207 // Indicates whether the installer is for installing or updating a WebAPK. 199 // Indicates whether the installer is for installing or updating a WebAPK.
208 TaskType task_type_; 200 TaskType task_type_;
209 201
210 // Points to the Java Object. 202 // Points to the Java Object.
211 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 203 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
212 204
213 // Used to get |weak_ptr_|. 205 // Used to get |weak_ptr_|.
214 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; 206 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_;
215 207
216 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); 208 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
217 }; 209 };
218 210
219 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 211 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698