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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 27ee8d887a52d8fb345f4d6732a7dec40965a50b..2cb7da531edfa807d4556e4eadb83d4a5344850b 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -428,6 +428,18 @@ static WebReferrerPolicy GetReferrerPolicyFromRequest(
frame->document().referrerPolicy();
}
+static RequestExtraData* GetExtraDataFromRequest(
+ const WebURLRequest& request) {
+ webkit_glue::WebURLRequestExtraDataImpl* extra_data_base =
+ static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
+ request.extraData());
+ if(extra_data_base &&
+ extra_data_base->type_id() == RequestExtraData::kType)
+ return reinterpret_cast<RequestExtraData*>(extra_data_base);
+ else
+ return NULL;
+}
+
static WebURLResponseExtraDataImpl* GetExtraDataFromResponse(
const WebURLResponse& response) {
return static_cast<WebURLResponseExtraDataImpl*>(
@@ -3404,7 +3416,6 @@ void RenderViewImpl::didCompleteClientRedirect(
void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) {
bool content_initiated = !pending_navigation_params_.get();
-
DocumentState* document_state = DocumentState::FromDataSource(ds);
if (!document_state) {
document_state = new DocumentState;
@@ -4000,6 +4011,31 @@ void RenderViewImpl::assignIdentifierToRequest(
// Ignore
}
+void RenderViewImpl::willRequestAfterPreconnect(WebFrame* frame,
+ WebURLRequest& request) {
+ WebString custom_user_agent;
+
+ if(request.extraData()) {
+ // This will only be called before willSendRequest, so only ExtraData
+ // members we have to copy here is on WebURLRequestExtraDataImpl.
+ webkit_glue::WebURLRequestExtraDataImpl* old_extra_data =
+ static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
+ request.extraData());
+ DCHECK(webkit_glue::WebURLRequestExtraDataImpl::kType ==
+ old_extra_data->type_id());
+
+ custom_user_agent = old_extra_data->custom_user_agent();
+ }
+
+ bool was_after_preconnect_request = true;
+ // The args after |was_after_preconnect_request| are not used, and set to
+ // correct values at |willSendRequest|.
+ request.setExtraData(
+ new RequestExtraData(WebKit::WebReferrerPolicyDefault, custom_user_agent,
+ was_after_preconnect_request, true, 0, false, -1,
+ true, PAGE_TRANSITION_LINK, -1, -1));
+}
+
void RenderViewImpl::willSendRequest(WebFrame* frame,
unsigned identifier,
WebURLRequest& request,
@@ -4064,9 +4100,16 @@ void RenderViewImpl::willSendRequest(WebFrame* frame,
}
}
+ bool was_after_preconnect_request = false;
+ RequestExtraData* old_extra_data = GetExtraDataFromRequest(request);
+ if(old_extra_data)
+ was_after_preconnect_request =
+ old_extra_data->was_after_preconnect_request();
+
request.setExtraData(
new RequestExtraData(referrer_policy,
custom_user_agent,
+ was_after_preconnect_request,
(frame == top_frame),
frame->identifier(),
frame->parent() == top_frame,
@@ -4078,11 +4121,15 @@ void RenderViewImpl::willSendRequest(WebFrame* frame,
DocumentState* top_document_state =
DocumentState::FromDataSource(top_data_source);
- // TODO(gavinp): separate out prefetching and prerender field trials
- // if the rel=prerender rel type is sticking around.
- if (top_document_state &&
- request.targetType() == WebURLRequest::TargetIsPrefetch)
- top_document_state->set_was_prefetcher(true);
+ if (top_document_state) {
+ // TODO(gavinp): separate out prefetching and prerender field trials
+ // if the rel=prerender rel type is sticking around.
+ if(request.targetType() == WebURLRequest::TargetIsPrefetch)
+ top_document_state->set_was_prefetcher(true);
+
+ if(was_after_preconnect_request)
+ top_document_state->set_was_after_preconnect_request(true);
+ }
request.setRequestorID(routing_id_);
request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());

Powered by Google App Engine
This is Rietveld 408576698