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 // WebContentsObserver logs page load UMA metrics based on | |
| 29 // IPC messages received from a MainRenderFrameObserver. | |
| 30 class WebContentsObserver | |
| 31 : public content::WebContentsObserver, | |
| 32 public content::WebContentsUserData<WebContentsObserver> { | |
| 33 public: | |
| 34 ~WebContentsObserver() override; | |
| 35 | |
| 36 // WebContentsObserver implementation | |
| 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 protected: | |
| 44 bool HandleMessageReceived( | |
| 45 const IPC::Message& message, | |
| 46 content::RenderFrameHost* render_frame_host); | |
| 47 | |
| 48 private: | |
| 49 explicit WebContentsObserver(content::WebContents* web_contents); | |
| 50 friend class content::WebContentsUserData<WebContentsObserver>; | |
| 51 friend class WebContentsObserverTest; | |
| 52 friend class MockWebContentsObserver; | |
|
Bryan McQuade
2015/09/04 20:53:18
does this need to be a friend? looking at the impl
Charlie Harrison
2015/09/08 23:05:15
Either it's a friend or the explicit constructor m
| |
| 53 | |
| 54 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing); | |
| 55 void RecordTimingHistograms(); | |
| 56 | |
| 57 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle); | |
| 58 // Used for testing, so we don't have to mock a whole WebContents | |
| 59 virtual const GURL& GetLastCommittedURL(); | |
| 60 | |
| 61 bool has_committed_navigation_; | |
|
Bryan McQuade
2015/09/04 20:53:17
looks like this bool is no longer used. remove?
Charlie Harrison
2015/09/08 23:05:15
Done.
| |
| 62 content::RenderFrameHost* current_host_; | |
|
Bryan McQuade
2015/09/04 20:53:17
suggest removing in favor of IsCurrentMainFrame me
| |
| 63 content::NavigationHandle* current_navigation_; | |
|
Bryan McQuade
2015/09/04 20:53:17
looks like this is also no longer used. remove?
clamy
2015/09/08 13:25:58
In particular, the NavigationHandle will likely be
Charlie Harrison
2015/09/08 23:05:15
Done.
| |
| 64 scoped_ptr<PageLoadTiming> current_timing_; | |
|
Bryan McQuade
2015/09/04 20:53:17
let's add a short comment to explain when this wil
Charlie Harrison
2015/09/08 23:05:15
Done.
| |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); | |
| 67 }; | |
| 68 | |
| 69 } // namespace page_load_metrics | |
| 70 | |
| 71 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | |
| OLD | NEW |