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

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: Cleanup (trybots previous) 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::didCreateDataSource(blink::WebLocalFrame* frame, 2551 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame,
clamy 2015/11/02 17:34:35 Do we also create the DataSource in same-page navi
Charlie Harrison 2015/11/02 18:19:10 You're right, we don't create a new data source. W
2552 blink::WebDataSource* datasource) { 2552 blink::WebDataSource* datasource) {
2553 DCHECK(!frame_ || frame_ == frame); 2553 DCHECK(!frame_ || frame_ == frame);
2554 2554
2555 bool content_initiated = !pending_navigation_params_.get(); 2555 bool content_initiated = !pending_navigation_params_.get();
2556 2556
2557 // Make sure any previous redirect URLs end up in our new data source. 2557 // Make sure any previous redirect URLs end up in our new data source.
2558 if (pending_navigation_params_.get()) { 2558 if (pending_navigation_params_.get()) {
2559 for (const auto& i : 2559 for (const auto& i :
2560 pending_navigation_params_->request_params.redirects) { 2560 pending_navigation_params_->request_params.redirects) {
2561 datasource->appendRedirect(i); 2561 datasource->appendRedirect(i);
2562 } 2562 }
2563 } 2563 }
2564 2564
2565 bool was_same_page = false;
2566
2565 DocumentState* document_state = DocumentState::FromDataSource(datasource); 2567 DocumentState* document_state = DocumentState::FromDataSource(datasource);
2566 if (!document_state) { 2568 if (!document_state) {
2567 document_state = new DocumentState; 2569 document_state = new DocumentState;
2568 datasource->setExtraData(document_state); 2570 datasource->setExtraData(document_state);
2569 if (!content_initiated) 2571 if (!content_initiated)
2570 PopulateDocumentStateFromPending(document_state); 2572 PopulateDocumentStateFromPending(document_state);
2573 } else if(document_state->navigation_state()) {
2574 // We set was_within_same_page in didNavigateWithinPage, to properly
2575 // set navigationStart in blink and update the new NavigationState.
2576 was_same_page = document_state->navigation_state()->WasWithinSamePage();
2571 } 2577 }
2572 2578
2573 // Carry over the user agent override flag, if it exists. 2579 // Carry over the user agent override flag, if it exists.
2574 blink::WebView* webview = render_view_->webview(); 2580 blink::WebView* webview = render_view_->webview();
2575 if (content_initiated && webview && webview->mainFrame() && 2581 if (content_initiated && webview && webview->mainFrame() &&
2576 webview->mainFrame()->isWebLocalFrame() && 2582 webview->mainFrame()->isWebLocalFrame() &&
2577 webview->mainFrame()->dataSource()) { 2583 webview->mainFrame()->dataSource()) {
2578 DocumentState* old_document_state = 2584 DocumentState* old_document_state =
2579 DocumentState::FromDataSource(webview->mainFrame()->dataSource()); 2585 DocumentState::FromDataSource(webview->mainFrame()->dataSource());
2580 if (old_document_state) { 2586 if (old_document_state) {
2581 InternalDocumentStateData* internal_data = 2587 InternalDocumentStateData* internal_data =
2582 InternalDocumentStateData::FromDocumentState(document_state); 2588 InternalDocumentStateData::FromDocumentState(document_state);
2583 InternalDocumentStateData* old_internal_data = 2589 InternalDocumentStateData* old_internal_data =
2584 InternalDocumentStateData::FromDocumentState(old_document_state); 2590 InternalDocumentStateData::FromDocumentState(old_document_state);
2585 internal_data->set_is_overriding_user_agent( 2591 internal_data->set_is_overriding_user_agent(
2586 old_internal_data->is_overriding_user_agent()); 2592 old_internal_data->is_overriding_user_agent());
2587 } 2593 }
2588 } 2594 }
2595 // Note for some browser initiated navigations (i.e. not
2596 // WebFrameLoadType::Standard), we want to record their start time now. These
2597 // navigations will have had common_params.navigation_start set to null.
2598 if (!content_initiated &&
2599 pending_navigation_params_->common_params.navigation_start.is_null()) {
2600 pending_navigation_params_->common_params.navigation_start =
2601 base::TimeTicks::Now();
2602 }
2589 2603
2590 // The rest of RenderView assumes that a WebDataSource will always have a 2604 // The rest of RenderView assumes that a WebDataSource will always have a
2591 // non-null NavigationState. 2605 // non-null NavigationState.
2592 if (content_initiated) { 2606 NavigationStateImpl* navigation_state =
2593 document_state->set_navigation_state( 2607 content_initiated ? NavigationStateImpl::CreateContentInitiated()
2594 NavigationStateImpl::CreateContentInitiated()); 2608 : CreateNavigationStateFromPending();
2595 } else { 2609 pending_navigation_params_.reset();
2596 document_state->set_navigation_state(CreateNavigationStateFromPending()); 2610 document_state->set_navigation_state(navigation_state);
2597 pending_navigation_params_.reset(); 2611 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2612 ->set_was_within_same_page(was_same_page);
2613
2614 // Set the navigation start time in blink.
2615 if (!was_same_page) {
2616 base::TimeTicks navigation_start =
2617 navigation_state->common_params().navigation_start;
2618 datasource->setNavigationStartTime(
2619 (navigation_start - base::TimeTicks()).InSecondsF());
2598 } 2620 }
2599 2621
2600 // DocumentState::referred_by_prefetcher_ is true if we are 2622 // DocumentState::referred_by_prefetcher_ is true if we are
2601 // navigating from a page that used prefetching using a link on that 2623 // 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 2624 // page. We are early enough in the request process here that we
2603 // can still see the DocumentState of the previous page and set 2625 // can still see the DocumentState of the previous page and set
2604 // this value appropriately. 2626 // this value appropriately.
2605 // TODO(gavinp): catch the important case of navigation in a new 2627 // TODO(gavinp): catch the important case of navigation in a new
2606 // renderer process. 2628 // renderer process.
2607 if (webview) { 2629 if (webview) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 } 2667 }
2646 } 2668 }
2647 2669
2648 // Create the serviceworker's per-document network observing object if it 2670 // Create the serviceworker's per-document network observing object if it
2649 // does not exist (When navigation happens within a page, the provider already 2671 // does not exist (When navigation happens within a page, the provider already
2650 // exists). 2672 // exists).
2651 if (ServiceWorkerNetworkProvider::FromDocumentState( 2673 if (ServiceWorkerNetworkProvider::FromDocumentState(
2652 DocumentState::FromDataSource(datasource))) 2674 DocumentState::FromDataSource(datasource)))
2653 return; 2675 return;
2654 2676
2655 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
2656 DocumentState::FromDataSource(datasource)->navigation_state());
2657
2658 ServiceWorkerNetworkProvider::AttachToDocumentState( 2677 ServiceWorkerNetworkProvider::AttachToDocumentState(
2659 DocumentState::FromDataSource(datasource), 2678 DocumentState::FromDataSource(datasource),
2660 ServiceWorkerNetworkProvider::CreateForNavigation( 2679 ServiceWorkerNetworkProvider::CreateForNavigation(
2661 routing_id_, navigation_state->request_params(), 2680 routing_id_, navigation_state->request_params(),
2662 frame->effectiveSandboxFlags(), content_initiated)); 2681 frame->effectiveSandboxFlags(), content_initiated));
2663 } 2682 }
2664 2683
2665 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, 2684 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame,
2666 double triggering_event_time) { 2685 double triggering_event_time) {
2667 DCHECK(!frame_ || frame_ == frame); 2686 DCHECK(!frame_ || frame_ == frame);
(...skipping 28 matching lines...) Expand all
2696 WebUserGestureIndicator::isProcessingUserGesture() ? 2715 WebUserGestureIndicator::isProcessingUserGesture() ?
2697 NavigationGestureUser : NavigationGestureAuto); 2716 NavigationGestureUser : NavigationGestureAuto);
2698 } else if (ds->replacesCurrentHistoryItem()) { 2717 } else if (ds->replacesCurrentHistoryItem()) {
2699 // Subframe navigations that don't add session history items must be 2718 // Subframe navigations that don't add session history items must be
2700 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2719 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2701 // handle loading of error pages. 2720 // handle loading of error pages.
2702 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 2721 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2703 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2722 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2704 } 2723 }
2705 2724
2725 // Get the navigation start in TimeTicks format. This will be
2726 // lossy because blink converts TimeTicks internal int64 representation to a
2727 // double. TODO(csharrison) Do we want to override this with the TimeTicks
2728 // timestamp in document_state->navigation_params for browser loads?
2729 DCHECK(ds->getNavigationStartTime());
2730 base::TimeTicks navigation_start = base::TimeTicks::FromInternalValue(
2731 ds->getNavigationStartTime() * base::Time::kMicrosecondsPerSecond);
2732
2706 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2733 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2707 DidStartProvisionalLoad(frame)); 2734 DidStartProvisionalLoad(frame));
2708 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2735 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2709 2736
2710 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2737 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2711 routing_id_, ds->request().url())); 2738 routing_id_, ds->request().url(), navigation_start));
2712 } 2739 }
2713 2740
2714 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 2741 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
2715 blink::WebLocalFrame* frame) { 2742 blink::WebLocalFrame* frame) {
2716 DCHECK(!frame_ || frame_ == frame); 2743 DCHECK(!frame_ || frame_ == frame);
2717 render_view_->history_controller()->RemoveChildrenForRedirect(this); 2744 render_view_->history_controller()->RemoveChildrenForRedirect(this);
2718 } 2745 }
2719 2746
2720 void RenderFrameImpl::didFailProvisionalLoad( 2747 void RenderFrameImpl::didFailProvisionalLoad(
2721 blink::WebLocalFrame* frame, 2748 blink::WebLocalFrame* frame,
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 Send(new FrameHostMsg_DidFinishLoad(routing_id_, 3144 Send(new FrameHostMsg_DidFinishLoad(routing_id_,
3118 ds->request().url())); 3145 ds->request().url()));
3119 } 3146 }
3120 3147
3121 void RenderFrameImpl::didNavigateWithinPage(blink::WebLocalFrame* frame, 3148 void RenderFrameImpl::didNavigateWithinPage(blink::WebLocalFrame* frame,
3122 const blink::WebHistoryItem& item, 3149 const blink::WebHistoryItem& item,
3123 blink::WebHistoryCommitType commit_type) { 3150 blink::WebHistoryCommitType commit_type) {
3124 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", 3151 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage",
3125 "id", routing_id_); 3152 "id", routing_id_);
3126 DCHECK(!frame_ || frame_ == frame); 3153 DCHECK(!frame_ || frame_ == frame);
3154
3155 DCHECK(frame->dataSource() && frame->dataSource()->extraData());
3156 // Set was_within_same_page here, so that didCreateDataSource knows not to
3157 // update navigationStart in blink. We propogate the boolean in the newly
3158 // created NavigationState.
3159 DocumentState* document_state =
3160 DocumentState::FromDataSource(frame->dataSource());
3161 static_cast<NavigationStateImpl*>(document_state->navigation_state())
3162 ->set_was_within_same_page(true);
3127 // If this was a reference fragment navigation that we initiated, then we 3163 // 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 3164 // 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 3165 // update the ExtraData on the datasource so that others who read the
3130 // ExtraData will get the new NavigationState. Similarly, if we did not 3166 // 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- 3167 // initiate this navigation, then we need to take care to reset any pre-
3132 // existing navigation state to a content-initiated navigation state. 3168 // existing navigation state to a content-initiated navigation state.
3133 // didCreateDataSource conveniently takes care of this for us. 3169 // didCreateDataSource conveniently takes care of this for us.
3134 didCreateDataSource(frame, frame->dataSource()); 3170 didCreateDataSource(frame, frame->dataSource());
3135
3136 DocumentState* document_state =
3137 DocumentState::FromDataSource(frame->dataSource());
3138 static_cast<NavigationStateImpl*>(document_state->navigation_state())
3139 ->set_was_within_same_page(true);
3140
3141 didCommitProvisionalLoad(frame, item, commit_type); 3171 didCommitProvisionalLoad(frame, item, commit_type);
3142 } 3172 }
3143 3173
3144 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) { 3174 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) {
3145 DCHECK(!frame_ || frame_ == frame); 3175 DCHECK(!frame_ || frame_ == frame);
3146 // TODO(nasko): Move implementation here. Needed methods: 3176 // TODO(nasko): Move implementation here. Needed methods:
3147 // * StartNavStateSyncTimerIfNecessary 3177 // * StartNavStateSyncTimerIfNecessary
3148 render_view_->didUpdateCurrentHistoryItem(frame); 3178 render_view_->didUpdateCurrentHistoryItem(frame);
3149 } 3179 }
3150 3180
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 common_params.url, request_params, &is_reload, &cache_policy); 4340 common_params.url, request_params, &is_reload, &cache_policy);
4311 4341
4312 GetContentClient()->SetActiveURL(common_params.url); 4342 GetContentClient()->SetActiveURL(common_params.url);
4313 4343
4314 pending_navigation_params_.reset(new NavigationParams( 4344 pending_navigation_params_.reset(new NavigationParams(
4315 common_params, StartNavigationParams(), request_params)); 4345 common_params, StartNavigationParams(), request_params));
4316 4346
4317 // Inform the browser of the start of the provisional load. This is needed so 4347 // 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. 4348 // that the load is properly tracked by the WebNavigation API.
4319 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 4349 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
4320 routing_id_, common_params.url)); 4350 routing_id_, common_params.url, common_params.navigation_start));
4321 4351
4322 // Send the provisional load failure. 4352 // Send the provisional load failure.
4323 blink::WebURLError error = 4353 blink::WebURLError error =
4324 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 4354 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
4325 WebURLRequest failed_request = CreateURLRequestForNavigation( 4355 WebURLRequest failed_request = CreateURLRequestForNavigation(
4326 common_params, scoped_ptr<StreamOverrideParameters>(), 4356 common_params, scoped_ptr<StreamOverrideParameters>(),
4327 frame_->isViewSourceModeEnabled()); 4357 frame_->isViewSourceModeEnabled());
4328 SendFailedProvisionalLoad(failed_request, error, frame_); 4358 SendFailedProvisionalLoad(failed_request, error, frame_);
4329 4359
4330 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { 4360 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
4614 } 4644 }
4615 4645
4616 void RenderFrameImpl::NavigateInternal( 4646 void RenderFrameImpl::NavigateInternal(
4617 const CommonNavigationParams& common_params, 4647 const CommonNavigationParams& common_params,
4618 const StartNavigationParams& start_params, 4648 const StartNavigationParams& start_params,
4619 const RequestNavigationParams& request_params, 4649 const RequestNavigationParams& request_params,
4620 scoped_ptr<StreamOverrideParameters> stream_params) { 4650 scoped_ptr<StreamOverrideParameters> stream_params) {
4621 bool browser_side_navigation = 4651 bool browser_side_navigation =
4622 base::CommandLine::ForCurrentProcess()->HasSwitch( 4652 base::CommandLine::ForCurrentProcess()->HasSwitch(
4623 switches::kEnableBrowserSideNavigation); 4653 switches::kEnableBrowserSideNavigation);
4654 // Upper bound for browser initiated navigation start time.
4655 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
4624 bool is_reload = IsReload(common_params.navigation_type); 4656 bool is_reload = IsReload(common_params.navigation_type);
4625 bool is_history_navigation = request_params.page_state.IsValid(); 4657 bool is_history_navigation = request_params.page_state.IsValid();
4626 WebURLRequest::CachePolicy cache_policy = 4658 WebURLRequest::CachePolicy cache_policy =
4627 WebURLRequest::UseProtocolCachePolicy; 4659 WebURLRequest::UseProtocolCachePolicy;
4628 RenderFrameImpl::PrepareRenderViewForNavigation( 4660 RenderFrameImpl::PrepareRenderViewForNavigation(
4629 common_params.url, request_params, &is_reload, &cache_policy); 4661 common_params.url, request_params, &is_reload, &cache_policy);
4630 4662
4631 GetContentClient()->SetActiveURL(common_params.url); 4663 GetContentClient()->SetActiveURL(common_params.url);
4632 4664
4633 // If this frame isn't in the same process as the main frame, it may naively 4665 // 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 4666 // 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 4667 // actually be the case. Inform the frame's state machine if this frame has
4636 // already committed other loads. 4668 // already committed other loads.
4637 if (request_params.has_committed_real_load && frame_->parent()) 4669 if (request_params.has_committed_real_load && frame_->parent())
4638 frame_->setCommittedFirstRealLoad(); 4670 frame_->setCommittedFirstRealLoad();
4639 4671
4640 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 4672 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
4641 // We cannot reload if we do not have any history state. This happens, for 4673 // We cannot reload if we do not have any history state. This happens, for
4642 // example, when recovering from a crash. 4674 // example, when recovering from a crash.
4643 is_reload = false; 4675 is_reload = false;
4644 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 4676 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
4645 } 4677 }
4646 4678
4647 pending_navigation_params_.reset( 4679 pending_navigation_params_.reset(
4648 new NavigationParams(common_params, start_params, request_params)); 4680 new NavigationParams(common_params, start_params, request_params));
4681 // We don't know for sure that this load type is WebFrameLoadType::Standard.
4682 // For now, set this to null, and update it when we are sure of the right
4683 // value.
4684 pending_navigation_params_->common_params.navigation_start =
4685 base::TimeTicks();
4649 4686
4650 // Create parameters for a standard navigation. 4687 // Create parameters for a standard navigation.
4651 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; 4688 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard;
4652 bool should_load_request = false; 4689 bool should_load_request = false;
4653 WebHistoryItem item_for_history_navigation; 4690 WebHistoryItem item_for_history_navigation;
4654 WebURLRequest request = CreateURLRequestForNavigation( 4691 WebURLRequest request = CreateURLRequestForNavigation(
4655 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); 4692 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled());
4656 #if defined(OS_ANDROID) 4693 #if defined(OS_ANDROID)
4657 request.setHasUserGesture(start_params.has_user_gesture); 4694 request.setHasUserGesture(start_params.has_user_gesture);
4658 #endif 4695 #endif
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 request.setHTTPBody(http_body); 4807 request.setHTTPBody(http_body);
4771 } 4808 }
4772 4809
4773 // A session history navigation should have been accompanied by state. 4810 // A session history navigation should have been accompanied by state.
4774 CHECK_EQ(request_params.page_id, -1); 4811 CHECK_EQ(request_params.page_id, -1);
4775 4812
4776 should_load_request = true; 4813 should_load_request = true;
4777 } 4814 }
4778 4815
4779 if (should_load_request) { 4816 if (should_load_request) {
4780 // Record this before starting the load. We need a lower bound of this 4817 // Sanitize navigation start now that we know the load_type.
4781 // time to sanitize the navigationStart override set below. 4818 pending_navigation_params_->common_params.navigation_start =
4782 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 4819 SanitizeNavigationTiming(load_type, common_params.navigation_start,
4783 4820 renderer_navigation_start);
4784 // Perform a navigation to a data url if needed. 4821 // Perform a navigation to a data url if needed.
4785 if (!common_params.base_url_for_data_url.is_empty() || 4822 if (!common_params.base_url_for_data_url.is_empty() ||
4786 (browser_side_navigation && 4823 (browser_side_navigation &&
4787 common_params.url.SchemeIs(url::kDataScheme))) { 4824 common_params.url.SchemeIs(url::kDataScheme))) {
4788 LoadDataURL(common_params, frame_); 4825 LoadDataURL(common_params, frame_);
4789 } else { 4826 } else {
4790 // Load the request. 4827 // Load the request.
4791 frame_->toWebLocalFrame()->load(request, load_type, 4828 frame_->toWebLocalFrame()->load(request, load_type,
4792 item_for_history_navigation); 4829 item_for_history_navigation);
4793 } 4830 }
4794
4795 if (load_type == blink::WebFrameLoadType::Standard) {
4796 UpdateFrameNavigationTiming(frame_,
4797 request_params.browser_navigation_start,
4798 renderer_navigation_start);
4799 }
4800 } 4831 }
4801 4832
4802 // In case LoadRequest failed before didCreateDataSource was called. 4833 // In case LoadRequest failed before didCreateDataSource was called.
4803 pending_navigation_params_.reset(); 4834 pending_navigation_params_.reset();
4804 } 4835 }
4805 4836
4806 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, 4837 void RenderFrameImpl::UpdateEncoding(WebFrame* frame,
4807 const std::string& encoding_name) { 4838 const std::string& encoding_name) {
4808 // Only update main frame's encoding_name. 4839 // Only update main frame's encoding_name.
4809 if (!frame->parent()) 4840 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 5011 // 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 5012 // 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 5013 // that the actual network request can be started. Ideally, all such
4983 // modifications should take place in willSendRequest, and in the 5014 // modifications should take place in willSendRequest, and in the
4984 // implementation of willSendRequest for the various InspectorAgents 5015 // implementation of willSendRequest for the various InspectorAgents
4985 // (devtools). 5016 // (devtools).
4986 // 5017 //
4987 // TODO(clamy): Apply devtools override. 5018 // TODO(clamy): Apply devtools override.
4988 // TODO(clamy): Make sure that navigation requests are not modified somewhere 5019 // TODO(clamy): Make sure that navigation requests are not modified somewhere
4989 // else in blink. 5020 // else in blink.
5021
5022 base::TimeTicks navigation_start = base::TimeTicks::Now();
5023
4990 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); 5024 willSendRequest(frame_, 0, *request, blink::WebURLResponse());
4991 5025
4992 // TODO(clamy): Same-document navigations should not be sent back to the 5026 // TODO(clamy): Same-document navigations should not be sent back to the
4993 // browser. 5027 // browser.
4994 // TODO(clamy): Data urls should not be sent back to the browser either. 5028 // TODO(clamy): Data urls should not be sent back to the browser either.
4995 bool should_replace_current_entry = false; 5029 bool should_replace_current_entry = false;
4996 WebDataSource* provisional_data_source = frame_->provisionalDataSource(); 5030 WebDataSource* provisional_data_source = frame_->provisionalDataSource();
4997 WebDataSource* current_data_source = frame_->dataSource(); 5031 WebDataSource* current_data_source = frame_->dataSource();
4998 WebDataSource* data_source = 5032 WebDataSource* data_source =
4999 provisional_data_source ? provisional_data_source : current_data_source; 5033 provisional_data_source ? provisional_data_source : current_data_source;
(...skipping 13 matching lines...) Expand all
5013 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == 5047 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) ==
5014 FetchRedirectMode::MANUAL_MODE); 5048 FetchRedirectMode::MANUAL_MODE);
5015 DCHECK(frame_->parent() || 5049 DCHECK(frame_->parent() ||
5016 GetRequestContextFrameTypeForWebURLRequest(*request) == 5050 GetRequestContextFrameTypeForWebURLRequest(*request) ==
5017 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); 5051 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL);
5018 DCHECK(!frame_->parent() || 5052 DCHECK(!frame_->parent() ||
5019 GetRequestContextFrameTypeForWebURLRequest(*request) == 5053 GetRequestContextFrameTypeForWebURLRequest(*request) ==
5020 REQUEST_CONTEXT_FRAME_TYPE_NESTED); 5054 REQUEST_CONTEXT_FRAME_TYPE_NESTED);
5021 5055
5022 Send(new FrameHostMsg_BeginNavigation( 5056 Send(new FrameHostMsg_BeginNavigation(
5023 routing_id_, 5057 routing_id_, MakeCommonNavigationParams(
5024 MakeCommonNavigationParams(request, should_replace_current_entry), 5058 request, should_replace_current_entry, navigation_start),
5025 BeginNavigationParams( 5059 BeginNavigationParams(
5026 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), 5060 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
5027 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(), 5061 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture(),
5028 request->skipServiceWorker(), 5062 request->skipServiceWorker(),
5029 GetRequestContextTypeForWebURLRequest(*request)), 5063 GetRequestContextTypeForWebURLRequest(*request)),
5030 GetRequestBodyForWebURLRequest(*request))); 5064 GetRequestBodyForWebURLRequest(*request)));
5031 } 5065 }
5032 5066
5033 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 5067 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
5034 WebFrame* frame) { 5068 WebFrame* frame) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5140 5174
5141 internal_data->set_is_overriding_user_agent( 5175 internal_data->set_is_overriding_user_agent(
5142 pending_navigation_params_->request_params.is_overriding_user_agent); 5176 pending_navigation_params_->request_params.is_overriding_user_agent);
5143 internal_data->set_must_reset_scroll_and_scale_state( 5177 internal_data->set_must_reset_scroll_and_scale_state(
5144 pending_navigation_params_->common_params.navigation_type == 5178 pending_navigation_params_->common_params.navigation_type ==
5145 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 5179 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
5146 document_state->set_can_load_local_resources( 5180 document_state->set_can_load_local_resources(
5147 pending_navigation_params_->request_params.can_load_local_resources); 5181 pending_navigation_params_->request_params.can_load_local_resources);
5148 } 5182 }
5149 5183
5150 NavigationState* RenderFrameImpl::CreateNavigationStateFromPending() { 5184 NavigationStateImpl* RenderFrameImpl::CreateNavigationStateFromPending() {
5151 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5185 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5152 return NavigationStateImpl::CreateBrowserInitiated( 5186 return NavigationStateImpl::CreateBrowserInitiated(
5153 pending_navigation_params_->common_params, 5187 pending_navigation_params_->common_params,
5154 pending_navigation_params_->start_params, 5188 pending_navigation_params_->start_params,
5155 pending_navigation_params_->request_params); 5189 pending_navigation_params_->request_params);
5156 } 5190 }
5157 return NavigationStateImpl::CreateContentInitiated(); 5191 return NavigationStateImpl::CreateContentInitiated();
5158 } 5192 }
5159 5193
5160 #if defined(OS_ANDROID) 5194 #if defined(OS_ANDROID)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
5287 mojo::ServiceProviderPtr service_provider; 5321 mojo::ServiceProviderPtr service_provider;
5288 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5322 mojo::URLRequestPtr request(mojo::URLRequest::New());
5289 request->url = mojo::String::From(url); 5323 request->url = mojo::String::From(url);
5290 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5324 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5291 nullptr, nullptr, 5325 nullptr, nullptr,
5292 base::Bind(&OnGotContentHandlerID)); 5326 base::Bind(&OnGotContentHandlerID));
5293 return service_provider.Pass(); 5327 return service_provider.Pass();
5294 } 5328 }
5295 5329
5296 } // namespace content 5330 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698