Commit 2e0e3efb authored by Tom McKee's avatar Tom McKee Committed by Commit Bot

[cleanup] Mark a constructor private to prefer a factory function

MetricsWebContentsObservers should be created through the
|CreateForWebContents| factory function. Hiding the constructor ensures
callers can't accidentally skip initialization handled by the factory
function.

Change-Id: I332aa234c7a307d80d8793ed4ebb4d2efb987448
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2233411Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776039}
parent 903504f6
......@@ -76,23 +76,6 @@ void MetricsWebContentsObserver::RecordFeatureUsage(
observer->OnBrowserFeatureUsage(render_frame_host, new_features);
}
MetricsWebContentsObserver::MetricsWebContentsObserver(
content::WebContents* web_contents,
std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface)
: content::WebContentsObserver(web_contents),
in_foreground_(web_contents->GetVisibility() !=
content::Visibility::HIDDEN),
embedder_interface_(std::move(embedder_interface)),
has_navigated_(false),
page_load_metrics_receiver_(web_contents, this) {
// Prerenders erroneously report that they are initially visible, so we
// manually override visibility state for prerender.
if (embedder_interface_->IsPrerender(web_contents))
in_foreground_ = false;
RegisterInputEventObserver(web_contents->GetRenderViewHost());
}
// static
MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents(
content::WebContents* web_contents,
......@@ -188,6 +171,23 @@ void MetricsWebContentsObserver::WillStartNavigationRequest(
has_navigated_ = true;
}
MetricsWebContentsObserver::MetricsWebContentsObserver(
content::WebContents* web_contents,
std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface)
: content::WebContentsObserver(web_contents),
in_foreground_(web_contents->GetVisibility() !=
content::Visibility::HIDDEN),
embedder_interface_(std::move(embedder_interface)),
has_navigated_(false),
page_load_metrics_receiver_(web_contents, this) {
// Prerenders erroneously report that they are initially visible, so we
// manually override visibility state for prerender.
if (embedder_interface_->IsPrerender(web_contents))
in_foreground_ = false;
RegisterInputEventObserver(web_contents->GetRenderViewHost());
}
void MetricsWebContentsObserver::WillStartNavigationRequestImpl(
content::NavigationHandle* navigation_handle) {
UserInitiatedInfo user_initiated_info(
......
......@@ -87,9 +87,6 @@ class MetricsWebContentsObserver
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;
// Any visibility changes that occur after this method should be ignored since
......@@ -175,6 +172,10 @@ class MetricsWebContentsObserver
private:
friend class content::WebContentsUserData<MetricsWebContentsObserver>;
MetricsWebContentsObserver(
content::WebContents* web_contents,
std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
void WillStartNavigationRequestImpl(
content::NavigationHandle* navigation_handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment