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

Side by Side Diff: components/error_page/renderer/net_error_helper_core.cc

Issue 961443002: Three way experiment for "Show saved copy" button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: histograms fix Created 5 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/error_page/renderer/net_error_helper_core.h" 5 #include "components/error_page/renderer/net_error_helper_core.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 } // namespace 371 } // namespace
372 372
373 struct NetErrorHelperCore::ErrorPageInfo { 373 struct NetErrorHelperCore::ErrorPageInfo {
374 ErrorPageInfo(blink::WebURLError error, bool was_failed_post) 374 ErrorPageInfo(blink::WebURLError error, bool was_failed_post)
375 : error(error), 375 : error(error),
376 was_failed_post(was_failed_post), 376 was_failed_post(was_failed_post),
377 needs_dns_updates(false), 377 needs_dns_updates(false),
378 needs_load_navigation_corrections(false), 378 needs_load_navigation_corrections(false),
379 reload_button_in_page(false), 379 reload_button_in_page(false),
380 load_stale_button_in_page(false), 380 show_saved_copy_button_in_page(false),
381 is_finished_loading(false), 381 is_finished_loading(false),
382 auto_reload_triggered(false) { 382 auto_reload_triggered(false) {
383 } 383 }
384 384
385 // Information about the failed page load. 385 // Information about the failed page load.
386 blink::WebURLError error; 386 blink::WebURLError error;
387 bool was_failed_post; 387 bool was_failed_post;
388 388
389 // Information about the status of the error page. 389 // Information about the status of the error page.
390 390
(...skipping 12 matching lines...) Expand all
403 navigation_correction_params; 403 navigation_correction_params;
404 404
405 scoped_ptr<NavigationCorrectionResponse> navigation_correction_response; 405 scoped_ptr<NavigationCorrectionResponse> navigation_correction_response;
406 406
407 // All the navigation corrections that have been clicked, for tracking 407 // All the navigation corrections that have been clicked, for tracking
408 // purposes. 408 // purposes.
409 std::set<int> clicked_corrections; 409 std::set<int> clicked_corrections;
410 410
411 // Track if specific buttons are included in an error page, for statistics. 411 // Track if specific buttons are included in an error page, for statistics.
412 bool reload_button_in_page; 412 bool reload_button_in_page;
413 bool load_stale_button_in_page; 413 bool show_saved_copy_button_in_page;
414 414
415 // True if a page has completed loading, at which point it can receive 415 // True if a page has completed loading, at which point it can receive
416 // updates. 416 // updates.
417 bool is_finished_loading; 417 bool is_finished_loading;
418 418
419 // True if the auto-reload timer has fired and a reload is or has been in 419 // True if the auto-reload timer has fired and a reload is or has been in
420 // flight. 420 // flight.
421 bool auto_reload_triggered; 421 bool auto_reload_triggered;
422 }; 422 };
423 423
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 // Track if an error occurred due to a page button press. 540 // Track if an error occurred due to a page button press.
541 // This isn't perfect; if (for instance), the server is slow responding 541 // This isn't perfect; if (for instance), the server is slow responding
542 // to a request generated from the page reload button, and the user hits 542 // to a request generated from the page reload button, and the user hits
543 // the browser reload button, this code will still believe the 543 // the browser reload button, this code will still believe the
544 // result is from the page reload button. 544 // result is from the page reload button.
545 if (committed_error_page_info_ && pending_error_page_info_ && 545 if (committed_error_page_info_ && pending_error_page_info_ &&
546 navigation_from_button_ != NO_BUTTON && 546 navigation_from_button_ != NO_BUTTON &&
547 committed_error_page_info_->error.unreachableURL == 547 committed_error_page_info_->error.unreachableURL ==
548 pending_error_page_info_->error.unreachableURL) { 548 pending_error_page_info_->error.unreachableURL) {
549 DCHECK(navigation_from_button_ == RELOAD_BUTTON || 549 DCHECK(navigation_from_button_ == RELOAD_BUTTON ||
550 navigation_from_button_ == LOAD_STALE_BUTTON); 550 navigation_from_button_ == SHOW_SAVED_COPY_BUTTON);
551 chrome_common_net::RecordEvent( 551 chrome_common_net::RecordEvent(
552 navigation_from_button_ == RELOAD_BUTTON ? 552 navigation_from_button_ == RELOAD_BUTTON ?
553 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_ERROR : 553 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_ERROR :
554 chrome_common_net::NETWORK_ERROR_PAGE_LOAD_STALE_BUTTON_ERROR); 554 chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_ERROR);
555 } 555 }
556 navigation_from_button_ = NO_BUTTON; 556 navigation_from_button_ = NO_BUTTON;
557 557
558 if (committed_error_page_info_ && !pending_error_page_info_ && 558 if (committed_error_page_info_ && !pending_error_page_info_ &&
559 committed_error_page_info_->auto_reload_triggered) { 559 committed_error_page_info_->auto_reload_triggered) {
560 const blink::WebURLError& error = committed_error_page_info_->error; 560 const blink::WebURLError& error = committed_error_page_info_->error;
561 const GURL& error_url = error.unreachableURL; 561 const GURL& error_url = error.unreachableURL;
562 if (url == error_url) 562 if (url == error_url)
563 ReportAutoReloadSuccess(error, auto_reload_count_); 563 ReportAutoReloadSuccess(error, auto_reload_count_);
564 else if (url != GURL(content::kUnreachableWebDataURL)) 564 else if (url != GURL(content::kUnreachableWebDataURL))
(...skipping 12 matching lines...) Expand all
577 return; 577 return;
578 } 578 }
579 579
580 committed_error_page_info_->is_finished_loading = true; 580 committed_error_page_info_->is_finished_loading = true;
581 581
582 chrome_common_net::RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_SHOWN); 582 chrome_common_net::RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_SHOWN);
583 if (committed_error_page_info_->reload_button_in_page) { 583 if (committed_error_page_info_->reload_button_in_page) {
584 chrome_common_net::RecordEvent( 584 chrome_common_net::RecordEvent(
585 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_SHOWN); 585 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_SHOWN);
586 } 586 }
587 if (committed_error_page_info_->load_stale_button_in_page) { 587 if (committed_error_page_info_->show_saved_copy_button_in_page) {
588 chrome_common_net::RecordEvent( 588 chrome_common_net::RecordEvent(
589 chrome_common_net::NETWORK_ERROR_PAGE_LOAD_STALE_BUTTON_SHOWN); 589 chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_SHOWN);
590 } 590 }
591 591
592 delegate_->EnablePageHelperFunctions(); 592 delegate_->EnablePageHelperFunctions();
593 593
594 if (committed_error_page_info_->needs_load_navigation_corrections) { 594 if (committed_error_page_info_->needs_load_navigation_corrections) {
595 // If there is another pending error page load, |fix_url| should have been 595 // If there is another pending error page load, |fix_url| should have been
596 // cleared. 596 // cleared.
597 DCHECK(!pending_error_page_info_); 597 DCHECK(!pending_error_page_info_);
598 DCHECK(!committed_error_page_info_->needs_dns_updates); 598 DCHECK(!committed_error_page_info_->needs_dns_updates);
599 delegate_->FetchNavigationCorrections( 599 delegate_->FetchNavigationCorrections(
(...skipping 25 matching lines...) Expand all
625 DCHECK(!committed_error_page_info_ || 625 DCHECK(!committed_error_page_info_ ||
626 !committed_error_page_info_->needs_load_navigation_corrections); 626 !committed_error_page_info_->needs_load_navigation_corrections);
627 627
628 pending_error_page_info_.reset(new ErrorPageInfo(error, is_failed_post)); 628 pending_error_page_info_.reset(new ErrorPageInfo(error, is_failed_post));
629 pending_error_page_info_->navigation_correction_params.reset( 629 pending_error_page_info_->navigation_correction_params.reset(
630 new NavigationCorrectionParams(navigation_correction_params_)); 630 new NavigationCorrectionParams(navigation_correction_params_));
631 GetErrorHtmlForMainFrame(pending_error_page_info_.get(), error_html); 631 GetErrorHtmlForMainFrame(pending_error_page_info_.get(), error_html);
632 } else { 632 } else {
633 // These values do not matter, as error pages in iframes hide the buttons. 633 // These values do not matter, as error pages in iframes hide the buttons.
634 bool reload_button_in_page; 634 bool reload_button_in_page;
635 bool load_stale_button_in_page; 635 bool show_saved_copy_button_in_page;
636 636
637 delegate_->GenerateLocalizedErrorPage( 637 delegate_->GenerateLocalizedErrorPage(
638 error, is_failed_post, scoped_ptr<ErrorPageParams>(), 638 error, is_failed_post, scoped_ptr<ErrorPageParams>(),
639 &reload_button_in_page, &load_stale_button_in_page, 639 &reload_button_in_page, &show_saved_copy_button_in_page,
640 error_html); 640 error_html);
641 } 641 }
642 } 642 }
643 643
644 void NetErrorHelperCore::OnNetErrorInfo( 644 void NetErrorHelperCore::OnNetErrorInfo(
645 chrome_common_net::DnsProbeStatus status) { 645 chrome_common_net::DnsProbeStatus status) {
646 DCHECK_NE(chrome_common_net::DNS_PROBE_POSSIBLE, status); 646 DCHECK_NE(chrome_common_net::DNS_PROBE_POSSIBLE, status);
647 647
648 last_probe_status_ = status; 648 last_probe_status_ = status;
649 649
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // will just get the results for the next page load. 690 // will just get the results for the next page load.
691 last_probe_status_ = chrome_common_net::DNS_PROBE_POSSIBLE; 691 last_probe_status_ = chrome_common_net::DNS_PROBE_POSSIBLE;
692 pending_error_page_info->needs_dns_updates = true; 692 pending_error_page_info->needs_dns_updates = true;
693 error = GetUpdatedError(error); 693 error = GetUpdatedError(error);
694 } 694 }
695 695
696 delegate_->GenerateLocalizedErrorPage( 696 delegate_->GenerateLocalizedErrorPage(
697 error, pending_error_page_info->was_failed_post, 697 error, pending_error_page_info->was_failed_post,
698 scoped_ptr<ErrorPageParams>(), 698 scoped_ptr<ErrorPageParams>(),
699 &pending_error_page_info->reload_button_in_page, 699 &pending_error_page_info->reload_button_in_page,
700 &pending_error_page_info->load_stale_button_in_page, 700 &pending_error_page_info->show_saved_copy_button_in_page,
701 error_html); 701 error_html);
702 } 702 }
703 703
704 void NetErrorHelperCore::UpdateErrorPage() { 704 void NetErrorHelperCore::UpdateErrorPage() {
705 DCHECK(committed_error_page_info_->needs_dns_updates); 705 DCHECK(committed_error_page_info_->needs_dns_updates);
706 DCHECK(committed_error_page_info_->is_finished_loading); 706 DCHECK(committed_error_page_info_->is_finished_loading);
707 DCHECK_NE(chrome_common_net::DNS_PROBE_POSSIBLE, last_probe_status_); 707 DCHECK_NE(chrome_common_net::DNS_PROBE_POSSIBLE, last_probe_status_);
708 708
709 UMA_HISTOGRAM_ENUMERATION("DnsProbe.ErrorPageUpdateStatus", 709 UMA_HISTOGRAM_ENUMERATION("DnsProbe.ErrorPageUpdateStatus",
710 last_probe_status_, 710 last_probe_status_,
711 chrome_common_net::DNS_PROBE_MAX); 711 chrome_common_net::DNS_PROBE_MAX);
712 // Every status other than DNS_PROBE_POSSIBLE and DNS_PROBE_STARTED is a 712 // Every status other than DNS_PROBE_POSSIBLE and DNS_PROBE_STARTED is a
713 // final status code. Once one is reached, the page does not need further 713 // final status code. Once one is reached, the page does not need further
714 // updates. 714 // updates.
715 if (last_probe_status_ != chrome_common_net::DNS_PROBE_STARTED) 715 if (last_probe_status_ != chrome_common_net::DNS_PROBE_STARTED)
716 committed_error_page_info_->needs_dns_updates = false; 716 committed_error_page_info_->needs_dns_updates = false;
717 717
718 // There is no need to worry about the button display statistics here because 718 // There is no need to worry about the button display statistics here because
719 // the presentation of the reload and load stale buttons can't be changed 719 // the presentation of the reload and show saved copy buttons can't be changed
720 // by a DNS error update. 720 // by a DNS error update.
721 delegate_->UpdateErrorPage( 721 delegate_->UpdateErrorPage(
722 GetUpdatedError(committed_error_page_info_->error), 722 GetUpdatedError(committed_error_page_info_->error),
723 committed_error_page_info_->was_failed_post); 723 committed_error_page_info_->was_failed_post);
724 } 724 }
725 725
726 void NetErrorHelperCore::OnNavigationCorrectionsFetched( 726 void NetErrorHelperCore::OnNavigationCorrectionsFetched(
727 const std::string& corrections, 727 const std::string& corrections,
728 const std::string& accept_languages, 728 const std::string& accept_languages,
729 bool is_rtl) { 729 bool is_rtl) {
(...skipping 21 matching lines...) Expand all
751 params = CreateErrorPageParams( 751 params = CreateErrorPageParams(
752 *pending_error_page_info_->navigation_correction_response, 752 *pending_error_page_info_->navigation_correction_response,
753 pending_error_page_info_->error, 753 pending_error_page_info_->error,
754 *pending_error_page_info_->navigation_correction_params, 754 *pending_error_page_info_->navigation_correction_params,
755 accept_languages, is_rtl); 755 accept_languages, is_rtl);
756 delegate_->GenerateLocalizedErrorPage( 756 delegate_->GenerateLocalizedErrorPage(
757 pending_error_page_info_->error, 757 pending_error_page_info_->error,
758 pending_error_page_info_->was_failed_post, 758 pending_error_page_info_->was_failed_post,
759 params.Pass(), 759 params.Pass(),
760 &pending_error_page_info_->reload_button_in_page, 760 &pending_error_page_info_->reload_button_in_page,
761 &pending_error_page_info_->load_stale_button_in_page, 761 &pending_error_page_info_->show_saved_copy_button_in_page,
762 &error_html); 762 &error_html);
763 } else { 763 } else {
764 // Since |navigation_correction_params| in |pending_error_page_info_| is 764 // Since |navigation_correction_params| in |pending_error_page_info_| is
765 // NULL, this won't trigger another attempt to load corrections. 765 // NULL, this won't trigger another attempt to load corrections.
766 GetErrorHtmlForMainFrame(pending_error_page_info_.get(), &error_html); 766 GetErrorHtmlForMainFrame(pending_error_page_info_.get(), &error_html);
767 } 767 }
768 768
769 // TODO(mmenke): Once the new API is in place, look into replacing this 769 // TODO(mmenke): Once the new API is in place, look into replacing this
770 // double page load by just updating the error page, like DNS 770 // double page load by just updating the error page, like DNS
771 // probes do. 771 // probes do.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 890 }
891 891
892 void NetErrorHelperCore::ExecuteButtonPress(Button button) { 892 void NetErrorHelperCore::ExecuteButtonPress(Button button) {
893 switch (button) { 893 switch (button) {
894 case RELOAD_BUTTON: 894 case RELOAD_BUTTON:
895 chrome_common_net::RecordEvent( 895 chrome_common_net::RecordEvent(
896 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_CLICKED); 896 chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_CLICKED);
897 navigation_from_button_ = RELOAD_BUTTON; 897 navigation_from_button_ = RELOAD_BUTTON;
898 Reload(); 898 Reload();
899 return; 899 return;
900 case LOAD_STALE_BUTTON: 900 case SHOW_SAVED_COPY_BUTTON:
901 chrome_common_net::RecordEvent( 901 chrome_common_net::RecordEvent(
902 chrome_common_net::NETWORK_ERROR_PAGE_LOAD_STALE_BUTTON_CLICKED); 902 chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_CLICKED);
903 navigation_from_button_ = LOAD_STALE_BUTTON; 903 navigation_from_button_ = SHOW_SAVED_COPY_BUTTON;
904 delegate_->LoadPageFromCache( 904 delegate_->LoadPageFromCache(
905 committed_error_page_info_->error.unreachableURL); 905 committed_error_page_info_->error.unreachableURL);
906 return; 906 return;
907 case MORE_BUTTON: 907 case MORE_BUTTON:
908 // Visual effects on page are handled in Javascript code. 908 // Visual effects on page are handled in Javascript code.
909 chrome_common_net::RecordEvent( 909 chrome_common_net::RecordEvent(
910 chrome_common_net::NETWORK_ERROR_PAGE_MORE_BUTTON_CLICKED); 910 chrome_common_net::NETWORK_ERROR_PAGE_MORE_BUTTON_CLICKED);
911 return; 911 return;
912 case NO_BUTTON: 912 case NO_BUTTON:
913 NOTREACHED(); 913 NOTREACHED();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 committed_error_page_info_->error, 945 committed_error_page_info_->error,
946 *committed_error_page_info_->navigation_correction_params, 946 *committed_error_page_info_->navigation_correction_params,
947 *response, 947 *response,
948 *response->corrections[tracking_id]); 948 *response->corrections[tracking_id]);
949 delegate_->SendTrackingRequest( 949 delegate_->SendTrackingRequest(
950 committed_error_page_info_->navigation_correction_params->url, 950 committed_error_page_info_->navigation_correction_params->url,
951 request_body); 951 request_body);
952 } 952 }
953 953
954 } // namespace error_page 954 } // namespace error_page
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698