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

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

Issue 18601004: Add the UMA PLT.BeginToFinish{,Doc}_AfterPreconnectRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: follow interface change Created 7 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 421 }
422 422
423 static WebReferrerPolicy GetReferrerPolicyFromRequest( 423 static WebReferrerPolicy GetReferrerPolicyFromRequest(
424 WebFrame* frame, 424 WebFrame* frame,
425 const WebURLRequest& request) { 425 const WebURLRequest& request) {
426 return request.extraData() ? 426 return request.extraData() ?
427 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : 427 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() :
428 frame->document().referrerPolicy(); 428 frame->document().referrerPolicy();
429 } 429 }
430 430
431 static RequestExtraData* GetExtraDataFromRequest(
432 const WebURLRequest& request) {
433 webkit_glue::WebURLRequestExtraDataImpl* extra_data_base =
434 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
435 request.extraData());
436 if(extra_data_base &&
437 extra_data_base->type_id() == RequestExtraData::kType)
438 return reinterpret_cast<RequestExtraData*>(extra_data_base);
439 else
440 return NULL;
441 }
442
431 static WebURLResponseExtraDataImpl* GetExtraDataFromResponse( 443 static WebURLResponseExtraDataImpl* GetExtraDataFromResponse(
432 const WebURLResponse& response) { 444 const WebURLResponse& response) {
433 return static_cast<WebURLResponseExtraDataImpl*>( 445 return static_cast<WebURLResponseExtraDataImpl*>(
434 response.extraData()); 446 response.extraData());
435 } 447 }
436 448
437 NOINLINE static void CrashIntentionally() { 449 NOINLINE static void CrashIntentionally() {
438 // NOTE(shess): Crash directly rather than using NOTREACHED() so 450 // NOTE(shess): Crash directly rather than using NOTREACHED() so
439 // that the signature is easier to triage in crash reports. 451 // that the signature is easier to triage in crash reports.
440 volatile int* zero = NULL; 452 volatile int* zero = NULL;
(...skipping 2956 matching lines...) Expand 10 before | Expand all | Expand 10 after
3397 ds ? GetReferrerPolicyFromRequest(frame, ds->request()) : 3409 ds ? GetReferrerPolicyFromRequest(frame, ds->request()) :
3398 frame->document().referrerPolicy()); 3410 frame->document().referrerPolicy());
3399 } 3411 }
3400 FOR_EACH_OBSERVER( 3412 FOR_EACH_OBSERVER(
3401 RenderViewObserver, observers_, DidCompleteClientRedirect( 3413 RenderViewObserver, observers_, DidCompleteClientRedirect(
3402 frame, from == GURL(kSwappedOutURL) ? blank_url : from)); 3414 frame, from == GURL(kSwappedOutURL) ? blank_url : from));
3403 } 3415 }
3404 3416
3405 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { 3417 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) {
3406 bool content_initiated = !pending_navigation_params_.get(); 3418 bool content_initiated = !pending_navigation_params_.get();
3407
3408 DocumentState* document_state = DocumentState::FromDataSource(ds); 3419 DocumentState* document_state = DocumentState::FromDataSource(ds);
3409 if (!document_state) { 3420 if (!document_state) {
3410 document_state = new DocumentState; 3421 document_state = new DocumentState;
3411 ds->setExtraData(document_state); 3422 ds->setExtraData(document_state);
3412 if (!content_initiated) 3423 if (!content_initiated)
3413 PopulateDocumentStateFromPending(document_state); 3424 PopulateDocumentStateFromPending(document_state);
3414 } 3425 }
3415 3426
3416 // Carry over the user agent override flag, if it exists. 3427 // Carry over the user agent override flag, if it exists.
3417 if (content_initiated && webview() && webview()->mainFrame() && 3428 if (content_initiated && webview() && webview()->mainFrame() &&
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 4004
3994 void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) { 4005 void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) {
3995 StartNavStateSyncTimerIfNecessary(); 4006 StartNavStateSyncTimerIfNecessary();
3996 } 4007 }
3997 4008
3998 void RenderViewImpl::assignIdentifierToRequest( 4009 void RenderViewImpl::assignIdentifierToRequest(
3999 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { 4010 WebFrame* frame, unsigned identifier, const WebURLRequest& request) {
4000 // Ignore 4011 // Ignore
4001 } 4012 }
4002 4013
4014 void RenderViewImpl::willRequestAfterPreconnect(WebFrame* frame,
4015 WebURLRequest& request) {
4016 WebString custom_user_agent;
4017
4018 if(request.extraData()) {
4019 // This will only be called before willSendRequest, so only ExtraData
4020 // members we have to copy here is on WebURLRequestExtraDataImpl.
4021 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data =
4022 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
4023 request.extraData());
4024 DCHECK(webkit_glue::WebURLRequestExtraDataImpl::kType ==
4025 old_extra_data->type_id());
4026
4027 custom_user_agent = old_extra_data->custom_user_agent();
4028 }
4029
4030 bool was_after_preconnect_request = true;
4031 // The args after |was_after_preconnect_request| are not used, and set to
4032 // correct values at |willSendRequest|.
4033 request.setExtraData(
4034 new RequestExtraData(WebKit::WebReferrerPolicyDefault, custom_user_agent,
4035 was_after_preconnect_request, true, 0, false, -1,
4036 true, PAGE_TRANSITION_LINK, -1, -1));
4037 }
4038
4003 void RenderViewImpl::willSendRequest(WebFrame* frame, 4039 void RenderViewImpl::willSendRequest(WebFrame* frame,
4004 unsigned identifier, 4040 unsigned identifier,
4005 WebURLRequest& request, 4041 WebURLRequest& request,
4006 const WebURLResponse& redirect_response) { 4042 const WebURLResponse& redirect_response) {
4007 // The request my be empty during tests. 4043 // The request my be empty during tests.
4008 if (request.url().isEmpty()) 4044 if (request.url().isEmpty())
4009 return; 4045 return;
4010 4046
4011 WebFrame* top_frame = frame->top(); 4047 WebFrame* top_frame = frame->top();
4012 if (!top_frame) 4048 if (!top_frame)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4057 custom_user_agent = old_extra_data->custom_user_agent(); 4093 custom_user_agent = old_extra_data->custom_user_agent();
4058 4094
4059 if (!custom_user_agent.isNull()) { 4095 if (!custom_user_agent.isNull()) {
4060 if (custom_user_agent.isEmpty()) 4096 if (custom_user_agent.isEmpty())
4061 request.clearHTTPHeaderField("User-Agent"); 4097 request.clearHTTPHeaderField("User-Agent");
4062 else 4098 else
4063 request.setHTTPHeaderField("User-Agent", custom_user_agent); 4099 request.setHTTPHeaderField("User-Agent", custom_user_agent);
4064 } 4100 }
4065 } 4101 }
4066 4102
4103 bool was_after_preconnect_request = false;
4104 RequestExtraData* old_extra_data = GetExtraDataFromRequest(request);
4105 if(old_extra_data)
4106 was_after_preconnect_request =
4107 old_extra_data->was_after_preconnect_request();
4108
4067 request.setExtraData( 4109 request.setExtraData(
4068 new RequestExtraData(referrer_policy, 4110 new RequestExtraData(referrer_policy,
4069 custom_user_agent, 4111 custom_user_agent,
4112 was_after_preconnect_request,
4070 (frame == top_frame), 4113 (frame == top_frame),
4071 frame->identifier(), 4114 frame->identifier(),
4072 frame->parent() == top_frame, 4115 frame->parent() == top_frame,
4073 frame->parent() ? frame->parent()->identifier() : -1, 4116 frame->parent() ? frame->parent()->identifier() : -1,
4074 navigation_state->allow_download(), 4117 navigation_state->allow_download(),
4075 transition_type, 4118 transition_type,
4076 navigation_state->transferred_request_child_id(), 4119 navigation_state->transferred_request_child_id(),
4077 navigation_state->transferred_request_request_id())); 4120 navigation_state->transferred_request_request_id()));
4078 4121
4079 DocumentState* top_document_state = 4122 DocumentState* top_document_state =
4080 DocumentState::FromDataSource(top_data_source); 4123 DocumentState::FromDataSource(top_data_source);
4081 // TODO(gavinp): separate out prefetching and prerender field trials 4124 if (top_document_state) {
4082 // if the rel=prerender rel type is sticking around. 4125 // TODO(gavinp): separate out prefetching and prerender field trials
4083 if (top_document_state && 4126 // if the rel=prerender rel type is sticking around.
4084 request.targetType() == WebURLRequest::TargetIsPrefetch) 4127 if(request.targetType() == WebURLRequest::TargetIsPrefetch)
4085 top_document_state->set_was_prefetcher(true); 4128 top_document_state->set_was_prefetcher(true);
4129
4130 if(was_after_preconnect_request)
4131 top_document_state->set_was_after_preconnect_request(true);
4132 }
4086 4133
4087 request.setRequestorID(routing_id_); 4134 request.setRequestorID(routing_id_);
4088 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); 4135 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
4089 4136
4090 if (!navigation_state->extra_headers().empty()) { 4137 if (!navigation_state->extra_headers().empty()) {
4091 for (net::HttpUtil::HeadersIterator i( 4138 for (net::HttpUtil::HeadersIterator i(
4092 navigation_state->extra_headers().begin(), 4139 navigation_state->extra_headers().begin(),
4093 navigation_state->extra_headers().end(), "\n"); 4140 navigation_state->extra_headers().end(), "\n");
4094 i.GetNext(); ) { 4141 i.GetNext(); ) {
4095 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), 4142 request.setHTTPHeaderField(WebString::fromUTF8(i.name()),
(...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after
6820 WebURL url = icon_urls[i].iconURL(); 6867 WebURL url = icon_urls[i].iconURL();
6821 if (!url.isEmpty()) 6868 if (!url.isEmpty())
6822 urls.push_back(FaviconURL(url, 6869 urls.push_back(FaviconURL(url,
6823 ToFaviconType(icon_urls[i].iconType()))); 6870 ToFaviconType(icon_urls[i].iconType())));
6824 } 6871 }
6825 SendUpdateFaviconURL(urls); 6872 SendUpdateFaviconURL(urls);
6826 } 6873 }
6827 6874
6828 6875
6829 } // namespace content 6876 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698