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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_PAGE_LOAD_HISTOGRAMS_H_
6 #define CHROME_RENDERER_PAGE_LOAD_HISTOGRAMS_H_
8 #include "base/basictypes.h"
9 #include "content/public/renderer/render_view_observer.h"
15 class RendererHistogramSnapshots
;
17 class PageLoadHistograms
: public content::RenderViewObserver
{
19 PageLoadHistograms(content::RenderView
* render_view
,
20 RendererHistogramSnapshots
* histogram_snapshots
);
23 // RenderViewObserver implementation.
24 virtual void FrameWillClose(WebKit::WebFrame
* frame
) OVERRIDE
;
25 virtual void ClosePage() OVERRIDE
;
27 // Dump all page load histograms appropriate for the given frame.
29 // This method will only dump once-per-instance, so it is safe to call
32 // The time points we keep are
33 // request: time document was requested by user
34 // start: time load of document started
35 // commit: time load of document started
36 // finish_document: main document loaded, before onload()
37 // finish_all_loads: after onload() and all resources are loaded
38 // first_paint: first paint performed
39 // first_paint_after_load: first paint performed after load is finished
40 // begin: request if it was user requested, start otherwise
42 // It's possible for the request time not to be set, if a client
43 // redirect had been done (the user never requested the page)
44 // Also, it's possible to load a page without ever laying it out
45 // so first_paint and first_paint_after_load can be 0.
46 void Dump(WebKit::WebFrame
* frame
);
48 void ResetCrossFramePropertyAccess();
50 void LogPageLoadTime(const content::DocumentState
* load_times
,
51 const WebKit::WebDataSource
* ds
) const;
53 // Site isolation metric counts.
54 // These are per-page-load counts, reset to 0 after they are dumped.
55 int cross_origin_access_count_
;
56 int same_origin_access_count_
;
58 RendererHistogramSnapshots
* histogram_snapshots_
;
60 DISALLOW_COPY_AND_ASSIGN(PageLoadHistograms
);
63 #endif // CHROME_RENDERER_PAGE_LOAD_HISTOGRAMS_H_