OLD | NEW |
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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 CHECK(proxy); | 620 CHECK(proxy); |
621 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); | 621 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); |
622 web_frame = | 622 web_frame = |
623 blink::WebLocalFrame::create(replicated_state.scope, render_frame); | 623 blink::WebLocalFrame::create(replicated_state.scope, render_frame); |
624 render_frame->proxy_routing_id_ = proxy_routing_id; | 624 render_frame->proxy_routing_id_ = proxy_routing_id; |
625 web_frame->initializeToReplaceRemoteFrame( | 625 web_frame->initializeToReplaceRemoteFrame( |
626 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), | 626 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), |
627 replicated_state.sandbox_flags); | 627 replicated_state.sandbox_flags); |
628 } | 628 } |
629 render_frame->SetWebFrame(web_frame); | 629 render_frame->SetWebFrame(web_frame); |
630 CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent()); | 630 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); |
631 | 631 |
632 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); | 632 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); |
633 web_frame->setOpener(opener); | 633 web_frame->setOpener(opener); |
634 | 634 |
635 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 635 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
636 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 636 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
637 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 637 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
638 widget_params.routing_id, widget_params.hidden, | 638 widget_params.routing_id, widget_params.hidden, |
639 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 639 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
640 // TODO(kenrb): Observing shouldn't be necessary when we sort out | 640 // TODO(kenrb): Observing shouldn't be necessary when we sort out |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 void RenderFrameImpl::OnSwapOut( | 1226 void RenderFrameImpl::OnSwapOut( |
1227 int proxy_routing_id, | 1227 int proxy_routing_id, |
1228 bool is_loading, | 1228 bool is_loading, |
1229 const FrameReplicationState& replicated_frame_state) { | 1229 const FrameReplicationState& replicated_frame_state) { |
1230 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); | 1230 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); |
1231 RenderFrameProxy* proxy = NULL; | 1231 RenderFrameProxy* proxy = NULL; |
1232 bool swapped_out_forbidden = | 1232 bool swapped_out_forbidden = |
1233 SiteIsolationPolicy::IsSwappedOutStateForbidden(); | 1233 SiteIsolationPolicy::IsSwappedOutStateForbidden(); |
1234 | 1234 |
1235 // This codepath should only be hit for subframes when in --site-per-process. | 1235 // This codepath should only be hit for subframes when in --site-per-process. |
1236 CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 1236 CHECK_IMPLIES(!is_main_frame_, |
| 1237 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
1237 | 1238 |
1238 // Only run unload if we're not swapped out yet, but send the ack either way. | 1239 // Only run unload if we're not swapped out yet, but send the ack either way. |
1239 if (!is_swapped_out_) { | 1240 if (!is_swapped_out_) { |
1240 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1241 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
1241 // a different process. This involves running the unload handler and | 1242 // a different process. This involves running the unload handler and |
1242 // clearing the page. We also allow this process to exit if there are no | 1243 // clearing the page. We also allow this process to exit if there are no |
1243 // other active RenderFrames in it. | 1244 // other active RenderFrames in it. |
1244 | 1245 |
1245 // Send an UpdateState message before we get swapped out. | 1246 // Send an UpdateState message before we get swapped out. |
1246 render_view_->SendUpdateState(); | 1247 render_view_->SendUpdateState(); |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 // callback is invoked. | 2647 // callback is invoked. |
2647 if (!ds) | 2648 if (!ds) |
2648 return; | 2649 return; |
2649 | 2650 |
2650 TRACE_EVENT2("navigation,benchmark", | 2651 TRACE_EVENT2("navigation,benchmark", |
2651 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, | 2652 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, |
2652 "url", ds->request().url().string().utf8()); | 2653 "url", ds->request().url().string().utf8()); |
2653 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2654 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2654 | 2655 |
2655 // We should only navigate to swappedout:// when is_swapped_out_ is true. | 2656 // We should only navigate to swappedout:// when is_swapped_out_ is true. |
2656 CHECK(ds->request().url() != GURL(kSwappedOutURL) || is_swapped_out_) | 2657 CHECK_IMPLIES(ds->request().url() == GURL(kSwappedOutURL), is_swapped_out_) |
2657 << "Heard swappedout:// when not swapped out."; | 2658 << "Heard swappedout:// when not swapped out."; |
2658 | 2659 |
2659 // Update the request time if WebKit has better knowledge of it. | 2660 // Update the request time if WebKit has better knowledge of it. |
2660 if (document_state->request_time().is_null() && | 2661 if (document_state->request_time().is_null() && |
2661 triggering_event_time != 0.0) { | 2662 triggering_event_time != 0.0) { |
2662 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); | 2663 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); |
2663 } | 2664 } |
2664 | 2665 |
2665 // Start time is only set after request time. | 2666 // Start time is only set after request time. |
2666 document_state->set_start_load_time(Time::Now()); | 2667 document_state->set_start_load_time(Time::Now()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 if (is_new_navigation) { | 2813 if (is_new_navigation) { |
2813 // We bump our Page ID to correspond with the new session history entry. | 2814 // We bump our Page ID to correspond with the new session history entry. |
2814 render_view_->page_id_ = render_view_->next_page_id_++; | 2815 render_view_->page_id_ = render_view_->next_page_id_++; |
2815 | 2816 |
2816 // Don't update history list values for kSwappedOutURL, since | 2817 // Don't update history list values for kSwappedOutURL, since |
2817 // we don't want to forget the entry that was there, and since we will | 2818 // we don't want to forget the entry that was there, and since we will |
2818 // never come back to kSwappedOutURL. Note that we have to call | 2819 // never come back to kSwappedOutURL. Note that we have to call |
2819 // SendUpdateState and update page_id_ even in this case, so that | 2820 // SendUpdateState and update page_id_ even in this case, so that |
2820 // the current entry gets a state update and so that we don't send a | 2821 // the current entry gets a state update and so that we don't send a |
2821 // state update to the wrong entry when we swap back in. | 2822 // state update to the wrong entry when we swap back in. |
2822 DCHECK(!navigation_state->common_params().should_replace_current_entry || | 2823 DCHECK_IMPLIES( |
2823 render_view_->history_list_length_ > 0); | 2824 navigation_state->common_params().should_replace_current_entry, |
| 2825 render_view_->history_list_length_ > 0); |
2824 if (GetLoadingUrl() != GURL(kSwappedOutURL) && | 2826 if (GetLoadingUrl() != GURL(kSwappedOutURL) && |
2825 !navigation_state->common_params().should_replace_current_entry) { | 2827 !navigation_state->common_params().should_replace_current_entry) { |
2826 // Advance our offset in session history, applying the length limit. | 2828 // Advance our offset in session history, applying the length limit. |
2827 // There is now no forward history. | 2829 // There is now no forward history. |
2828 render_view_->history_list_offset_++; | 2830 render_view_->history_list_offset_++; |
2829 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2831 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
2830 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2832 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
2831 render_view_->history_list_length_ = | 2833 render_view_->history_list_length_ = |
2832 render_view_->history_list_offset_ + 1; | 2834 render_view_->history_list_offset_ + 1; |
2833 } | 2835 } |
(...skipping 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4976 } | 4978 } |
4977 | 4979 |
4978 // These values are assumed on the browser side for navigations. These checks | 4980 // These values are assumed on the browser side for navigations. These checks |
4979 // ensure the renderer has the correct values. | 4981 // ensure the renderer has the correct values. |
4980 DCHECK_EQ(FETCH_REQUEST_MODE_SAME_ORIGIN, | 4982 DCHECK_EQ(FETCH_REQUEST_MODE_SAME_ORIGIN, |
4981 GetFetchRequestModeForWebURLRequest(*request)); | 4983 GetFetchRequestModeForWebURLRequest(*request)); |
4982 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, | 4984 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, |
4983 GetFetchCredentialsModeForWebURLRequest(*request)); | 4985 GetFetchCredentialsModeForWebURLRequest(*request)); |
4984 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == | 4986 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == |
4985 FetchRedirectMode::MANUAL_MODE); | 4987 FetchRedirectMode::MANUAL_MODE); |
4986 DCHECK(frame_->parent() || | 4988 DCHECK_IMPLIES(!frame_->parent(), |
4987 GetRequestContextFrameTypeForWebURLRequest(*request) == | 4989 GetRequestContextFrameTypeForWebURLRequest(*request) == |
4988 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 4990 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
4989 DCHECK(!frame_->parent() || | 4991 DCHECK_IMPLIES(frame_->parent(), |
4990 GetRequestContextFrameTypeForWebURLRequest(*request) == | 4992 GetRequestContextFrameTypeForWebURLRequest(*request) == |
4991 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 4993 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
4992 | 4994 |
4993 Send(new FrameHostMsg_BeginNavigation( | 4995 Send(new FrameHostMsg_BeginNavigation( |
4994 routing_id_, | 4996 routing_id_, |
4995 MakeCommonNavigationParams(request, should_replace_current_entry), | 4997 MakeCommonNavigationParams(request, should_replace_current_entry), |
4996 BeginNavigationParams( | 4998 BeginNavigationParams( |
4997 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), | 4999 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), |
4998 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), | 5000 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), |
4999 request->skipServiceWorker(), | 5001 request->skipServiceWorker(), |
5000 GetRequestContextTypeForWebURLRequest(*request)), | 5002 GetRequestContextTypeForWebURLRequest(*request)), |
5001 GetRequestBodyForWebURLRequest(*request))); | 5003 GetRequestBodyForWebURLRequest(*request))); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5258 mojo::ServiceProviderPtr service_provider; | 5260 mojo::ServiceProviderPtr service_provider; |
5259 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5261 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5260 request->url = mojo::String::From(url); | 5262 request->url = mojo::String::From(url); |
5261 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5263 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5262 nullptr, nullptr, | 5264 nullptr, nullptr, |
5263 base::Bind(&OnGotContentHandlerID)); | 5265 base::Bind(&OnGotContentHandlerID)); |
5264 return service_provider.Pass(); | 5266 return service_provider.Pass(); |
5265 } | 5267 } |
5266 | 5268 |
5267 } // namespace content | 5269 } // namespace content |
OLD | NEW |