Commit 28b3eafd authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Add page load metrics

Measure browser and render generated page
load running time through UMA.

Bug: 996682
Change-Id: Ie6f6445ace8ea77285d819434ec8a0d541f9411b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760799
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699270}
parent b0ecb562
......@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/timer/elapsed_timer.h"
#import "ios/web/public/navigation/navigation_context.h"
#include "url/gurl.h"
......@@ -61,6 +62,9 @@ class NavigationContextImpl : public NavigationContext {
void SetResponseHeaders(
const scoped_refptr<net::HttpResponseHeaders>& response_headers);
// Get elapsed time since context was created.
base::TimeDelta GetElapsedTimeSinceCreation() const;
// Optional unique id of the navigation item associated with this navigaiton.
int GetNavigationItemUniqueID() const;
void SetNavigationItemUniqueID(int unique_id);
......@@ -133,6 +137,7 @@ class NavigationContextImpl : public NavigationContext {
bool is_native_content_presented_ = false;
bool is_placeholder_navigation_ = false;
NSString* mime_type_ = nil;
base::ElapsedTimer elapsed_timer_;
// Holds pending navigation item in this object. Pending item is stored in
// NavigationContext after context is created. The item is still stored in
......
......@@ -207,6 +207,10 @@ void NavigationContextImpl::SetItem(std::unique_ptr<NavigationItemImpl> item) {
item_ = std::move(item);
}
base::TimeDelta NavigationContextImpl::GetElapsedTimeSinceCreation() const {
return elapsed_timer_.Elapsed();
}
NavigationContextImpl::NavigationContextImpl(WebState* web_state,
const GURL& url,
bool has_user_gesture,
......@@ -220,7 +224,8 @@ NavigationContextImpl::NavigationContextImpl(WebState* web_state,
is_same_document_(false),
error_(nil),
response_headers_(nullptr),
is_renderer_initiated_(is_renderer_initiated) {}
is_renderer_initiated_(is_renderer_initiated),
elapsed_timer_(base::ElapsedTimer()) {}
NavigationContextImpl::~NavigationContextImpl() = default;
......
......@@ -481,7 +481,18 @@ enum class BackForwardNavigationType {
} else {
// There is another pending navigation, so the state is still loading.
}
self.webState->OnPageLoaded(currentURL, YES);
if (context) {
if (context->IsRendererInitiated()) {
UMA_HISTOGRAM_TIMES("PLT.iOS.RendererInitiatedPageLoadTime",
context->GetElapsedTimeSinceCreation());
} else {
UMA_HISTOGRAM_TIMES("PLT.iOS.BrowserInitiatedPageLoadTime",
context->GetElapsedTimeSinceCreation());
}
}
}
// Reports Navigation.IOSWKWebViewSlowFastBackForward UMA. No-op if pending
......
......@@ -106864,6 +106864,28 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="PLT.iOS.BrowserInitiatedPageLoadTime" units="ms"
expires_after="2020-08-09">
<owner>djean@chromium.org</owner>
<owner>eugenebut@chromium.org</owner>
<summary>
Page load time for Browser-initiated navigations. Recorded when
CRWWebRequestController::didFinishWithURL completes successfully. iOS
specific.
</summary>
</histogram>
<histogram name="PLT.iOS.RendererInitiatedPageLoadTime" units="ms"
expires_after="2020-08-09">
<owner>djean@chromium.org</owner>
<owner>eugenebut@chromium.org</owner>
<summary>
Page load time for Renderer-initiated navigations. Recorded when
CRWWebRequestController::didFinishWithURL completes successfully. iOS
specific.
</summary>
</histogram>
<histogram name="PLT.LoadType" enum="LoadType" expires_after="2016-08-02">
<obsolete>
Use PageLoad.PaintTiming.NavigationToFirstContentfulPaint.LoadType.*
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