OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ | |
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/time/time.h" | |
10 #include "components/page_load_metrics/common/page_load_timing.h" | |
11 #include "content/public/browser/web_contents.h" | |
12 #include "content/public/browser/web_contents_observer.h" | |
13 #include "content/public/browser/web_contents_user_data.h" | |
14 | |
15 namespace content { | |
16 class NavigationHandle; | |
17 class RenderFrameHost; | |
18 } // namespace content | |
19 | |
20 namespace IPC { | |
21 class Message; | |
22 } // namespace IPC | |
23 | |
24 namespace page_load_metrics { | |
25 | |
26 // MetricsWebContentsObserver logs page load UMA metrics based on | |
27 // IPC messages received from a MainRenderFrameObserver. | |
28 class MetricsWebContentsObserver | |
29 : public content::WebContentsObserver, | |
30 public content::WebContentsUserData<MetricsWebContentsObserver> { | |
31 public: | |
32 ~MetricsWebContentsObserver() override; | |
33 | |
34 // WebContentsObserver implementation. | |
Alexei Svitkine (slow)
2015/09/11 21:26:48
Nit: For new code, I think this comment syntax is
| |
35 void FrameDeleted(content::RenderFrameHost* render_frame_host) override; | |
36 bool OnMessageReceived(const IPC::Message& message, | |
37 content::RenderFrameHost* render_frame_host) override; | |
38 void DidCommitNavigation( | |
39 content::NavigationHandle* navigation_handle) override; | |
40 void RenderProcessGone(base::TerminationStatus status) override; | |
41 | |
42 private: | |
43 explicit MetricsWebContentsObserver(content::WebContents* web_contents); | |
44 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | |
45 friend class MetricsWebContentsObserverTest; | |
46 | |
47 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing); | |
48 void RecordTimingHistograms(); | |
49 | |
50 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle); | |
51 | |
52 content::RenderFrameHost* current_host_; | |
53 | |
54 // Will be null before any navigations have committed. When a navigation | |
55 // commits we will initialize this as empty. | |
56 scoped_ptr<PageLoadTiming> current_timing_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | |
59 }; | |
60 | |
61 } // namespace page_load_metrics | |
62 | |
63 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | |
OLD | NEW |