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

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

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

Powered by Google App Engine
This is Rietveld 408576698