Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Unified Diff: components/page_load_metrics/browser/page_load_metrics_web_contents_observer.h

Issue 1312213010: PageLoadMetrics renderer and browser implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Instrumented NavigationHandle for IsSamePage, fixed broken logic and tests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/page_load_metrics/browser/page_load_metrics_web_contents_observer.h
diff --git a/components/page_load_metrics/browser/page_load_metrics_web_contents_observer.h b/components/page_load_metrics/browser/page_load_metrics_web_contents_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..4bc6997bba55545d4a1c4dfabc75c52407089a44
--- /dev/null
+++ b/components/page_load_metrics/browser/page_load_metrics_web_contents_observer.h
@@ -0,0 +1,71 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSERVER_H_
+#define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSERVER_H_
+
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "components/page_load_metrics/common/page_load_timing.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace content {
+class NavigationHandle;
+class RenderFrameHost;
+} // namespace content
+
+namespace IPC {
+class Message;
+} // namespace IPC
+
+namespace page_load_metrics {
+
+struct PageLoadTiming;
+
+// WebContentsObserver logs page load UMA metrics based on
+// IPC messages received from a MainRenderFrameObserver.
+class WebContentsObserver
+ : public content::WebContentsObserver,
+ public content::WebContentsUserData<WebContentsObserver> {
+ public:
+ ~WebContentsObserver() override;
+
+ // WebContentsObserver implementation
+ bool OnMessageReceived(const IPC::Message& message,
+ content::RenderFrameHost* render_frame_host) override;
+ void DidCommitNavigation(
+ content::NavigationHandle* navigation_handle) override;
+ void RenderProcessGone(base::TerminationStatus status) override;
+
+ protected:
+ bool HandleMessageReceived(
+ const IPC::Message& message,
+ content::RenderFrameHost* render_frame_host);
+
+ private:
+ explicit WebContentsObserver(content::WebContents* web_contents);
+ friend class content::WebContentsUserData<WebContentsObserver>;
+ friend class WebContentsObserverTest;
+ 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
+
+ void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing);
+ void RecordTimingHistograms();
+
+ bool IsRelevantNavigation(content::NavigationHandle* navigation_handle);
+ // Used for testing, so we don't have to mock a whole WebContents
+ virtual const GURL& GetLastCommittedURL();
+
+ 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.
+ content::RenderFrameHost* current_host_;
Bryan McQuade 2015/09/04 20:53:17 suggest removing in favor of IsCurrentMainFrame me
+ 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.
+ 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.
+
+ DISALLOW_COPY_AND_ASSIGN(WebContentsObserver);
+};
+
+} // namespace page_load_metrics
+
+#endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698