OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 } | 837 } |
838 | 838 |
839 void TabAndroid::DetachOverlayContentViewCore(JNIEnv* env, | 839 void TabAndroid::DetachOverlayContentViewCore(JNIEnv* env, |
840 jobject obj, | 840 jobject obj, |
841 jobject jcontent_view_core) { | 841 jobject jcontent_view_core) { |
842 content::ContentViewCore* content_view_core = | 842 content::ContentViewCore* content_view_core = |
843 content::ContentViewCore::GetNativeContentViewCore(env, | 843 content::ContentViewCore::GetNativeContentViewCore(env, |
844 jcontent_view_core); | 844 jcontent_view_core); |
845 DCHECK(content_view_core); | 845 DCHECK(content_view_core); |
846 | 846 |
847 content_view_core->GetLayer()->RemoveFromParent(); | 847 if (content_view_core->GetLayer()->parent() == content_layer_) |
| 848 content_view_core->GetLayer()->RemoveFromParent(); |
848 } | 849 } |
849 | 850 |
850 static void Init(JNIEnv* env, jobject obj) { | 851 static void Init(JNIEnv* env, jobject obj) { |
851 TRACE_EVENT0("native", "TabAndroid::Init"); | 852 TRACE_EVENT0("native", "TabAndroid::Init"); |
852 // This will automatically bind to the Java object and pass ownership there. | 853 // This will automatically bind to the Java object and pass ownership there. |
853 new TabAndroid(env, obj); | 854 new TabAndroid(env, obj); |
854 } | 855 } |
855 | 856 |
856 // static | 857 // static |
857 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 858 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
858 return RegisterNativesImpl(env); | 859 return RegisterNativesImpl(env); |
859 } | 860 } |
860 | 861 |
861 static void RecordStartupToCommitUma(JNIEnv* env, jclass jcaller) { | 862 static void RecordStartupToCommitUma(JNIEnv* env, jclass jcaller) { |
862 // Currently it takes about 2000ms to commit a navigation if the measurement | 863 // Currently it takes about 2000ms to commit a navigation if the measurement |
863 // begins very early in the browser start. How many buckets (b) are needed to | 864 // begins very early in the browser start. How many buckets (b) are needed to |
864 // explore the _typical_ values with granularity 100ms and a maximum duration | 865 // explore the _typical_ values with granularity 100ms and a maximum duration |
865 // of 1 minute? | 866 // of 1 minute? |
866 // s^{n+1} / s^{n} = 2100 / 2000 | 867 // s^{n+1} / s^{n} = 2100 / 2000 |
867 // s = 1.05 | 868 // s = 1.05 |
868 // s^b = 60000 | 869 // s^b = 60000 |
869 // b = ln(60000) / ln(1.05) ~= 225 | 870 // b = ln(60000) / ln(1.05) ~= 225 |
870 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", | 871 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", |
871 base::Time::Now() - chrome::android::GetMainEntryPointTime(), | 872 base::Time::Now() - chrome::android::GetMainEntryPointTime(), |
872 base::TimeDelta::FromMilliseconds(1), | 873 base::TimeDelta::FromMilliseconds(1), |
873 base::TimeDelta::FromMinutes(1), | 874 base::TimeDelta::FromMinutes(1), |
874 225); | 875 225); |
875 } | 876 } |
OLD | NEW |