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

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

Issue 2687163002: Add logs for WebAPK server failures (Closed)
Patch Set: Merge branch 'master' into better_logs Created 3 years, 10 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 | 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 GetBackgroundTaskRunner().get(), FROM_HERE, 393 GetBackgroundTaskRunner().get(), FROM_HERE,
394 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, 394 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_,
395 icon_url_to_murmur2_hash, is_manifest_stale), 395 icon_url_to_murmur2_hash, is_manifest_stale),
396 base::Bind(&WebApkInstaller::SendUpdateWebApkRequest, 396 base::Bind(&WebApkInstaller::SendUpdateWebApkRequest,
397 weak_ptr_factory_.GetWeakPtr())); 397 weak_ptr_factory_.GetWeakPtr()));
398 } 398 }
399 399
400 void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) { 400 void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) {
401 timer_.Stop(); 401 timer_.Stop();
402 402
403 if (!source->GetStatus().is_success() || 403 int response_code = source->GetResponseCode();
404 source->GetResponseCode() != net::HTTP_OK) { 404 std::string response_string;
405 source->GetResponseAsString(&response_string);
406
407 if (!source->GetStatus().is_success() || response_code != net::HTTP_OK) {
408 LOG(WARNING) << base::StringPrintf(
409 "WebAPK server returned response code %d %s.", response_code,
410 response_string.c_str());
pkotwicz 2017/02/09 21:23:56 The response string won't look too pretty right no
Xi Han 2017/02/09 22:02:14 I don't think we should put the entire response_st
pkotwicz 2017/02/09 22:54:22 Done.
405 OnFailure(); 411 OnFailure();
406 return; 412 return;
407 } 413 }
408 414
409 std::string response_string;
410 source->GetResponseAsString(&response_string);
411
412 std::unique_ptr<webapk::WebApkResponse> response(new webapk::WebApkResponse); 415 std::unique_ptr<webapk::WebApkResponse> response(new webapk::WebApkResponse);
413 if (!response->ParseFromString(response_string)) { 416 if (!response->ParseFromString(response_string)) {
417 LOG(WARNING) << "WebAPK server did not return proto.";
414 OnFailure(); 418 OnFailure();
415 return; 419 return;
416 } 420 }
417 421
418 GURL signed_download_url(response->signed_download_url()); 422 GURL signed_download_url(response->signed_download_url());
419 if (!signed_download_url.is_valid() || response->package_name().empty()) { 423 if (!signed_download_url.is_valid() || response->package_name().empty()) {
424 LOG(WARNING) << "WebAPK server returned incomplete proto.";
420 OnFailure(); 425 OnFailure();
421 return; 426 return;
422 } 427 }
423 428
424 if (CanUseGooglePlayInstallService()) { 429 if (CanUseGooglePlayInstallService()) {
425 int version = 1; 430 int version = 1;
426 base::StringToInt(response->version(), &version); 431 base::StringToInt(response->version(), &version);
427 // TODO(hanxi): crbug.com/688759. Remove the return value of 432 // TODO(hanxi): crbug.com/688759. Remove the return value of
428 // InstallOrUpdateWebApkFromGooglePlay(), since a callback will be called 433 // InstallOrUpdateWebApkFromGooglePlay(), since a callback will be called
429 // asynchronously after the install or upidate has either failed or 434 // asynchronously after the install or upidate has either failed or
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 624
620 void WebApkInstaller::OnSuccess() { 625 void WebApkInstaller::OnSuccess() {
621 finish_callback_.Run(true, webapk_package_); 626 finish_callback_.Run(true, webapk_package_);
622 delete this; 627 delete this;
623 } 628 }
624 629
625 void WebApkInstaller::OnFailure() { 630 void WebApkInstaller::OnFailure() {
626 finish_callback_.Run(false, webapk_package_); 631 finish_callback_.Run(false, webapk_package_);
627 delete this; 632 delete this;
628 } 633 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698