1 // Copyright 2015 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 COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_LOAD_METRICS_RENDER_FRAME_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_LOAD_METRICS_RENDER_FRAME_OBSERVER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/page_load_metrics/common/page_load_timing.h"
11 #include "content/public/renderer/render_frame_observer.h"
17 namespace page_load_metrics
{
19 class PageTimingMetricsSender
;
21 // MetricsRenderFrameObserver observes RenderFrame notifications, and
22 // sends page load timing information to the browser process over IPC.
23 class MetricsRenderFrameObserver
: public content::RenderFrameObserver
{
25 explicit MetricsRenderFrameObserver(content::RenderFrame
* render_frame
);
26 ~MetricsRenderFrameObserver() override
;
28 // RenderFrameObserver implementation
29 void DidChangePerformanceTiming() override
;
30 void DidCommitProvisionalLoad(bool is_new_navigation
,
31 bool is_same_page_navigation
) override
;
34 // Will be null when we're not actively sending metrics.
35 scoped_ptr
<PageTimingMetricsSender
> page_timing_metrics_sender_
;
38 virtual bool ShouldSendMetrics() const;
39 virtual PageLoadTiming
GetTiming() const;
40 virtual scoped_ptr
<base::Timer
> CreateTimer() const;
42 DISALLOW_COPY_AND_ASSIGN(MetricsRenderFrameObserver
);
45 } // namespace page_load_metrics
47 #endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_LOAD_METRICS_RENDER_FRAME_OBSERVER_H_