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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1425823002: (DEPRECATED) Send navigation_start to browser process in DidStartProvisionalLoad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop calling didCreateDataSource for same-page navs Created 5 years, 1 month 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/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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // passed back to the browser in the DidCommitProvisionalLoad and the 450 // passed back to the browser in the DidCommitProvisionalLoad and the
451 // DocumentLoadComplete IPCs. 451 // DocumentLoadComplete IPCs.
452 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); 452 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks();
453 request.setUiStartTime(ui_timestamp.InSecondsF()); 453 request.setUiStartTime(ui_timestamp.InSecondsF());
454 request.setInputPerfMetricReportPolicy( 454 request.setInputPerfMetricReportPolicy(
455 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( 455 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>(
456 common_params.report_type)); 456 common_params.report_type));
457 return request; 457 return request;
458 } 458 }
459 459
460 void UpdateFrameNavigationTiming(WebFrame* frame, 460 base::TimeTicks SanitizeNavigationTiming(
461 base::TimeTicks browser_navigation_start, 461 blink::WebFrameLoadType load_type,
462 base::TimeTicks renderer_navigation_start) { 462 const base::TimeTicks& browser_navigation_start,
463 const base::TimeTicks& renderer_navigation_start) {
464 if (load_type != blink::WebFrameLoadType::Standard)
465 return base::TimeTicks();
463 // The browser provides the navigation_start time to bootstrap the 466 // The browser provides the navigation_start time to bootstrap the
464 // Navigation Timing information for the browser-initiated navigations. In 467 // Navigation Timing information for the browser-initiated navigations. In
465 // case of cross-process navigations, this carries over the time of 468 // case of cross-process navigations, this carries over the time of
466 // finishing the onbeforeunload handler of the previous page. 469 // finishing the onbeforeunload handler of the previous page.
470 // |browser_navigation_start| is likely before this process existed, so we
471 // can't use InterProcessTimeTicksConverter. We need at least to ensure
472 // that the browser-side navigation start we set is not later than the one
473 // on the renderer side.
467 DCHECK(!browser_navigation_start.is_null()); 474 DCHECK(!browser_navigation_start.is_null());
468 if (frame->provisionalDataSource()) { 475 base::TimeTicks navigation_start =
469 // |browser_navigation_start| is likely before this process existed, so we 476 std::min(browser_navigation_start, renderer_navigation_start);
470 // can't use InterProcessTimeTicksConverter. We need at least to ensure 477 // TODO(csharrison) UMA log:
471 // that the browser-side navigation start we set is not later than the one 478 // |renderer_navigation_start - browser_navigation_start|
472 // on the renderer side. 479 return navigation_start;
473 base::TimeTicks navigation_start = std::min(
474 browser_navigation_start, renderer_navigation_start);
475 double navigation_start_seconds =
476 (navigation_start - base::TimeTicks()).InSecondsF();
477 frame->provisionalDataSource()->setNavigationStartTime(
478 navigation_start_seconds);
479 // TODO(clamy): We need to provide additional timing values for the
480 // Navigation Timing API to work with browser-side navigations.
481 }
482 } 480 }
483 481
484 // PlzNavigate 482 // PlzNavigate
485 CommonNavigationParams MakeCommonNavigationParams( 483 CommonNavigationParams MakeCommonNavigationParams(
486 blink::WebURLRequest* request, 484 blink::WebURLRequest* request,
487 bool should_replace_current_entry) { 485 bool should_replace_current_entry,
486 const base::TimeTicks& navigation_start) {
488 const RequestExtraData kEmptyData; 487 const RequestExtraData kEmptyData;
489 const RequestExtraData* extra_data = 488 const RequestExtraData* extra_data =
490 static_cast<RequestExtraData*>(request->extraData()); 489 static_cast<RequestExtraData*>(request->extraData());
491 if (!extra_data) 490 if (!extra_data)
492 extra_data = &kEmptyData; 491 extra_data = &kEmptyData;
493 Referrer referrer( 492 Referrer referrer(
494 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 493 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
495 request->referrerPolicy()); 494 request->referrerPolicy());
496 495
497 // Set the ui timestamp for this navigation. Currently the timestamp here is 496 // Set the ui timestamp for this navigation. Currently the timestamp here is
498 // only non empty when the navigation was triggered by an Android intent, or 497 // only non empty when the navigation was triggered by an Android intent, or
499 // by the user clicking on a link. The timestamp is converted from a double 498 // by the user clicking on a link. The timestamp is converted from a double
500 // version supported by blink. It will be passed back to the renderer in the 499 // version supported by blink. It will be passed back to the renderer in the
501 // CommitNavigation IPC, and then back to the browser again in the 500 // CommitNavigation IPC, and then back to the browser again in the
502 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 501 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
503 base::TimeTicks ui_timestamp = 502 base::TimeTicks ui_timestamp =
504 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 503 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
505 FrameMsg_UILoadMetricsReportType::Value report_type = 504 FrameMsg_UILoadMetricsReportType::Value report_type =
506 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 505 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
507 request->inputPerfMetricReportPolicy()); 506 request->inputPerfMetricReportPolicy());
508 return CommonNavigationParams( 507 return CommonNavigationParams(
509 request->url(), referrer, extra_data->transition_type(), 508 request->url(), referrer, extra_data->transition_type(),
510 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, 509 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry,
511 ui_timestamp, report_type, GURL(), GURL(), LOFI_UNSPECIFIED); 510 ui_timestamp, report_type, GURL(), GURL(), LOFI_UNSPECIFIED,
511 navigation_start);
512 } 512 }
513 513
514 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) 514 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
515 media::Context3D GetSharedMainThreadContext3D() { 515 media::Context3D GetSharedMainThreadContext3D() {
516 cc::ContextProvider* provider = 516 cc::ContextProvider* provider =
517 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 517 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
518 if (!provider) 518 if (!provider)
519 return media::Context3D(); 519 return media::Context3D();
520 return media::Context3D(provider->ContextGL(), provider->GrContext()); 520 return media::Context3D(provider->ContextGL(), provider->GrContext());
521 } 521 }
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 2541
2542 // Save these to be processed when the ensuing navigation is committed. 2542 // Save these to be processed when the ensuing navigation is committed.
2543 WebSearchableFormData web_searchable_form_data(form); 2543 WebSearchableFormData web_searchable_form_data(form);
2544 internal_data->set_searchable_form_url(web_searchable_form_data.url()); 2544 internal_data->set_searchable_form_url(web_searchable_form_data.url());
2545 internal_data->set_searchable_form_encoding( 2545 internal_data->set_searchable_form_encoding(
2546 web_searchable_form_data.encoding().utf8()); 2546 web_searchable_form_data.encoding().utf8());
2547 2547
2548 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form)); 2548 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form));
2549 } 2549 }
2550 2550
2551 void RenderFrameImpl::UpdateNavigationState(DocumentState* document_state) {
2552 bool content_initiated = !pending_navigation_params_.get();
2553 // Note for some browser initiated navigations (i.e. not
2554 // WebFrameLoadType::Standard), we want to record their start time now. They
2555 // will have had common_params.navigation_start set to null. Other
2556 // content-initiated loads will have start time set when their NavigationState
2557 // is constructed.
2558 if (!content_initiated &&
2559 pending_navigation_params_->common_params.navigation_start.is_null()) {
2560 pending_navigation_params_->common_params.navigation_start =
2561 base::TimeTicks::Now();
2562 }
2563 document_state->set_navigation_state(
2564 content_initiated ? NavigationStateImpl::CreateContentInitiated()
2565 : CreateNavigationStateFromPending());
2566 pending_navigation_params_.reset();
2567 }
2568
2551 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, 2569 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame,
2552 blink::WebDataSource* datasource) { 2570 blink::WebDataSource* datasource) {
2553 DCHECK(!frame_ || frame_ == frame); 2571 DCHECK(!frame_ || frame_ == frame);
2554 2572
2555 bool content_initiated = !pending_navigation_params_.get(); 2573 bool content_initiated = !pending_navigation_params_.get();
2556 2574
2557 // Make sure any previous redirect URLs end up in our new data source. 2575 // Make sure any previous redirect URLs end up in our new data source.
2558 if (pending_navigation_params_.get()) { 2576 if (pending_navigation_params_.get()) {
2559 for (const auto& i : 2577 for (const auto& i :
2560 pending_navigation_params_->request_params.redirects) { 2578 pending_navigation_params_->request_params.redirects) {
(...skipping 18 matching lines...) Expand all
2579 DocumentState::FromDataSource(webview->mainFrame()->dataSource()); 2597 DocumentState::FromDataSource(webview->mainFrame()->dataSource());
2580 if (old_document_state) { 2598 if (old_document_state) {
2581 InternalDocumentStateData* internal_data = 2599 InternalDocumentStateData* internal_data =
2582 InternalDocumentStateData::FromDocumentState(document_state); 2600 InternalDocumentStateData::FromDocumentState(document_state);
2583 InternalDocumentStateData* old_internal_data = 2601 InternalDocumentStateData* old_internal_data =
2584 InternalDocumentStateData::FromDocumentState(old_document_state); 2602 InternalDocumentStateData::FromDocumentState(old_document_state);
2585 internal_data->set_is_overriding_user_agent( 2603 internal_data->set_is_overriding_user_agent(
2586 old_internal_data->is_overriding_user_agent()); 2604 old_internal_data->is_overriding_user_agent());
2587 } 2605 }
2588 } 2606 }
2589
2590 // The rest of RenderView assumes that a WebDataSource will always have a 2607 // The rest of RenderView assumes that a WebDataSource will always have a
2591 // non-null NavigationState. 2608 // non-null NavigationState.
2592 if (content_initiated) { 2609 UpdateNavigationState(document_state);
2593 document_state->set_navigation_state(
2594 NavigationStateImpl::CreateContentInitiated());
2595 } else {
2596 document_state->set_navigation_state(CreateNavigationStateFromPending());
2597 pending_navigation_params_.reset();
2598 }
2599 2610
2600 // DocumentState::referred_by_prefetcher_ is true if we are 2611 // DocumentState::referred_by_prefetcher_ is true if we are
2601 // navigating from a page that used prefetching using a link on that 2612 // navigating from a page that used prefetching using a link on that
2602 // page. We are early enough in the request process here that we 2613 // page. We are early enough in the request process here that we
2603 // can still see the DocumentState of the previous page and set 2614 // can still see the DocumentState of the previous page and set
2604 // this value appropriately. 2615 // this value appropriately.
2605 // TODO(gavinp): catch the important case of navigation in a new 2616 // TODO(gavinp): catch the important case of navigation in a new
2606 // renderer process. 2617 // renderer process.
2607 if (webview) { 2618 if (webview) {
2608 if (WebFrame* old_frame = webview->mainFrame()) { 2619 if (WebFrame* old_frame = webview->mainFrame()) {
(...skipping 29 matching lines...) Expand all
2638 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); 2649 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK);
2639 break; 2650 break;
2640 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. 2651 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post.
2641 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); 2652 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY);
2642 break; 2653 break;
2643 default: 2654 default:
2644 NOTREACHED(); 2655 NOTREACHED();
2645 } 2656 }
2646 } 2657 }
2647 2658
2659 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
2660 document_state->navigation_state());
2661
2662 // Set the navigation start time in blink.
2663 base::TimeTicks navigation_start =
2664 navigation_state->common_params().navigation_start;
2665 datasource->setNavigationStartTime(
2666 (navigation_start - base::TimeTicks()).InSecondsF());
2667
2648 // Create the serviceworker's per-document network observing object if it 2668 // Create the serviceworker's per-document network observing object if it
2649 // does not exist (When navigation happens within a page, the provider already 2669 // does not exist (When navigation happens within a page, the provider already
2650 // exists). 2670 // exists).
2651 if (ServiceWorkerNetworkProvider::FromDocumentState( 2671 if (ServiceWorkerNetworkProvider::FromDocumentState(
2652 DocumentState::FromDataSource(datasource))) 2672 DocumentState::FromDataSource(datasource)))
2653 return; 2673 return;
2654 2674
2655 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
2656 DocumentState::FromDataSource(datasource)->navigation_state());
2657
2658 ServiceWorkerNetworkProvider::AttachToDocumentState( 2675 ServiceWorkerNetworkProvider::AttachToDocumentState(
2659 DocumentState::FromDataSource(datasource), 2676 DocumentState::FromDataSource(datasource),
2660 ServiceWorkerNetworkProvider::CreateForNavigation( 2677 ServiceWorkerNetworkProvider::CreateForNavigation(
2661 routing_id_, navigation_state->request_params(), 2678 routing_id_, navigation_state->request_params(),
2662 frame->effectiveSandboxFlags(), content_initiated)); 2679 frame->effectiveSandboxFlags(), content_initiated));
2663 } 2680 }
2664 2681
2665 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, 2682 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame,
2666 double triggering_event_time) { 2683 double triggering_event_time) {
2667 DCHECK(!frame_ || frame_ == frame); 2684 DCHECK(!frame_ || frame_ == frame);
(...skipping 28 matching lines...) Expand all
2696 WebUserGestureIndicator::isProcessingUserGesture() ? 2713 WebUserGestureIndicator::isProcessingUserGesture() ?
2697 NavigationGestureUser : NavigationGestureAuto); 2714 NavigationGestureUser : NavigationGestureAuto);
2698 } else if (ds->replacesCurrentHistoryItem()) { 2715 } else if (ds->replacesCurrentHistoryItem()) {
2699 // Subframe navigations that don't add session history items must be 2716 // Subframe navigations that don't add session history items must be
2700 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2717 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2701 // handle loading of error pages. 2718 // handle loading of error pages.
2702 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 2719 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2703 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2720 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2704 } 2721 }
2705 2722
2723 // Get the navigation start in TimeTicks format. This will be
2724 // lossy because blink converts TimeTicks internal int64 representation to a
2725 // double. TODO(csharrison) Do we want to override this with the TimeTicks
2726 // timestamp in document_state->navigation_params for browser loads?
2727 DCHECK(ds->getNavigationStartTime());
2728 base::TimeTicks navigation_start = base::TimeTicks::FromInternalValue(
clamy 2015/11/03 13:33:00 Since we always set the start time of the DataSour
2729 ds->getNavigationStartTime() * base::Time::kMicrosecondsPerSecond);
2730
2706 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2731 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2707 DidStartProvisionalLoad(frame)); 2732 DidStartProvisionalLoad(frame));
2708 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2733 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2709 2734
2710 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2735 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2711 routing_id_, ds->request().url())); 2736 routing_id_, ds->request().url(), navigation_start));
2712 } 2737 }
2713 2738
2714 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 2739 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
2715 blink::WebLocalFrame* frame) { 2740 blink::WebLocalFrame* frame) {
2716 DCHECK(!frame_ || frame_ == frame); 2741 DCHECK(!frame_ || frame_ == frame);
2717 render_view_->history_controller()->RemoveChildrenForRedirect(this); 2742 render_view_->history_controller()->RemoveChildrenForRedirect(this);
2718 } 2743 }
2719 2744
2720 void RenderFrameImpl::didFailProvisionalLoad( 2745 void RenderFrameImpl::didFailProvisionalLoad(
2721 blink::WebLocalFrame* frame, 2746 blink::WebLocalFrame* frame,
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 blink::WebHistoryCommitType commit_type) { 3148 blink::WebHistoryCommitType commit_type) {
3124 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", 3149 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage",
3125 "id", routing_id_); 3150 "id", routing_id_);
3126 DCHECK(!frame_ || frame_ == frame); 3151 DCHECK(!frame_ || frame_ == frame);
3127 // If this was a reference fragment navigation that we initiated, then we 3152 // If this was a reference fragment navigation that we initiated, then we
3128 // could end up having a non-null pending navigation params. We just need to 3153 // could end up having a non-null pending navigation params. We just need to
3129 // update the ExtraData on the datasource so that others who read the 3154 // update the ExtraData on the datasource so that others who read the
3130 // ExtraData will get the new NavigationState. Similarly, if we did not 3155 // ExtraData will get the new NavigationState. Similarly, if we did not
3131 // initiate this navigation, then we need to take care to reset any pre- 3156 // initiate this navigation, then we need to take care to reset any pre-
3132 // existing navigation state to a content-initiated navigation state. 3157 // existing navigation state to a content-initiated navigation state.
3133 // didCreateDataSource conveniently takes care of this for us. 3158 // UpdateNavigationState conveniently takes care of this for us.
3134 didCreateDataSource(frame, frame->dataSource());
3135
3136 DocumentState* document_state = 3159 DocumentState* document_state =
3137 DocumentState::FromDataSource(frame->dataSource()); 3160 DocumentState::FromDataSource(frame->dataSource());
3161 DCHECK(document_state);
3162 UpdateNavigationState(document_state);
3138 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 3163 static_cast<NavigationStateImpl*>(document_state->navigation_state())
3139 ->set_was_within_same_page(true); 3164 ->set_was_within_same_page(true);
3140
3141 didCommitProvisionalLoad(frame, item, commit_type); 3165 didCommitProvisionalLoad(frame, item, commit_type);
3142 } 3166 }
3143 3167
3144 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) { 3168 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) {
3145 DCHECK(!frame_ || frame_ == frame); 3169 DCHECK(!frame_ || frame_ == frame);
3146 // TODO(nasko): Move implementation here. Needed methods: 3170 // TODO(nasko): Move implementation here. Needed methods:
3147 // * StartNavStateSyncTimerIfNecessary 3171 // * StartNavStateSyncTimerIfNecessary
3148 render_view_->didUpdateCurrentHistoryItem(frame); 3172 render_view_->didUpdateCurrentHistoryItem(frame);
3149 } 3173 }
3150 3174
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 common_params.url, request_params, &is_reload, &cache_policy); 4334 common_params.url, request_params, &is_reload, &cache_policy);
4311 4335
4312 GetContentClient()->SetActiveURL(common_params.url); 4336 GetContentClient()->SetActiveURL(common_params.url);
4313 4337
4314 pending_navigation_params_.reset(new NavigationParams( 4338 pending_navigation_params_.reset(new NavigationParams(
4315 common_params, StartNavigationParams(), request_params)); 4339 common_params, StartNavigationParams(), request_params));
4316 4340
4317 // Inform the browser of the start of the provisional load. This is needed so 4341 // Inform the browser of the start of the provisional load. This is needed so
4318 // that the load is properly tracked by the WebNavigation API. 4342 // that the load is properly tracked by the WebNavigation API.
4319 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 4343 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
4320 routing_id_, common_params.url)); 4344 routing_id_, common_params.url, common_params.navigation_start));
4321 4345
4322 // Send the provisional load failure. 4346 // Send the provisional load failure.
4323 blink::WebURLError error = 4347 blink::WebURLError error =
4324 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 4348 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
4325 WebURLRequest failed_request = CreateURLRequestForNavigation( 4349 WebURLRequest failed_request = CreateURLRequestForNavigation(
4326 common_params, scoped_ptr<StreamOverrideParameters>(), 4350 common_params, scoped_ptr<StreamOverrideParameters>(),
4327 frame_->isViewSourceModeEnabled()); 4351 frame_->isViewSourceModeEnabled());
4328 SendFailedProvisionalLoad(failed_request, error, frame_); 4352 SendFailedProvisionalLoad(failed_request, error, frame_);
4329 4353
4330 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { 4354 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
4614 } 4638 }
4615 4639
4616 void RenderFrameImpl::NavigateInternal( 4640 void RenderFrameImpl::NavigateInternal(
4617 const CommonNavigationParams& common_params, 4641 const CommonNavigationParams& common_params,
4618 const StartNavigationParams& start_params, 4642 const StartNavigationParams& start_params,
4619 const RequestNavigationParams& request_params, 4643 const RequestNavigationParams& request_params,
4620 scoped_ptr<StreamOverrideParameters> stream_params) { 4644 scoped_ptr<StreamOverrideParameters> stream_params) {
4621 bool browser_side_navigation = 4645 bool browser_side_navigation =
4622 base::CommandLine::ForCurrentProcess()->HasSwitch( 4646 base::CommandLine::ForCurrentProcess()->HasSwitch(
4623 switches::kEnableBrowserSideNavigation); 4647 switches::kEnableBrowserSideNavigation);
4648 // Upper bound for browser initiated navigation start time.
4649 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
4624 bool is_reload = IsReload(common_params.navigation_type); 4650 bool is_reload = IsReload(common_params.navigation_type);
4625 bool is_history_navigation = request_params.page_state.IsValid(); 4651 bool is_history_navigation = request_params.page_state.IsValid();
4626 WebURLRequest::CachePolicy cache_policy = 4652 WebURLRequest::CachePolicy cache_policy =
4627 WebURLRequest::UseProtocolCachePolicy; 4653 WebURLRequest::UseProtocolCachePolicy;
4628 RenderFrameImpl::PrepareRenderViewForNavigation( 4654 RenderFrameImpl::PrepareRenderViewForNavigation(
4629 common_params.url, request_params, &is_reload, &cache_policy); 4655 common_params.url, request_params, &is_reload, &cache_policy);
4630 4656
4631 GetContentClient()->SetActiveURL(common_params.url); 4657 GetContentClient()->SetActiveURL(common_params.url);
4632 4658
4633 // If this frame isn't in the same process as the main frame, it may naively 4659 // If this frame isn't in the same process as the main frame, it may naively
4634 // assume that this is the first navigation in the iframe, but this may not 4660 // assume that this is the first navigation in the iframe, but this may not
4635 // actually be the case. Inform the frame's state machine if this frame has 4661 // actually be the case. Inform the frame's state machine if this frame has
4636 // already committed other loads. 4662 // already committed other loads.
4637 if (request_params.has_committed_real_load && frame_->parent()) 4663 if (request_params.has_committed_real_load && frame_->parent())
4638 frame_->setCommittedFirstRealLoad(); 4664 frame_->setCommittedFirstRealLoad();
4639 4665
4640 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 4666 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
4641 // We cannot reload if we do not have any history state. This happens, for 4667 // We cannot reload if we do not have any history state. This happens, for
4642 // example, when recovering from a crash. 4668 // example, when recovering from a crash.
4643 is_reload = false; 4669 is_reload = false;
4644 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 4670 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
4645 } 4671 }
4646 4672
4647 pending_navigation_params_.reset( 4673 pending_navigation_params_.reset(
4648 new NavigationParams(common_params, start_params, request_params)); 4674 new NavigationParams(common_params, start_params, request_params));
4675 // We don't know for sure that this load type is WebFrameLoadType::Standard.
4676 // For now, set this to null, and update it when we are sure of the right
4677 // value.
clamy 2015/11/03 13:33:00 Could we check with Navigation Timing API people w
4678 pending_navigation_params_->common_params.navigation_start =
4679 base::TimeTicks();
4649 4680
4650 // Create parameters for a standard navigation. 4681 // Create parameters for a standard navigation.
4651 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; 4682 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard;
4652 bool should_load_request = false; 4683 bool should_load_request = false;
4653 WebHistoryItem item_for_history_navigation; 4684 WebHistoryItem item_for_history_navigation;
4654 WebURLRequest request = CreateURLRequestForNavigation( 4685 WebURLRequest request = CreateURLRequestForNavigation(
4655 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); 4686 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled());
4656 #if defined(OS_ANDROID) 4687 #if defined(OS_ANDROID)
4657 request.setHasUserGesture(start_params.has_user_gesture); 4688 request.setHasUserGesture(start_params.has_user_gesture);
4658 #endif 4689 #endif
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 request.setHTTPBody(http_body); 4801 request.setHTTPBody(http_body);
4771 } 4802 }
4772 4803
4773 // A session history navigation should have been accompanied by state. 4804 // A session history navigation should have been accompanied by state.
4774 CHECK_EQ(request_params.page_id, -1); 4805 CHECK_EQ(request_params.page_id, -1);
4775 4806
4776 should_load_request = true; 4807 should_load_request = true;
4777 } 4808 }
4778 4809
4779 if (should_load_request) { 4810 if (should_load_request) {
4780 // Record this before starting the load. We need a lower bound of this 4811 // Sanitize navigation start now that we know the load_type.
4781 // time to sanitize the navigationStart override set below. 4812 pending_navigation_params_->common_params.navigation_start =
4782 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 4813 SanitizeNavigationTiming(load_type, common_params.navigation_start,
4783 4814 renderer_navigation_start);
4784 // Perform a navigation to a data url if needed. 4815 // Perform a navigation to a data url if needed.
4785 if (!common_params.base_url_for_data_url.is_empty() || 4816 if (!common_params.base_url_for_data_url.is_empty() ||
4786 (browser_side_navigation && 4817 (browser_side_navigation &&
4787 common_params.url.SchemeIs(url::kDataScheme))) { 4818 common_params.url.SchemeIs(url::kDataScheme))) {
4788 LoadDataURL(common_params, frame_); 4819 LoadDataURL(common_params, frame_);
4789 } else { 4820 } else {
4790 // Load the request. 4821 // Load the request.
4791 frame_->toWebLocalFrame()->load(request, load_type, 4822 frame_->toWebLocalFrame()->load(request, load_type,
4792 item_for_history_navigation); 4823 item_for_history_navigation);
4793 } 4824 }
4794
4795 if (load_type == blink::WebFrameLoadType::Standard) {
4796 UpdateFrameNavigationTiming(frame_,
4797 request_params.browser_navigation_start,
4798 renderer_navigation_start);
4799 }
4800 } 4825 }
4801 4826
4802 // In case LoadRequest failed before didCreateDataSource was called. 4827 // In case LoadRequest failed before didCreateDataSource was called.
4803 pending_navigation_params_.reset(); 4828 pending_navigation_params_.reset();
4804 } 4829 }
4805 4830
4806 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, 4831 void RenderFrameImpl::UpdateEncoding(WebFrame* frame,
4807 const std::string& encoding_name) { 4832 const std::string& encoding_name) {
4808 // Only update main frame's encoding_name. 4833 // Only update main frame's encoding_name.
4809 if (!frame->parent()) 4834 if (!frame->parent())
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
4980 // Note: At this stage, the goal is to apply all the modifications the 5005 // Note: At this stage, the goal is to apply all the modifications the
4981 // renderer wants to make to the request, and then send it to the browser, so 5006 // renderer wants to make to the request, and then send it to the browser, so
4982 // that the actual network request can be started. Ideally, all such 5007 // that the actual network request can be started. Ideally, all such
4983 // modifications should take place in willSendRequest, and in the 5008 // modifications should take place in willSendRequest, and in the
4984 // implementation of willSendRequest for the various InspectorAgents 5009 // implementation of willSendRequest for the various InspectorAgents
4985 // (devtools). 5010 // (devtools).
4986 // 5011 //
4987 // TODO(clamy): Apply devtools override. 5012 // TODO(clamy): Apply devtools override.
4988 // TODO(clamy): Make sure that navigation requests are not modified somewhere 5013 // TODO(clamy): Make sure that navigation requests are not modified somewhere
4989 // else in blink. 5014 // else in blink.
5015
5016 base::TimeTicks navigation_start = base::TimeTicks::Now();
clamy 2015/11/03 13:33:00 I don't think this is needed. None of the function
5017
4990 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); 5018 willSendRequest(frame_, 0, *request, blink::WebURLResponse());
4991 5019
4992 // TODO(clamy): Same-document navigations should not be sent back to the 5020 // TODO(clamy): Same-document navigations should not be sent back to the
4993 // browser. 5021 // browser.
4994 // TODO(clamy): Data urls should not be sent back to the browser either. 5022 // TODO(clamy): Data urls should not be sent back to the browser either.
4995 bool should_replace_current_entry = false; 5023 bool should_replace_current_entry = false;
4996 WebDataSource* provisional_data_source = frame_->provisionalDataSource(); 5024 WebDataSource* provisional_data_source = frame_->provisionalDataSource();
4997 WebDataSource* current_data_source = frame_->dataSource(); 5025 WebDataSource* current_data_source = frame_->dataSource();
4998 WebDataSource* data_source = 5026 WebDataSource* data_source =
4999 provisional_data_source ? provisional_data_source : current_data_source; 5027 provisional_data_source ? provisional_data_source : current_data_source;
(...skipping 13 matching lines...) Expand all
5013 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == 5041 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) ==
5014 FetchRedirectMode::MANUAL_MODE); 5042 FetchRedirectMode::MANUAL_MODE);
5015 DCHECK(frame_->parent() || 5043 DCHECK(frame_->parent() ||
5016 GetRequestContextFrameTypeForWebURLRequest(*request) == 5044 GetRequestContextFrameTypeForWebURLRequest(*request) ==
5017 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 5045 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
5018 DCHECK(!frame_->parent() || 5046 DCHECK(!frame_->parent() ||
5019 GetRequestContextFrameTypeForWebURLRequest(*request) == 5047 GetRequestContextFrameTypeForWebURLRequest(*request) ==
5020 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 5048 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
5021 5049
5022 Send(new FrameHostMsg_BeginNavigation( 5050 Send(new FrameHostMsg_BeginNavigation(
5023 routing_id_, 5051 routing_id_, MakeCommonNavigationParams(
5024 MakeCommonNavigationParams(request, should_replace_current_entry), 5052 request, should_replace_current_entry, navigation_start),
5025 BeginNavigationParams( 5053 BeginNavigationParams(
5026 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), 5054 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
5027 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), 5055 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(),
5028 request->skipServiceWorker(), 5056 request->skipServiceWorker(),
5029 GetRequestContextTypeForWebURLRequest(*request)), 5057 GetRequestContextTypeForWebURLRequest(*request)),
5030 GetRequestBodyForWebURLRequest(*request))); 5058 GetRequestBodyForWebURLRequest(*request)));
5031 } 5059 }
5032 5060
5033 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 5061 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
5034 WebFrame* frame) { 5062 WebFrame* frame) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
5287 mojo::ServiceProviderPtr service_provider; 5315 mojo::ServiceProviderPtr service_provider;
5288 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5316 mojo::URLRequestPtr request(mojo::URLRequest::New());
5289 request->url = mojo::String::From(url); 5317 request->url = mojo::String::From(url);
5290 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5318 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5291 nullptr, nullptr, 5319 nullptr, nullptr,
5292 base::Bind(&OnGotContentHandlerID)); 5320 base::Bind(&OnGotContentHandlerID));
5293 return service_provider.Pass(); 5321 return service_provider.Pass();
5294 } 5322 }
5295 5323
5296 } // namespace content 5324 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698