Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/page_load_metrics/observers/android_page_load_metrics_o bserver.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/android/jni_android.h" | |
| 10 #include "base/android/jni_string.h" | |
| 11 #include "base/android/scoped_java_ref.h" | |
| 12 #include "components/page_load_metrics/browser/page_load_metrics_util.h" | |
|
Bryan McQuade
2016/07/26 23:44:27
same - need to update include path
Benoit L
2016/07/27 16:23:45
Done.
| |
| 13 #include "content/public/browser/browser_thread.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 #include "jni/PageLoadMetrics_jni.h" | |
| 16 #include "url/gurl.h" | |
| 17 | |
| 18 AndroidPageLoadMetricsObserver::AndroidPageLoadMetricsObserver( | |
| 19 content::WebContents* web_contents) | |
| 20 : web_contents_(web_contents) {} | |
| 21 | |
| 22 void AndroidPageLoadMetricsObserver::OnFirstContentfulPaint( | |
| 23 const page_load_metrics::PageLoadTiming& timing, | |
| 24 const page_load_metrics::PageLoadExtraInfo& extra_info) { | |
| 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
|
Bryan McQuade
2016/07/26 14:29:33
if we want to cases where a page is backgrounded b
Benoit L
2016/07/27 16:23:45
I guess there are two ways to look at how to proce
| |
| 26 int64_t first_contentful_paint_ms = | |
| 27 timing.first_contentful_paint->InMilliseconds(); | |
| 28 base::android::ScopedJavaLocalRef<jobject> java_web_contents = | |
| 29 web_contents_->GetJavaWebContents(); | |
| 30 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 31 Java_PageLoadMetrics_onFirstContentfulPaint( | |
| 32 env, java_web_contents.obj(), | |
| 33 static_cast<jlong>(first_contentful_paint_ms)); | |
| 34 } | |
| 35 | |
| 36 bool RegisterPageLoadMetricsBindings(JNIEnv* env) { | |
| 37 return RegisterNativesImpl(env); | |
| 38 } | |
| OLD | NEW |