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

Side by Side Diff: webkit/glue/weburlloader_impl.cc

Issue 15552003: Fix ResourceLoadTiming resolution lose issue (chromium part) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Patch for landing Created 7 years, 7 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 | « build/common.gypi ('k') | no next file » | 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge.
6 6
7 #include "webkit/glue/weburlloader_impl.h" 7 #include "webkit/glue/weburlloader_impl.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 return true; 144 return true;
145 } 145 }
146 146
147 *error_code = net::ERR_INVALID_URL; 147 *error_code = net::ERR_INVALID_URL;
148 return false; 148 return false;
149 } 149 }
150 150
151 typedef ResourceDevToolsInfo::HeadersVector HeadersVector; 151 typedef ResourceDevToolsInfo::HeadersVector HeadersVector;
152 152
153 // Given a base time and a second time, returns the time from the base time to
154 // the second time, in milliseconds. If the second time is null, returns -1.
155 // The base time must not be null.
156 int TimeTicksToOffset(base::TimeTicks base_time, base::TimeTicks time) {
157 if (time.is_null())
158 return -1;
159 DCHECK(!base_time.is_null());
160 return static_cast<int>((time - base_time).InMillisecondsRoundedUp());
161 }
162
163 // Converts timing data from |load_timing| to the format used by WebKit. 153 // Converts timing data from |load_timing| to the format used by WebKit.
164 void PopulateURLLoadTiming(const net::LoadTimingInfo& load_timing, 154 void PopulateURLLoadTiming(const net::LoadTimingInfo& load_timing,
165 WebURLLoadTiming* url_timing) { 155 WebURLLoadTiming* url_timing) {
166 DCHECK(!load_timing.request_start.is_null()); 156 DCHECK(!load_timing.request_start.is_null());
167 157
158 const TimeTicks kNullTicks;
168 url_timing->initialize(); 159 url_timing->initialize();
169 url_timing->setRequestTime( 160 url_timing->setRequestTime(
170 (load_timing.request_start - TimeTicks()).InSecondsF()); 161 (load_timing.request_start - kNullTicks).InSecondsF());
171 url_timing->setProxyStart(TimeTicksToOffset(load_timing.request_start, 162 url_timing->setProxyStart(
172 load_timing.proxy_resolve_start)); 163 (load_timing.proxy_resolve_start - kNullTicks).InSecondsF());
173 url_timing->setProxyEnd(TimeTicksToOffset(load_timing.request_start, 164 url_timing->setProxyEnd(
174 load_timing.proxy_resolve_end)); 165 (load_timing.proxy_resolve_end - kNullTicks).InSecondsF());
175 url_timing->setDNSStart(TimeTicksToOffset( 166 url_timing->setDNSStart(
176 load_timing.request_start, 167 (load_timing.connect_timing.dns_start - kNullTicks).InSecondsF());
177 load_timing.connect_timing.dns_start)); 168 url_timing->setDNSEnd(
178 url_timing->setDNSEnd(TimeTicksToOffset(load_timing.request_start, 169 (load_timing.connect_timing.dns_end - kNullTicks).InSecondsF());
179 load_timing.connect_timing.dns_end));
180 url_timing->setConnectStart( 170 url_timing->setConnectStart(
181 TimeTicksToOffset(load_timing.request_start, 171 (load_timing.connect_timing.connect_start - kNullTicks).InSecondsF());
182 load_timing.connect_timing.connect_start));
183 url_timing->setConnectEnd( 172 url_timing->setConnectEnd(
184 TimeTicksToOffset(load_timing.request_start, 173 (load_timing.connect_timing.connect_end - kNullTicks).InSecondsF());
185 load_timing.connect_timing.connect_end));
186 url_timing->setSSLStart( 174 url_timing->setSSLStart(
187 TimeTicksToOffset(load_timing.request_start, 175 (load_timing.connect_timing.ssl_start - kNullTicks).InSecondsF());
188 load_timing.connect_timing.ssl_start)); 176 url_timing->setSSLEnd(
189 url_timing->setSSLEnd(TimeTicksToOffset(load_timing.request_start, 177 (load_timing.connect_timing.ssl_end - kNullTicks).InSecondsF());
190 load_timing.connect_timing.ssl_end)); 178 url_timing->setSendStart(
191 url_timing->setSendStart(TimeTicksToOffset(load_timing.request_start, 179 (load_timing.send_start - kNullTicks).InSecondsF());
192 load_timing.send_start)); 180 url_timing->setSendEnd(
193 url_timing->setSendEnd(TimeTicksToOffset(load_timing.request_start, 181 (load_timing.send_end - kNullTicks).InSecondsF());
194 load_timing.send_end));
195 url_timing->setReceiveHeadersEnd( 182 url_timing->setReceiveHeadersEnd(
196 TimeTicksToOffset(load_timing.request_start, 183 (load_timing.receive_headers_end - kNullTicks).InSecondsF());
197 load_timing.receive_headers_end));
198 } 184 }
199 185
200 void PopulateURLResponse( 186 void PopulateURLResponse(
201 const GURL& url, 187 const GURL& url,
202 const ResourceResponseInfo& info, 188 const ResourceResponseInfo& info,
203 WebURLResponse* response) { 189 WebURLResponse* response) {
204 response->setURL(url); 190 response->setURL(url);
205 response->setResponseTime(info.response_time.ToDoubleT()); 191 response->setResponseTime(info.response_time.ToDoubleT());
206 response->setMIMEType(WebString::fromUTF8(info.mime_type)); 192 response->setMIMEType(WebString::fromUTF8(info.mime_type));
207 response->setTextEncodingName(WebString::fromUTF8(info.charset)); 193 response->setTextEncodingName(WebString::fromUTF8(info.charset));
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 845
860 void WebURLLoaderImpl::setDefersLoading(bool value) { 846 void WebURLLoaderImpl::setDefersLoading(bool value) {
861 context_->SetDefersLoading(value); 847 context_->SetDefersLoading(value);
862 } 848 }
863 849
864 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { 850 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
865 context_->DidChangePriority(new_priority); 851 context_->DidChangePriority(new_priority);
866 } 852 }
867 853
868 } // namespace webkit_glue 854 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698