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: Use strong typing Created 9 years, 1 month 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, which also provides a factory method Create 7 // implemented by the embedder, which also provides a factory method Create
8 // to instantiate this object. 8 // to instantiate this object.
9 // 9 //
10 // One of these objects will be created by WebKit for each request. WebKit 10 // One of these objects will be created by WebKit for each request. WebKit
(...skipping 15 matching lines...) Expand all
26 #endif 26 #endif
27 #include "base/file_path.h" 27 #include "base/file_path.h"
28 #include "base/memory/ref_counted.h" 28 #include "base/memory/ref_counted.h"
29 #include "base/memory/scoped_ptr.h" 29 #include "base/memory/scoped_ptr.h"
30 #include "base/platform_file.h" 30 #include "base/platform_file.h"
31 #include "base/time.h" 31 #include "base/time.h"
32 #include "base/values.h" 32 #include "base/values.h"
33 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
34 #include "net/base/host_port_pair.h" 34 #include "net/base/host_port_pair.h"
35 #include "net/url_request/url_request_status.h" 35 #include "net/url_request/url_request_status.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoadTiming.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
37 #include "webkit/glue/resource_type.h" 38 #include "webkit/glue/resource_type.h"
38 39
39 namespace net { 40 namespace net {
40 class HttpResponseHeaders; 41 class HttpResponseHeaders;
41 } 42 }
42 43
43 namespace webkit_glue { 44 namespace webkit_glue {
44 45
45 // Structure containing timing information for the request. It addresses 46 // Structure containing timing information for the request. It addresses
46 // http://groups.google.com/group/http-archive-specification/web/har-1-1-spec 47 // http://groups.google.com/group/http-archive-specification/web/har-1-1-spec
47 // and http://dev.w3.org/2006/webapi/WebTiming/ needs. 48 // and http://dev.w3.org/2006/webapi/WebTiming/ needs.
48 // 49 //
49 // All the values for starts and ends are given in milliseconds and are 50 // All the values for starts and ends are given in milliseconds and are
50 // offsets with respect to the given base time. 51 // offsets with respect to the given base time.
51 struct ResourceLoadTimingInfo { 52 struct ResourceLoadTimingInfo {
52 ResourceLoadTimingInfo(); 53 ResourceLoadTimingInfo();
53 ~ResourceLoadTimingInfo(); 54 ~ResourceLoadTimingInfo();
54 55
55 // All the values in this struct are given as offsets in milliseconds wrt 56 // All the values in this struct are given as offsets in ticks wrt
56 // this base time. 57 // this base tick count.
58 base::TimeTicks base_ticks;
59
60 // The value of Time::Now() when base_ticks was set.
57 base::Time base_time; 61 base::Time base_time;
58 62
59 // The time that proxy processing started. For requests with no proxy phase, 63 // The time that proxy processing started. For requests with no proxy phase,
60 // this time is -1. 64 // this time is -1.
61 int32 proxy_start; 65 int32 proxy_start;
62 66
63 // The time that proxy processing ended. For reused sockets this time 67 // The time that proxy processing ended. For reused sockets this time
64 // is -1. 68 // is -1.
65 int32 proxy_end; 69 int32 proxy_end;
66 70
(...skipping 196 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& start_time,
310 const base::TimeTicks& 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& start_time,
318 const base::TimeTicks& 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 Create() for construction, but anybody can delete at any time, 347 // use Create() for construction, but anybody can delete at any time,
333 // INCLUDING during processing of callbacks. 348 // INCLUDING during processing of callbacks.
334 virtual ~ResourceLoaderBridge(); 349 virtual ~ResourceLoaderBridge();
335 350
336 // Call this method to make a new instance. 351 // Call this method to make a new instance.
337 // 352 //
338 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload 353 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload
339 // methods may be called to construct the body of the request. 354 // methods may be called to construct the body of the request.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 virtual void UpdateRoutingId(int new_routing_id) = 0; 409 virtual void UpdateRoutingId(int new_routing_id) = 0;
395 410
396 protected: 411 protected:
397 // construction must go through Create() 412 // construction must go through Create()
398 ResourceLoaderBridge(); 413 ResourceLoaderBridge();
399 414
400 private: 415 private:
401 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); 416 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge);
402 }; 417 };
403 418
419 // For testing purposes.
420 WebKit::WebURLLoadTiming PopulateWebURLLoadTiming(
421 const ResourceLoadTimingInfo& timing_info,
422 const base::TimeTicks& initiation_time,
423 const base::TimeTicks& start_time,
424 const base::TimeTicks& end_time,
425 const base::TimeTicks& callback_time);
426
404 } // namespace webkit_glue 427 } // namespace webkit_glue
405 428
406 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ 429 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698