Chromium Code Reviews| 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 struct PageLoadTiming; | |
| 27 | |
| 28 // MetricsWebContentsObserver logs page load UMA metrics based on | |
| 29 // IPC messages received from a MainRenderFrameObserver. | |
| 30 class MetricsWebContentsObserver | |
| 31 : public content::WebContentsObserver, | |
| 32 public content::WebContentsUserData<MetricsWebContentsObserver> { | |
| 33 public: | |
| 34 ~MetricsWebContentsObserver() override; | |
| 35 | |
| 36 // WebContentsObserver implementation | |
|
clamy
2015/09/11 11:52:32
nit: . at the end of the comment.
Charlie Harrison
2015/09/11 14:40:52
Done.
| |
| 37 bool OnMessageReceived(const IPC::Message& message, | |
| 38 content::RenderFrameHost* render_frame_host) override; | |
| 39 void DidCommitNavigation( | |
| 40 content::NavigationHandle* navigation_handle) override; | |
| 41 void RenderProcessGone(base::TerminationStatus status) override; | |
| 42 | |
| 43 private: | |
| 44 explicit MetricsWebContentsObserver(content::WebContents* web_contents); | |
| 45 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | |
| 46 friend class MetricsWebContentsObserverTest; | |
| 47 friend class MockMetricsWebContentsObserver; | |
| 48 | |
| 49 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing); | |
| 50 void RecordTimingHistograms(); | |
| 51 | |
| 52 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle); | |
| 53 | |
| 54 content::RenderFrameHost* current_host_; | |
| 55 | |
| 56 // Will be null before any navigations have committed. When a navigation | |
| 57 // commits we will initialize this as empty. | |
| 58 scoped_ptr<PageLoadTiming> current_timing_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | |
| 61 }; | |
| 62 | |
| 63 } // namespace page_load_metrics | |
| 64 | |
| 65 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | |
| OLD | NEW |