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

Side by Side Diff: chrome/browser/page_load_metrics/observers/android_page_load_metrics_observer.cc

Issue 2472163003: [CustomTabs] Report the navigation start as absolute time (Closed)
Patch Set: Cache tick offset Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/page_load_metrics/observers/android_page_load_metrics_o bserver.h" 5 #include "chrome/browser/page_load_metrics/observers/android_page_load_metrics_o bserver.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/time/time.h"
12 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 13 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "jni/PageLoadMetrics_jni.h" 16 #include "jni/PageLoadMetrics_jni.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 AndroidPageLoadMetricsObserver::AndroidPageLoadMetricsObserver( 19 AndroidPageLoadMetricsObserver::AndroidPageLoadMetricsObserver(
19 content::WebContents* web_contents) 20 content::WebContents* web_contents)
20 : web_contents_(web_contents) {} 21 : web_contents_(web_contents) {}
21 22
23 page_load_metrics::PageLoadMetricsObserver::ObservePolicy
24 AndroidPageLoadMetricsObserver::OnStart(
25 content::NavigationHandle* navigation_handle,
26 const GURL& currently_committed_url,
27 bool started_in_foreground) {
28 navigation_start_ = navigation_handle->NavigationStart();
29 return CONTINUE_OBSERVING;
30 }
31
22 void AndroidPageLoadMetricsObserver::OnFirstContentfulPaint( 32 void AndroidPageLoadMetricsObserver::OnFirstContentfulPaint(
23 const page_load_metrics::PageLoadTiming& timing, 33 const page_load_metrics::PageLoadTiming& timing,
24 const page_load_metrics::PageLoadExtraInfo& extra_info) { 34 const page_load_metrics::PageLoadExtraInfo& extra_info) {
25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 35 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
26 int64_t first_contentful_paint_ms = 36 int64_t first_contentful_paint_ms =
27 timing.first_contentful_paint->InMilliseconds(); 37 timing.first_contentful_paint->InMilliseconds();
28 base::android::ScopedJavaLocalRef<jobject> java_web_contents = 38 base::android::ScopedJavaLocalRef<jobject> java_web_contents =
29 web_contents_->GetJavaWebContents(); 39 web_contents_->GetJavaWebContents();
30 JNIEnv* env = base::android::AttachCurrentThread(); 40 JNIEnv* env = base::android::AttachCurrentThread();
31 Java_PageLoadMetrics_onFirstContentfulPaint( 41 Java_PageLoadMetrics_onFirstContentfulPaint(
32 env, java_web_contents, static_cast<jlong>(first_contentful_paint_ms)); 42 env, java_web_contents,
43 static_cast<jlong>(
44 (navigation_start_ - base::TimeTicks()).InMicroseconds()),
45 static_cast<jlong>(first_contentful_paint_ms));
33 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698