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

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

Issue 2436833002: Send POST request to update WebAPK instead of PUT request (Closed)
Patch Set: Created 4 years, 2 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 | « chrome/browser/android/webapk/webapk_installer.h ('k') | no next file » | 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 #include "chrome/browser/android/webapk/webapk_installer.h" 5 #include "chrome/browser/android/webapk/webapk_installer.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/path_utils.h" 10 #include "base/android/path_utils.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 base::PostTaskAndReplyWithResult( 336 base::PostTaskAndReplyWithResult(
337 GetBackgroundTaskRunner().get(), FROM_HERE, 337 GetBackgroundTaskRunner().get(), FROM_HERE,
338 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, 338 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_,
339 shortcut_icon_, shortcut_icon_murmur2_hash_), 339 shortcut_icon_, shortcut_icon_murmur2_hash_),
340 base::Bind(&WebApkInstaller::SendCreateWebApkRequest, 340 base::Bind(&WebApkInstaller::SendCreateWebApkRequest,
341 weak_ptr_factory_.GetWeakPtr())); 341 weak_ptr_factory_.GetWeakPtr()));
342 } 342 }
343 343
344 void WebApkInstaller::SendCreateWebApkRequest( 344 void WebApkInstaller::SendCreateWebApkRequest(
345 std::unique_ptr<webapk::WebApk> webapk) { 345 std::unique_ptr<webapk::WebApk> webapk) {
346 SendRequest(std::move(webapk), net::URLFetcher::POST, server_url_); 346 SendRequest(std::move(webapk), server_url_);
347 } 347 }
348 348
349 void WebApkInstaller::SendUpdateWebApkRequest( 349 void WebApkInstaller::SendUpdateWebApkRequest(
350 std::unique_ptr<webapk::WebApk> webapk) { 350 std::unique_ptr<webapk::WebApk> webapk) {
351 webapk->set_package_name(webapk_package_); 351 webapk->set_package_name(webapk_package_);
352 webapk->set_version(std::to_string(webapk_version_)); 352 webapk->set_version(std::to_string(webapk_version_));
353 353
354 SendRequest(std::move(webapk), net::URLFetcher::PUT, server_url_); 354 SendRequest(std::move(webapk), server_url_);
355 } 355 }
356 356
357 void WebApkInstaller::SendRequest(std::unique_ptr<webapk::WebApk> request_proto, 357 void WebApkInstaller::SendRequest(std::unique_ptr<webapk::WebApk> request_proto,
358 net::URLFetcher::RequestType request_type,
359 const GURL& server_url) { 358 const GURL& server_url) {
360 timer_.Start( 359 timer_.Start(
361 FROM_HERE, 360 FROM_HERE,
362 base::TimeDelta::FromMilliseconds(webapk_download_url_timeout_ms_), 361 base::TimeDelta::FromMilliseconds(webapk_download_url_timeout_ms_),
363 base::Bind(&WebApkInstaller::OnTimeout, weak_ptr_factory_.GetWeakPtr())); 362 base::Bind(&WebApkInstaller::OnTimeout, weak_ptr_factory_.GetWeakPtr()));
364 363
365 url_fetcher_ = net::URLFetcher::Create(server_url, request_type, this); 364 url_fetcher_ =
365 net::URLFetcher::Create(server_url, net::URLFetcher::POST, this);
366 url_fetcher_->SetRequestContext(request_context_getter_); 366 url_fetcher_->SetRequestContext(request_context_getter_);
367 std::string serialized_request; 367 std::string serialized_request;
368 request_proto->SerializeToString(&serialized_request); 368 request_proto->SerializeToString(&serialized_request);
369 url_fetcher_->SetUploadData(kProtoMimeType, serialized_request); 369 url_fetcher_->SetUploadData(kProtoMimeType, serialized_request);
370 url_fetcher_->Start(); 370 url_fetcher_->Start();
371 } 371 }
372 372
373 void WebApkInstaller::OnGotWebApkDownloadUrl(const GURL& download_url, 373 void WebApkInstaller::OnGotWebApkDownloadUrl(const GURL& download_url,
374 const std::string& package_name) { 374 const std::string& package_name) {
375 webapk_package_ = package_name; 375 webapk_package_ = package_name;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 void WebApkInstaller::OnSuccess() { 475 void WebApkInstaller::OnSuccess() {
476 finish_callback_.Run(true, webapk_package_); 476 finish_callback_.Run(true, webapk_package_);
477 delete this; 477 delete this;
478 } 478 }
479 479
480 void WebApkInstaller::OnFailure() { 480 void WebApkInstaller::OnFailure() {
481 finish_callback_.Run(false, webapk_package_); 481 finish_callback_.Run(false, webapk_package_);
482 delete this; 482 delete this;
483 } 483 }
OLDNEW
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698