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

Side by Side Diff: net/url_request/url_request.cc

Issue 13653003: Fix a load timing bug in the case of SPDY session reuse (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « net/base/load_timing_info.h ('k') | net/url_request/url_request_job.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 "net/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 base::AutoLock lock(g_next_url_request_identifier_lock.Get()); 67 base::AutoLock lock(g_next_url_request_identifier_lock.Get());
68 return g_next_url_request_identifier++; 68 return g_next_url_request_identifier++;
69 } 69 }
70 70
71 // True once the first URLRequest was started. 71 // True once the first URLRequest was started.
72 bool g_url_requests_started = false; 72 bool g_url_requests_started = false;
73 73
74 // True if cookies are accepted by default. 74 // True if cookies are accepted by default.
75 bool g_default_can_use_cookies = true; 75 bool g_default_can_use_cookies = true;
76 76
77 // When the URLRequest first assempts load timing information, it has the times
78 // at which each event occurred. The API requires the time which the request
79 // was blocked on each phase. This function handles the conversion.
80 //
81 // In the case of reusing a SPDY session or HTTP pipeline, old proxy results may
82 // have been reused, so proxy resolution times may be before the request was
83 // started.
84 //
85 // Due to preconnect and late binding, it is also possible for the connection
86 // attempt to start before a request has been started, or proxy resolution
87 // completed.
88 //
89 // This functions fixes both those cases.
90 void ConvertRealLoadTimesToBlockingTimes(
91 net::LoadTimingInfo* load_timing_info) {
92 DCHECK(!load_timing_info->request_start.is_null());
93
94 // Earliest time possible for the request to be blocking on connect events.
95 base::TimeTicks block_on_connect = load_timing_info->request_start;
96
97 if (!load_timing_info->proxy_resolve_start.is_null()) {
98 DCHECK(!load_timing_info->proxy_resolve_end.is_null());
99
100 // Make sure the proxy times are after request start.
101 if (load_timing_info->proxy_resolve_start < load_timing_info->request_start)
102 load_timing_info->proxy_resolve_start = load_timing_info->request_start;
103 if (load_timing_info->proxy_resolve_end < load_timing_info->request_start)
104 load_timing_info->proxy_resolve_end = load_timing_info->request_start;
105
106 // Connect times must also be after the proxy times.
107 block_on_connect = load_timing_info->proxy_resolve_end;
108 }
109
110 // Make sure connection times are after start and proxy times.
111
112 net::LoadTimingInfo::ConnectTiming* connect_timing =
113 &load_timing_info->connect_timing;
114 if (!connect_timing->dns_start.is_null()) {
115 DCHECK(!connect_timing->dns_end.is_null());
116 if (connect_timing->dns_start < block_on_connect)
117 connect_timing->dns_start = block_on_connect;
118 if (connect_timing->dns_end < block_on_connect)
119 connect_timing->dns_end = block_on_connect;
120 }
121
122 if (!connect_timing->connect_start.is_null()) {
123 DCHECK(!connect_timing->connect_end.is_null());
124 if (connect_timing->connect_start < block_on_connect)
125 connect_timing->connect_start = block_on_connect;
126 if (connect_timing->connect_end < block_on_connect)
127 connect_timing->connect_end = block_on_connect;
128 }
129
130 if (!connect_timing->ssl_start.is_null()) {
131 DCHECK(!connect_timing->ssl_end.is_null());
132 if (connect_timing->ssl_start < block_on_connect)
133 connect_timing->ssl_start = block_on_connect;
134 if (connect_timing->ssl_end < block_on_connect)
135 connect_timing->ssl_end = block_on_connect;
136 }
137 }
138
77 } // namespace 139 } // namespace
78 140
79 URLRequest::ProtocolFactory* 141 URLRequest::ProtocolFactory*
80 URLRequest::Deprecated::RegisterProtocolFactory(const std::string& scheme, 142 URLRequest::Deprecated::RegisterProtocolFactory(const std::string& scheme,
81 ProtocolFactory* factory) { 143 ProtocolFactory* factory) {
82 return URLRequest::RegisterProtocolFactory(scheme, factory); 144 return URLRequest::RegisterProtocolFactory(scheme, factory);
83 } 145 }
84 146
85 void URLRequest::Deprecated::RegisterRequestInterceptor( 147 void URLRequest::Deprecated::RegisterRequestInterceptor(
86 Interceptor* interceptor) { 148 Interceptor* interceptor) {
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 if (delegate_) 1028 if (delegate_)
967 delegate_->OnReadCompleted(this, bytes_read); 1029 delegate_->OnReadCompleted(this, bytes_read);
968 1030
969 // Nothing below this line as OnReadCompleted may delete |this|. 1031 // Nothing below this line as OnReadCompleted may delete |this|.
970 } 1032 }
971 1033
972 void URLRequest::OnHeadersComplete() { 1034 void URLRequest::OnHeadersComplete() {
973 // Cache load timing information now, as information will be lost once the 1035 // Cache load timing information now, as information will be lost once the
974 // socket is closed and the ClientSocketHandle is Reset, which will happen 1036 // socket is closed and the ClientSocketHandle is Reset, which will happen
975 // once the body is complete. The start times should already be populated. 1037 // once the body is complete. The start times should already be populated.
976 if (job_) 1038 if (job_) {
977 job_->GetLoadTimingInfo(&load_timing_info_); 1039 job_->GetLoadTimingInfo(&load_timing_info_);
1040 ConvertRealLoadTimesToBlockingTimes(&load_timing_info_);
1041 }
978 } 1042 }
979 1043
980 void URLRequest::NotifyRequestCompleted() { 1044 void URLRequest::NotifyRequestCompleted() {
981 // TODO(battre): Get rid of this check, according to willchan it should 1045 // TODO(battre): Get rid of this check, according to willchan it should
982 // not be needed. 1046 // not be needed.
983 if (has_notified_completion_) 1047 if (has_notified_completion_)
984 return; 1048 return;
985 1049
986 is_pending_ = false; 1050 is_pending_ = false;
987 is_redirecting_ = false; 1051 is_redirecting_ = false;
(...skipping 25 matching lines...) Expand all
1013 new base::debug::StackTrace(NULL, 0); 1077 new base::debug::StackTrace(NULL, 0);
1014 *stack_trace_copy = stack_trace; 1078 *stack_trace_copy = stack_trace;
1015 stack_trace_.reset(stack_trace_copy); 1079 stack_trace_.reset(stack_trace_copy);
1016 } 1080 }
1017 1081
1018 const base::debug::StackTrace* URLRequest::stack_trace() const { 1082 const base::debug::StackTrace* URLRequest::stack_trace() const {
1019 return stack_trace_.get(); 1083 return stack_trace_.get();
1020 } 1084 }
1021 1085
1022 } // namespace net 1086 } // namespace net
OLDNEW
« no previous file with comments | « net/base/load_timing_info.h ('k') | net/url_request/url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698