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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1171973004: Ensure the new navigation classifier works in the real world. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // notification containing parameters identifying the navigation. 781 // notification containing parameters identifying the navigation.
782 // 782 //
783 // Subframes are identified by the page transition type. For subframes loaded 783 // Subframes are identified by the page transition type. For subframes loaded
784 // as part of a wider page load, the page_id will be the same as for the top 784 // as part of a wider page load, the page_id will be the same as for the top
785 // level frame. If the user explicitly requests a subframe navigation, we will 785 // level frame. If the user explicitly requests a subframe navigation, we will
786 // get a new page_id because we need to create a new navigation entry for that 786 // get a new page_id because we need to create a new navigation entry for that
787 // action. 787 // action.
788 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { 788 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) {
789 // Read the parameters out of the IPC message directly to avoid making another 789 // Read the parameters out of the IPC message directly to avoid making another
790 // copy when we filter the URLs. 790 // copy when we filter the URLs.
791 ++commit_count_;
791 base::PickleIterator iter(msg); 792 base::PickleIterator iter(msg);
792 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; 793 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params;
793 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: 794 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>::
794 Read(&msg, &iter, &validated_params)) 795 Read(&msg, &iter, &validated_params)) {
796 base::debug::SetCrashKeyValue("369661-earlyreturn",
797 CommitCountString() + "/badipc");
795 return; 798 return;
799 }
796 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", 800 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad",
797 "url", validated_params.url.possibly_invalid_spec()); 801 "url", validated_params.url.possibly_invalid_spec());
798 802
799 // Sanity-check the page transition for frame type. 803 // Sanity-check the page transition for frame type.
800 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition), 804 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition),
801 !GetParent()); 805 !GetParent());
802 806
803 // If we're waiting for a cross-site beforeunload ack from this renderer and 807 // If we're waiting for a cross-site beforeunload ack from this renderer and
804 // we receive a Navigate message from the main frame, then the renderer was 808 // we receive a Navigate message from the main frame, then the renderer was
805 // navigating already and sent it before hearing the FrameMsg_Stop message. 809 // navigating already and sent it before hearing the FrameMsg_Stop message.
806 // We do not want to cancel the pending navigation in this case, since the 810 // We do not want to cancel the pending navigation in this case, since the
807 // old page will soon be stopped. Instead, treat this as a beforeunload ack 811 // old page will soon be stopped. Instead, treat this as a beforeunload ack
808 // to allow the pending navigation to continue. 812 // to allow the pending navigation to continue.
809 if (is_waiting_for_beforeunload_ack_ && 813 if (is_waiting_for_beforeunload_ack_ &&
810 unload_ack_is_for_navigation_ && 814 unload_ack_is_for_navigation_ &&
811 !GetParent()) { 815 !GetParent()) {
812 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 816 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
813 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 817 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
818 base::debug::SetCrashKeyValue("369661-earlyreturn",
819 CommitCountString() + "/beforeunloadwait");
814 return; 820 return;
815 } 821 }
816 822
817 // If we're waiting for an unload ack from this renderer and we receive a 823 // If we're waiting for an unload ack from this renderer and we receive a
818 // Navigate message, then the renderer was navigating before it received the 824 // Navigate message, then the renderer was navigating before it received the
819 // unload request. It will either respond to the unload request soon or our 825 // unload request. It will either respond to the unload request soon or our
820 // timer will expire. Either way, we should ignore this message, because we 826 // timer will expire. Either way, we should ignore this message, because we
821 // have already committed to closing this renderer. 827 // have already committed to closing this renderer.
822 if (IsWaitingForUnloadACK()) 828 if (IsWaitingForUnloadACK()) {
829 base::debug::SetCrashKeyValue("369661-earlyreturn",
830 CommitCountString() + "/unloadwait");
823 return; 831 return;
832 }
824 833
825 if (validated_params.report_type == 834 if (validated_params.report_type ==
826 FrameMsg_UILoadMetricsReportType::REPORT_LINK) { 835 FrameMsg_UILoadMetricsReportType::REPORT_LINK) {
827 UMA_HISTOGRAM_CUSTOM_TIMES( 836 UMA_HISTOGRAM_CUSTOM_TIMES(
828 "Navigation.UI_OnCommitProvisionalLoad.Link", 837 "Navigation.UI_OnCommitProvisionalLoad.Link",
829 base::TimeTicks::Now() - validated_params.ui_timestamp, 838 base::TimeTicks::Now() - validated_params.ui_timestamp,
830 base::TimeDelta::FromMilliseconds(10), base::TimeDelta::FromMinutes(10), 839 base::TimeDelta::FromMilliseconds(10), base::TimeDelta::FromMinutes(10),
831 100); 840 100);
832 } else if (validated_params.report_type == 841 } else if (validated_params.report_type ==
833 FrameMsg_UILoadMetricsReportType::REPORT_INTENT) { 842 FrameMsg_UILoadMetricsReportType::REPORT_INTENT) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 process->FilterURL(false, &(*it)); 874 process->FilterURL(false, &(*it));
866 } 875 }
867 process->FilterURL(true, &validated_params.searchable_form_url); 876 process->FilterURL(true, &validated_params.searchable_form_url);
868 877
869 // Without this check, the renderer can trick the browser into using 878 // Without this check, the renderer can trick the browser into using
870 // filenames it can't access in a future session restore. 879 // filenames it can't access in a future session restore.
871 if (!render_view_host_->CanAccessFilesOfPageState( 880 if (!render_view_host_->CanAccessFilesOfPageState(
872 validated_params.page_state)) { 881 validated_params.page_state)) {
873 bad_message::ReceivedBadMessage( 882 bad_message::ReceivedBadMessage(
874 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); 883 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE);
884 base::debug::SetCrashKeyValue("369661-earlyreturn",
885 CommitCountString() + "/fileaccess");
875 return; 886 return;
876 } 887 }
877 888
878 accessibility_reset_count_ = 0; 889 accessibility_reset_count_ = 0;
879 frame_tree_node()->navigator()->DidNavigate(this, validated_params); 890 frame_tree_node()->navigator()->DidNavigate(this, validated_params);
880 891
881 // PlzNavigate 892 // PlzNavigate
882 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 893 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
883 switches::kEnableBrowserSideNavigation)) { 894 switches::kEnableBrowserSideNavigation)) {
884 pending_commit_ = false; 895 pending_commit_ = false;
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 2078
2068 // We may be returning to an existing NavigationEntry that had been granted 2079 // We may be returning to an existing NavigationEntry that had been granted
2069 // file access. If this is a different process, we will need to grant the 2080 // file access. If this is a different process, we will need to grant the
2070 // access again. The files listed in the page state are validated when they 2081 // access again. The files listed in the page state are validated when they
2071 // are received from the renderer to prevent abuse. 2082 // are received from the renderer to prevent abuse.
2072 if (request_params.page_state.IsValid()) { 2083 if (request_params.page_state.IsValid()) {
2073 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); 2084 render_view_host_->GrantFileAccessFromPageState(request_params.page_state);
2074 } 2085 }
2075 } 2086 }
2076 2087
2088 std::string RenderFrameHostImpl::CommitCountString() {
2089 std::string result = base::Int64ToString(reinterpret_cast<int64_t>(this));
Charlie Reis 2015/06/09 23:32:13 This seems very suspicious to me (signed int, rein
Avi (use Gerrit) 2015/06/10 16:34:52 The *actual* value of the pointer is completely ir
2090 result += "/";
2091 result += base::IntToString(commit_count_);
2092 return result;
2093 }
2094
2077 } // namespace content 2095 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698