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

Unified Diff: chrome/browser/page_load_metrics/page_load_tracker.h

Issue 2435233002: Factor PageLoadTracker into its own header and impl files. (Closed)
Patch Set: share IsNavigationUserInitiated impl Created 4 years, 2 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: chrome/browser/page_load_metrics/page_load_tracker.h
diff --git a/chrome/browser/page_load_metrics/metrics_web_contents_observer.h b/chrome/browser/page_load_metrics/page_load_tracker.h
similarity index 63%
copy from chrome/browser/page_load_metrics/metrics_web_contents_observer.h
copy to chrome/browser/page_load_metrics/page_load_tracker.h
index 3d6daece59a17bb31c4fb1ed0d43619187a96c06..3d082f8e03afa7c0d96e3f9436edf8d6057e0160 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.h
+++ b/chrome/browser/page_load_metrics/page_load_tracker.h
@@ -1,11 +1,10 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// Copyright 2016 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 CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
-#define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
+#ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_
+#define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_
-#include <map>
#include <memory>
#include <vector>
@@ -13,26 +12,22 @@
#include "base/time/time.h"
#include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
#include "chrome/common/page_load_metrics/page_load_timing.h"
-#include "content/public/browser/render_widget_host.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"
-#include "content/public/common/resource_type.h"
-#include "net/base/net_errors.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "ui/base/page_transition_types.h"
+
+class GURL;
+
+namespace blink {
+class WebInputEvent;
+} // namespace blink
namespace content {
class NavigationHandle;
-class RenderFrameHost;
} // namespace content
-namespace IPC {
-class Message;
-} // namespace IPC
-
namespace page_load_metrics {
-class PageLoadTracker;
+class PageLoadMetricsEmbedderInterface;
+class PageLoadMetricsObserver;
namespace internal {
@@ -110,15 +105,13 @@ enum InternalErrorLoadEvent {
ERR_LAST_ENTRY,
};
-// This class serves as a functional interface to various chrome// features.
-// Impl version is defined in chrome/browser/page_load_metrics.
-class PageLoadMetricsEmbedderInterface {
- public:
- virtual ~PageLoadMetricsEmbedderInterface() {}
- virtual bool IsPrerendering(content::WebContents* web_contents) = 0;
- virtual bool IsNewTabPageUrl(const GURL& url) = 0;
- virtual void RegisterObservers(PageLoadTracker* metrics) = 0;
-};
+// NOTE: these functions are shared by page_load_tracker.cc and
+// metrics_web_contents_observer.cc. They are declared here to allow both files
+// to access them.
+void RecordInternalError(InternalErrorLoadEvent event);
+UserAbortType AbortTypeForPageTransition(ui::PageTransition transition);
+void LogAbortChainSameURLHistogram(int aborted_chain_size_same_url);
+bool IsNavigationUserInitiated(content::NavigationHandle* handle);
// This class tracks a given page load, starting from navigation start /
// provisional load, until a new navigation commits or the navigation fails.
@@ -303,121 +296,6 @@ class PageLoadTracker {
DISALLOW_COPY_AND_ASSIGN(PageLoadTracker);
};
-// MetricsWebContentsObserver tracks page loads and loading metrics
-// related data based on IPC messages received from a
-// MetricsRenderFrameObserver.
-class MetricsWebContentsObserver
- : public content::WebContentsObserver,
- public content::WebContentsUserData<MetricsWebContentsObserver>,
- public content::RenderWidgetHost::InputEventObserver {
- public:
- // Note that the returned metrics is owned by the web contents.
- static MetricsWebContentsObserver* CreateForWebContents(
- content::WebContents* web_contents,
- std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
- MetricsWebContentsObserver(
- content::WebContents* web_contents,
- std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
- ~MetricsWebContentsObserver() override;
-
- // content::WebContentsObserver implementation:
- bool OnMessageReceived(const IPC::Message& message,
- content::RenderFrameHost* render_frame_host) override;
- void DidFinishNavigation(
- content::NavigationHandle* navigation_handle) override;
- void DidRedirectNavigation(
- content::NavigationHandle* navigation_handle) override;
- void NavigationStopped() override;
- void OnInputEvent(const blink::WebInputEvent& event) override;
- void WasShown() override;
- void WasHidden() override;
- void RenderProcessGone(base::TerminationStatus status) override;
- void RenderViewHostChanged(content::RenderViewHost* old_host,
- content::RenderViewHost* new_host) override;
-
- // This method is forwarded from the MetricsNavigationThrottle.
- void WillStartNavigationRequest(content::NavigationHandle* navigation_handle);
-
- // A resource request completed on the IO thread.
- void OnRequestComplete(content::ResourceType resource_type,
- bool was_cached,
- int net_error);
-
- // Flush any buffered metrics, as part of the metrics subsystem persisting
- // metrics as the application goes into the background. The application may be
- // killed at any time after this method is invoked without further
- // notification.
- void FlushMetricsOnAppEnterBackground();
-
- // This getter function is required for testing.
- const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
-
- private:
- friend class content::WebContentsUserData<MetricsWebContentsObserver>;
-
- void HandleFailedNavigationForTrackedLoad(
- content::NavigationHandle* navigation_handle,
- std::unique_ptr<PageLoadTracker> tracker);
-
- void HandleCommittedNavigationForTrackedLoad(
- content::NavigationHandle* navigation_handle,
- std::unique_ptr<PageLoadTracker> tracker);
-
- // Notify all loads, provisional and committed, that we performed an action
- // that might abort them.
- void NotifyAbortAllLoads(UserAbortType abort_type, bool user_initiated);
- void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type,
- bool user_initiated,
- base::TimeTicks timestamp,
- bool is_certainly_browser_timestamp);
-
- // Register / Unregister input event callback to given RenderViewHost
- void RegisterInputEventObserver(content::RenderViewHost* host);
- void UnregisterInputEventObserver(content::RenderViewHost* host);
-
- // Notify aborted provisional loads that a new navigation occurred. This is
- // used for more consistent attribution tracking for aborted provisional
- // loads. This method returns the provisional load that was likely aborted
- // by this navigation, to help instantiate the new PageLoadTracker.
- std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation(
- content::NavigationHandle* new_navigation);
-
- void OnTimingUpdated(content::RenderFrameHost*,
- const PageLoadTiming& timing,
- const PageLoadMetadata& metadata);
-
- bool ShouldTrackNavigation(
- content::NavigationHandle* navigation_handle) const;
-
- // True if the web contents is currently in the foreground.
- bool in_foreground_;
-
- // The PageLoadTrackers must be deleted before the |embedder_interface_|,
- // because they hold a pointer to the |embedder_interface_|.
- std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface_;
-
- // This map tracks all of the navigations ongoing that are not committed
- // yet. Once a navigation is committed, it moves from the map to
- // committed_load_. Note that a PageLoadTrackers NavigationHandle is only
- // valid until commit time, when we remove it from the map.
- std::map<content::NavigationHandle*, std::unique_ptr<PageLoadTracker>>
- provisional_loads_;
-
- // Tracks aborted provisional loads for a little bit longer than usual (one
- // more navigation commit at the max), in order to better understand how the
- // navigation failed. This is because most provisional loads are destroyed
- // and vanish before we get signal about what caused the abort (new
- // navigation, stop button, etc.).
- std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_;
-
- std::unique_ptr<PageLoadTracker> committed_load_;
-
- // Has the MWCO observed at least one navigation?
- bool has_navigated_;
-
- DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
-};
-
} // namespace page_load_metrics
-#endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
+#endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_

Powered by Google App Engine
This is Rietveld 408576698