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

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: revert unwanted 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | webkit/glue/weburlrequest_extradata_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3969 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 3980
3981 void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) { 3981 void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) {
3982 StartNavStateSyncTimerIfNecessary(); 3982 StartNavStateSyncTimerIfNecessary();
3983 } 3983 }
3984 3984
3985 void RenderViewImpl::assignIdentifierToRequest( 3985 void RenderViewImpl::assignIdentifierToRequest(
3986 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { 3986 WebFrame* frame, unsigned identifier, const WebURLRequest& request) {
3987 // Ignore 3987 // Ignore
3988 } 3988 }
3989 3989
3990 void RenderViewImpl::willRequestAfterPreconnect(WebFrame* frame,
3991 WebURLRequest& request) {
3992 WebKit::WebReferrerPolicy referrer_policy = WebKit::WebReferrerPolicyDefault;
3993 WebString custom_user_agent;
3994
3995 if(request.extraData()) {
jam 2013/07/26 04:59:39 nit: "if ("
kouhei (in TOK) 2013/07/26 10:50:02 Done.
3996 // This will only be called before willSendRequest, so only ExtraData
3997 // members we have to copy here is on WebURLRequestExtraDataImpl.
3998 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data =
3999 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
4000 request.extraData());
4001
4002 referrer_policy = old_extra_data->referrer_policy();
4003 custom_user_agent = old_extra_data->custom_user_agent();
4004 }
4005
4006 bool was_after_preconnect_request = true;
4007 // The args after |was_after_preconnect_request| are not used, and set to
4008 // correct values at |willSendRequest|.
4009 request.setExtraData(new webkit_glue::WebURLRequestExtraDataImpl(
4010 referrer_policy, custom_user_agent, was_after_preconnect_request));
4011 }
4012
3990 void RenderViewImpl::willSendRequest(WebFrame* frame, 4013 void RenderViewImpl::willSendRequest(WebFrame* frame,
3991 unsigned identifier, 4014 unsigned identifier,
3992 WebURLRequest& request, 4015 WebURLRequest& request,
3993 const WebURLResponse& redirect_response) { 4016 const WebURLResponse& redirect_response) {
3994 // The request my be empty during tests. 4017 // The request my be empty during tests.
3995 if (request.url().isEmpty()) 4018 if (request.url().isEmpty())
3996 return; 4019 return;
3997 4020
3998 WebFrame* top_frame = frame->top(); 4021 WebFrame* top_frame = frame->top();
3999 if (!top_frame) 4022 if (!top_frame)
(...skipping 30 matching lines...) Expand all
4030 referrer_policy = internal_data->referrer_policy(); 4053 referrer_policy = internal_data->referrer_policy();
4031 internal_data->clear_referrer_policy(); 4054 internal_data->clear_referrer_policy();
4032 } else { 4055 } else {
4033 referrer_policy = frame->document().referrerPolicy(); 4056 referrer_policy = frame->document().referrerPolicy();
4034 } 4057 }
4035 4058
4036 // The request's extra data may indicate that we should set a custom user 4059 // The request's extra data may indicate that we should set a custom user
4037 // agent. This needs to be done here, after WebKit is through with setting the 4060 // agent. This needs to be done here, after WebKit is through with setting the
4038 // user agent on its own. 4061 // user agent on its own.
4039 WebString custom_user_agent; 4062 WebString custom_user_agent;
4063 bool was_after_preconnect_request = false;
4040 if (request.extraData()) { 4064 if (request.extraData()) {
4041 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = 4065 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data =
4042 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( 4066 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
4043 request.extraData()); 4067 request.extraData());
4044 custom_user_agent = old_extra_data->custom_user_agent(); 4068 custom_user_agent = old_extra_data->custom_user_agent();
4069 was_after_preconnect_request =
4070 old_extra_data->was_after_preconnect_request();
4045 4071
4046 if (!custom_user_agent.isNull()) { 4072 if (!custom_user_agent.isNull()) {
4047 if (custom_user_agent.isEmpty()) 4073 if (custom_user_agent.isEmpty())
4048 request.clearHTTPHeaderField("User-Agent"); 4074 request.clearHTTPHeaderField("User-Agent");
4049 else 4075 else
4050 request.setHTTPHeaderField("User-Agent", custom_user_agent); 4076 request.setHTTPHeaderField("User-Agent", custom_user_agent);
4051 } 4077 }
4052 } 4078 }
4053 4079
4054 request.setExtraData( 4080 request.setExtraData(
4055 new RequestExtraData(referrer_policy, 4081 new RequestExtraData(referrer_policy,
4056 custom_user_agent, 4082 custom_user_agent,
4083 was_after_preconnect_request,
4057 (frame == top_frame), 4084 (frame == top_frame),
4058 frame->identifier(), 4085 frame->identifier(),
4059 frame->parent() == top_frame, 4086 frame->parent() == top_frame,
4060 frame->parent() ? frame->parent()->identifier() : -1, 4087 frame->parent() ? frame->parent()->identifier() : -1,
4061 navigation_state->allow_download(), 4088 navigation_state->allow_download(),
4062 transition_type, 4089 transition_type,
4063 navigation_state->transferred_request_child_id(), 4090 navigation_state->transferred_request_child_id(),
4064 navigation_state->transferred_request_request_id())); 4091 navigation_state->transferred_request_request_id()));
4065 4092
4066 DocumentState* top_document_state = 4093 DocumentState* top_document_state =
4067 DocumentState::FromDataSource(top_data_source); 4094 DocumentState::FromDataSource(top_data_source);
4068 // TODO(gavinp): separate out prefetching and prerender field trials 4095 if (top_document_state) {
4069 // if the rel=prerender rel type is sticking around. 4096 // TODO(gavinp): separate out prefetching and prerender field trials
4070 if (top_document_state && 4097 // if the rel=prerender rel type is sticking around.
4071 request.targetType() == WebURLRequest::TargetIsPrefetch) 4098 if(request.targetType() == WebURLRequest::TargetIsPrefetch)
jam 2013/07/26 04:59:39 ditto and also below
kouhei (in TOK) 2013/07/26 10:50:02 Done.
4072 top_document_state->set_was_prefetcher(true); 4099 top_document_state->set_was_prefetcher(true);
4100
4101 if(was_after_preconnect_request)
4102 top_document_state->set_was_after_preconnect_request(true);
4103 }
4073 4104
4074 request.setRequestorID(routing_id_); 4105 request.setRequestorID(routing_id_);
4075 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); 4106 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
4076 4107
4077 if (!navigation_state->extra_headers().empty()) { 4108 if (!navigation_state->extra_headers().empty()) {
4078 for (net::HttpUtil::HeadersIterator i( 4109 for (net::HttpUtil::HeadersIterator i(
4079 navigation_state->extra_headers().begin(), 4110 navigation_state->extra_headers().begin(),
4080 navigation_state->extra_headers().end(), "\n"); 4111 navigation_state->extra_headers().end(), "\n");
4081 i.GetNext(); ) { 4112 i.GetNext(); ) {
4082 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), 4113 request.setHTTPHeaderField(WebString::fromUTF8(i.name()),
(...skipping 2656 matching lines...) Expand 10 before | Expand all | Expand 10 after
6739 WebURL url = icon_urls[i].iconURL(); 6770 WebURL url = icon_urls[i].iconURL();
6740 if (!url.isEmpty()) 6771 if (!url.isEmpty())
6741 urls.push_back(FaviconURL(url, 6772 urls.push_back(FaviconURL(url,
6742 ToFaviconType(icon_urls[i].iconType()))); 6773 ToFaviconType(icon_urls[i].iconType())));
6743 } 6774 }
6744 SendUpdateFaviconURL(urls); 6775 SendUpdateFaviconURL(urls);
6745 } 6776 }
6746 6777
6747 6778
6748 } // namespace content 6779 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | webkit/glue/weburlrequest_extradata_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698