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

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

Issue 537703003: Keep a copy of page id in RenderViewHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/debug/crash_logging.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/metrics/user_metrics_action.h" 13 #include "base/metrics/user_metrics_action.h"
14 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 15 #include "base/time/time.h"
14 #include "content/browser/accessibility/accessibility_mode_helper.h" 16 #include "content/browser/accessibility/accessibility_mode_helper.h"
15 #include "content/browser/accessibility/browser_accessibility_manager.h" 17 #include "content/browser/accessibility/browser_accessibility_manager.h"
16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 18 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
17 #include "content/browser/child_process_security_policy_impl.h" 19 #include "content/browser/child_process_security_policy_impl.h"
18 #include "content/browser/frame_host/cross_process_frame_connector.h" 20 #include "content/browser/frame_host/cross_process_frame_connector.h"
19 #include "content/browser/frame_host/cross_site_transferring_request.h" 21 #include "content/browser/frame_host/cross_site_transferring_request.h"
20 #include "content/browser/frame_host/frame_tree.h" 22 #include "content/browser/frame_host/frame_tree.h"
21 #include "content/browser/frame_host/frame_tree_node.h" 23 #include "content/browser/frame_host/frame_tree_node.h"
22 #include "content/browser/frame_host/navigator.h" 24 #include "content/browser/frame_host/navigator.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 GetProcess()->FilterURL(false, &validated_url); 564 GetProcess()->FilterURL(false, &validated_url);
563 565
564 frame_tree_node_->navigator()->DidFailLoadWithError( 566 frame_tree_node_->navigator()->DidFailLoadWithError(
565 this, validated_url, error_code, error_description); 567 this, validated_url, error_code, error_description);
566 } 568 }
567 569
568 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( 570 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad(
569 int32 page_id, 571 int32 page_id,
570 const GURL& source_url, 572 const GURL& source_url,
571 const GURL& target_url) { 573 const GURL& target_url) {
574 if (render_view_host_->page_id_ != page_id) {
575 base::debug::SetCrashKeyValue("url1",
576 source_url.possibly_invalid_spec());
577 base::debug::SetCrashKeyValue("url2",
578 target_url.possibly_invalid_spec());
579 base::debug::SetCrashKeyValue(
580 "id1", base::IntToString(render_view_host_->page_id_));
581 base::debug::SetCrashKeyValue("id2",
582 base::IntToString(page_id));
583 CHECK(false);
584 }
572 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( 585 frame_tree_node_->navigator()->DidRedirectProvisionalLoad(
573 this, page_id, source_url, target_url); 586 this, render_view_host_->page_id_, source_url, target_url);
574 } 587 }
575 588
576 // Called when the renderer navigates. For every frame loaded, we'll get this 589 // Called when the renderer navigates. For every frame loaded, we'll get this
577 // notification containing parameters identifying the navigation. 590 // notification containing parameters identifying the navigation.
578 // 591 //
579 // Subframes are identified by the page transition type. For subframes loaded 592 // Subframes are identified by the page transition type. For subframes loaded
580 // as part of a wider page load, the page_id will be the same as for the top 593 // as part of a wider page load, the page_id will be the same as for the top
581 // level frame. If the user explicitly requests a subframe navigation, we will 594 // level frame. If the user explicitly requests a subframe navigation, we will
582 // get a new page_id because we need to create a new navigation entry for that 595 // get a new page_id because we need to create a new navigation entry for that
583 // action. 596 // action.
584 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { 597 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) {
585 // Read the parameters out of the IPC message directly to avoid making another 598 // Read the parameters out of the IPC message directly to avoid making another
586 // copy when we filter the URLs. 599 // copy when we filter the URLs.
587 PickleIterator iter(msg); 600 PickleIterator iter(msg);
588 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; 601 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params;
589 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: 602 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>::
590 Read(&msg, &iter, &validated_params)) 603 Read(&msg, &iter, &validated_params))
591 return; 604 return;
592 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnNavigate", 605 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnNavigate",
593 "url", validated_params.url.possibly_invalid_spec()); 606 "url", validated_params.url.possibly_invalid_spec());
594 607
608 // Update the RVH's current page ID so that future IPCs from the renderer
609 // correspond to the new page.
610 render_view_host_->page_id_ = validated_params.page_id;
611
612 // Update the RVH's current page ID so that future IPCs from the renderer
613 // correspond to the new page.
614 render_view_host_->page_id_ = validated_params.page_id;
615
595 // If we're waiting for a cross-site beforeunload ack from this renderer and 616 // If we're waiting for a cross-site beforeunload ack from this renderer and
596 // we receive a Navigate message from the main frame, then the renderer was 617 // we receive a Navigate message from the main frame, then the renderer was
597 // navigating already and sent it before hearing the FrameMsg_Stop message. 618 // navigating already and sent it before hearing the FrameMsg_Stop message.
598 // We do not want to cancel the pending navigation in this case, since the 619 // We do not want to cancel the pending navigation in this case, since the
599 // old page will soon be stopped. Instead, treat this as a beforeunload ack 620 // old page will soon be stopped. Instead, treat this as a beforeunload ack
600 // to allow the pending navigation to continue. 621 // to allow the pending navigation to continue.
601 if (render_view_host_->is_waiting_for_beforeunload_ack_ && 622 if (render_view_host_->is_waiting_for_beforeunload_ack_ &&
602 render_view_host_->unload_ack_is_for_cross_site_transition_ && 623 render_view_host_->unload_ack_is_for_cross_site_transition_ &&
603 PageTransitionIsMainFrame(validated_params.transition)) { 624 PageTransitionIsMainFrame(validated_params.transition)) {
604 OnBeforeUnloadACK(true, send_before_unload_start_time_, 625 OnBeforeUnloadACK(true, send_before_unload_start_time_,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 void RenderFrameHostImpl::OnDidDisownOpener() { 939 void RenderFrameHostImpl::OnDidDisownOpener() {
919 // This message is only sent for top-level frames. TODO(avi): when frame tree 940 // This message is only sent for top-level frames. TODO(avi): when frame tree
920 // mirroring works correctly, add a check here to enforce it. 941 // mirroring works correctly, add a check here to enforce it.
921 delegate_->DidDisownOpener(this); 942 delegate_->DidDisownOpener(this);
922 } 943 }
923 944
924 void RenderFrameHostImpl::OnUpdateTitle( 945 void RenderFrameHostImpl::OnUpdateTitle(
925 int32 page_id, 946 int32 page_id,
926 const base::string16& title, 947 const base::string16& title,
927 blink::WebTextDirection title_direction) { 948 blink::WebTextDirection title_direction) {
949 if (render_view_host_->page_id_ != page_id) {
950 base::debug::SetCrashKeyValue(
951 "url1", GetLastCommittedURL().possibly_invalid_spec());
952 base::debug::SetCrashKeyValue(
953 "id1", base::IntToString(render_view_host_->page_id_));
954 base::debug::SetCrashKeyValue("id2",
955 base::IntToString(page_id));
956 CHECK(false);
957 }
928 // This message is only sent for top-level frames. TODO(avi): when frame tree 958 // This message is only sent for top-level frames. TODO(avi): when frame tree
929 // mirroring works correctly, add a check here to enforce it. 959 // mirroring works correctly, add a check here to enforce it.
930 if (title.length() > kMaxTitleChars) { 960 if (title.length() > kMaxTitleChars) {
931 NOTREACHED() << "Renderer sent too many characters in title."; 961 NOTREACHED() << "Renderer sent too many characters in title.";
932 return; 962 return;
933 } 963 }
934 964
935 delegate_->UpdateTitle(this, page_id, title, 965 delegate_->UpdateTitle(this, render_view_host_->page_id_, title,
936 WebTextDirectionToChromeTextDirection( 966 WebTextDirectionToChromeTextDirection(
937 title_direction)); 967 title_direction));
938 } 968 }
939 969
940 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { 970 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) {
941 // This message is only sent for top-level frames. TODO(avi): when frame tree 971 // This message is only sent for top-level frames. TODO(avi): when frame tree
942 // mirroring works correctly, add a check here to enforce it. 972 // mirroring works correctly, add a check here to enforce it.
943 delegate_->UpdateEncoding(this, encoding_name); 973 delegate_->UpdateEncoding(this, encoding_name);
944 } 974 }
945 975
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 // Clear any state if a pending navigation is canceled or preempted. 1359 // Clear any state if a pending navigation is canceled or preempted.
1330 if (suspended_nav_params_) 1360 if (suspended_nav_params_)
1331 suspended_nav_params_.reset(); 1361 suspended_nav_params_.reset();
1332 1362
1333 TRACE_EVENT_ASYNC_END0("navigation", 1363 TRACE_EVENT_ASYNC_END0("navigation",
1334 "RenderFrameHostImpl navigation suspended", this); 1364 "RenderFrameHostImpl navigation suspended", this);
1335 navigations_suspended_ = false; 1365 navigations_suspended_ = false;
1336 } 1366 }
1337 1367
1338 } // namespace content 1368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698