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

Side by Side Diff: webkit/glue/resource_loader_bridge.h

Issue 7602023: Use a monotonic clock (TimeTicks) to report network times to WebCore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add random test Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // The intent of this file is to provide a type-neutral abstraction between 5 // The intent of this file is to provide a type-neutral abstraction between
6 // Chrome and WebKit for resource loading. This pure-virtual interface is 6 // Chrome and WebKit for resource loading. This pure-virtual interface is
7 // implemented by the embedder. 7 // implemented by the embedder.
8 // 8 //
9 // One of these objects will be created by WebKit for each request. WebKit 9 // One of these objects will be created by WebKit for each request. WebKit
10 // will own the pointer to the bridge, and will delete it when the request is 10 // will own the pointer to the bridge, and will delete it when the request is
(...skipping 14 matching lines...) Expand all
25 #endif 25 #endif
26 #include "base/file_path.h" 26 #include "base/file_path.h"
27 #include "base/memory/ref_counted.h" 27 #include "base/memory/ref_counted.h"
28 #include "base/memory/scoped_ptr.h" 28 #include "base/memory/scoped_ptr.h"
29 #include "base/platform_file.h" 29 #include "base/platform_file.h"
30 #include "base/time.h" 30 #include "base/time.h"
31 #include "base/values.h" 31 #include "base/values.h"
32 #include "googleurl/src/gurl.h" 32 #include "googleurl/src/gurl.h"
33 #include "net/base/host_port_pair.h" 33 #include "net/base/host_port_pair.h"
34 #include "net/url_request/url_request_status.h" 34 #include "net/url_request/url_request_status.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoadTiming.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
36 #include "webkit/glue/resource_type.h" 37 #include "webkit/glue/resource_type.h"
37 38
38 namespace net { 39 namespace net {
39 class HttpResponseHeaders; 40 class HttpResponseHeaders;
40 } 41 }
41 42
42 namespace webkit_glue { 43 namespace webkit_glue {
43 44
44 // Structure containing timing information for the request. It addresses 45 // Structure containing timing information for the request. It addresses
45 // http://groups.google.com/group/http-archive-specification/web/har-1-1-spec 46 // http://groups.google.com/group/http-archive-specification/web/har-1-1-spec
46 // and http://dev.w3.org/2006/webapi/WebTiming/ needs. 47 // and http://dev.w3.org/2006/webapi/WebTiming/ needs.
47 // 48 //
48 // All the values for starts and ends are given in milliseconds and are 49 // All the values for starts and ends are given in milliseconds and are
49 // offsets with respect to the given base time. 50 // offsets with respect to the given base time.
50 struct ResourceLoadTimingInfo { 51 struct ResourceLoadTimingInfo {
51 ResourceLoadTimingInfo(); 52 ResourceLoadTimingInfo();
52 ~ResourceLoadTimingInfo(); 53 ~ResourceLoadTimingInfo();
53 54
54 // All the values in this struct are given as offsets in milliseconds wrt 55 // All the values in this struct are given as offsets in ticks wrt
55 // this base time. 56 // this base tick count.
57 base::TimeTicks base_ticks;
58
59 // The value of Time::Now() when base_ticks was set.
56 base::Time base_time; 60 base::Time base_time;
57 61
58 // The time that proxy processing started. For requests with no proxy phase, 62 // The time that proxy processing started. For requests with no proxy phase,
59 // this time is -1. 63 // this time is -1.
60 int32 proxy_start; 64 int32 proxy_start;
61 65
62 // The time that proxy processing ended. For reused sockets this time 66 // The time that proxy processing ended. For reused sockets this time
63 // is -1. 67 // is -1.
64 int32 proxy_end; 68 int32 proxy_end;
65 69
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 267
264 // The response status. 268 // The response status.
265 net::URLRequestStatus status; 269 net::URLRequestStatus status;
266 270
267 // The final URL of the response. This may differ from the request URL in 271 // The final URL of the response. This may differ from the request URL in
268 // the case of a server redirect. 272 // the case of a server redirect.
269 GURL url; 273 GURL url;
270 274
271 // The response data. 275 // The response data.
272 std::string data; 276 std::string data;
277
278 // TimeTicks when the network stack first receives the request.
279 base::TimeTicks net_start_time;
280
281 // TimeTicks when the response is sent to the renderer.
282 base::TimeTicks net_end_time;
273 }; 283 };
274 284
275 // Generated by the bridge. This is implemented by our custom resource loader 285 // Generated by the bridge. This is implemented by our custom resource loader
276 // within webkit. The Peer and it's bridge should have identical lifetimes 286 // within webkit. The Peer and it's bridge should have identical lifetimes
277 // as they represent each end of a communication channel. 287 // as they represent each end of a communication channel.
278 // 288 //
279 // These callbacks mirror net::URLRequest::Delegate and the order and 289 // These callbacks mirror net::URLRequest::Delegate and the order and
280 // conditions in which they will be called are identical. See url_request.h 290 // conditions in which they will be called are identical. See url_request.h
281 // for more information. 291 // for more information.
282 class Peer { 292 class Peer {
283 public: 293 public:
284 virtual ~Peer() {} 294 virtual ~Peer() {}
285 295
286 // Called as upload progress is made. 296 // Called as upload progress is made.
287 // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set 297 // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set
288 virtual void OnUploadProgress(uint64 position, uint64 size) = 0; 298 virtual void OnUploadProgress(uint64 position, uint64 size) = 0;
289 299
290 // Called when a redirect occurs. The implementation may return false to 300 // Called when a redirect occurs. The implementation may return false to
291 // suppress the redirect. The given ResponseInfo provides complete 301 // suppress the redirect. The given ResponseInfo provides complete
292 // information about the redirect, and new_url is the URL that will be 302 // information about the redirect, and new_url is the URL that will be
293 // loaded if this method returns true. If this method returns true, the 303 // loaded if this method returns true. If this method returns true, the
294 // output parameter *has_new_first_party_for_cookies indicates whether the 304 // output parameter *has_new_first_party_for_cookies indicates whether the
295 // output parameter *new_first_party_for_cookies contains the new URL that 305 // output parameter *new_first_party_for_cookies contains the new URL that
296 // should be consulted for the third-party cookie blocking policy. 306 // should be consulted for the third-party cookie blocking policy.
297 virtual bool OnReceivedRedirect(const GURL& new_url, 307 virtual bool OnReceivedRedirect(const GURL& new_url,
298 const ResourceResponseInfo& info, 308 const ResourceResponseInfo& info,
309 const base::TimeTicks& net_start_time,
darin (slow to review) 2011/12/06 01:06:32 are you sure you wouldn't want to include these ti
James Simonsen 2011/12/10 00:21:47 Done.
310 const base::TimeTicks& net_end_time,
299 bool* has_new_first_party_for_cookies, 311 bool* has_new_first_party_for_cookies,
300 GURL* new_first_party_for_cookies) = 0; 312 GURL* new_first_party_for_cookies) = 0;
301 313
302 // Called when response headers are available (after all redirects have 314 // Called when response headers are available (after all redirects have
303 // been followed). 315 // been followed).
304 virtual void OnReceivedResponse(const ResourceResponseInfo& info) = 0; 316 virtual void OnReceivedResponse(const ResourceResponseInfo& info,
317 const base::TimeTicks& net_start_time,
318 const base::TimeTicks& net_end_time) = 0;
305 319
306 // Called when a chunk of response data is downloaded. This method may be 320 // Called when a chunk of response data is downloaded. This method may be
307 // called multiple times or not at all if an error occurs. This method is 321 // called multiple times or not at all if an error occurs. This method is
308 // only called if RequestInfo::download_to_file was set to true, and in 322 // only called if RequestInfo::download_to_file was set to true, and in
309 // that case, OnReceivedData will not be called. 323 // that case, OnReceivedData will not be called.
310 virtual void OnDownloadedData(int len) = 0; 324 virtual void OnDownloadedData(int len) = 0;
311 325
312 // Called when a chunk of response data is available. This method may 326 // Called when a chunk of response data is available. This method may
313 // be called multiple times or not at all if an error occurs. 327 // be called multiple times or not at all if an error occurs.
314 // The encoded_data_length is the length of the encoded data transferred 328 // The encoded_data_length is the length of the encoded data transferred
315 // over the network, which could be different from data length (e.g. for 329 // over the network, which could be different from data length (e.g. for
316 // gzipped content), or -1 if if unknown. 330 // gzipped content), or -1 if if unknown.
317 virtual void OnReceivedData(const char* data, 331 virtual void OnReceivedData(const char* data,
318 int data_length, 332 int data_length,
319 int encoded_data_length) = 0; 333 int encoded_data_length) = 0;
320 334
321 // Called when metadata generated by the renderer is retrieved from the 335 // Called when metadata generated by the renderer is retrieved from the
322 // cache. This method may be called zero or one times. 336 // cache. This method may be called zero or one times.
323 virtual void OnReceivedCachedMetadata(const char* data, int len) { } 337 virtual void OnReceivedCachedMetadata(const char* data, int len) { }
324 338
325 // Called when the response is complete. This method signals completion of 339 // Called when the response is complete. This method signals completion of
326 // the resource load.ff 340 // the resource load.ff
327 virtual void OnCompletedRequest(const net::URLRequestStatus& status, 341 virtual void OnCompletedRequest(
328 const std::string& security_info, 342 const net::URLRequestStatus& status,
329 const base::Time& completion_time) = 0; 343 const std::string& security_info,
344 const base::TimeTicks& completion_time) = 0;
330 }; 345 };
331 346
332 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but 347 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but
333 // anybody can delete at any time, INCLUDING during processing of callbacks. 348 // anybody can delete at any time, INCLUDING during processing of callbacks.
334 virtual ~ResourceLoaderBridge(); 349 virtual ~ResourceLoaderBridge();
335 350
336 // Call this method before calling Start() to append a chunk of binary data 351 // Call this method before calling Start() to append a chunk of binary data
337 // to the request body. May only be used with HTTP(S) POST requests. 352 // to the request body. May only be used with HTTP(S) POST requests.
338 virtual void AppendDataToUpload(const char* data, int data_len) = 0; 353 virtual void AppendDataToUpload(const char* data, int data_len) = 0;
339 354
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // Construction must go through 406 // Construction must go through
392 // WebKitPlatformSupportImpl::CreateResourceLoader() 407 // WebKitPlatformSupportImpl::CreateResourceLoader()
393 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload 408 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload
394 // methods may be called to construct the body of the request. 409 // methods may be called to construct the body of the request.
395 ResourceLoaderBridge(); 410 ResourceLoaderBridge();
396 411
397 private: 412 private:
398 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); 413 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge);
399 }; 414 };
400 415
416 // For testing purposes.
417 WebKit::WebURLLoadTiming PopulateWebURLLoadTiming(
418 const ResourceLoadTimingInfo& timing_info,
419 const base::TimeTicks& ipc_request_time,
420 const base::TimeTicks& net_start_time,
421 const base::TimeTicks& net_end_time,
422 const base::TimeTicks& ipc_response_time);
423
401 } // namespace webkit_glue 424 } // namespace webkit_glue
402 425
403 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ 426 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698