OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/android/tab_model/tab_model_jni_bridge.h" | 5 #include "chrome/browser/ui/android/tab_model/tab_model_jni_bridge.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void TabModelJniBridge::BroadcastSessionRestoreComplete(JNIEnv* env, | 151 void TabModelJniBridge::BroadcastSessionRestoreComplete(JNIEnv* env, |
152 jobject obj) { | 152 jobject obj) { |
153 TabModel::BroadcastSessionRestoreComplete(); | 153 TabModel::BroadcastSessionRestoreComplete(); |
154 } | 154 } |
155 | 155 |
156 inline static base::TimeDelta GetTimeDelta(jlong ms) { | 156 inline static base::TimeDelta GetTimeDelta(jlong ms) { |
157 return base::TimeDelta::FromMilliseconds(static_cast<int64>(ms)); | 157 return base::TimeDelta::FromMilliseconds(static_cast<int64>(ms)); |
158 } | 158 } |
159 | 159 |
160 void LogFromCloseMetric(JNIEnv* env, | 160 void LogFromCloseMetric(JNIEnv* env, |
161 jclass jcaller, | 161 const JavaParamRef<jclass>& jcaller, |
162 jlong ms, | 162 jlong ms, |
163 jboolean perceived) { | 163 jboolean perceived) { |
164 if (perceived) { | 164 if (perceived) { |
165 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromCloseLatency_Perceived", | 165 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromCloseLatency_Perceived", |
166 GetTimeDelta(ms)); | 166 GetTimeDelta(ms)); |
167 } else { | 167 } else { |
168 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromCloseLatency_Actual", | 168 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromCloseLatency_Actual", |
169 GetTimeDelta(ms)); | 169 GetTimeDelta(ms)); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 void LogFromExitMetric(JNIEnv* env, | 173 void LogFromExitMetric(JNIEnv* env, |
174 jclass jcaller, | 174 const JavaParamRef<jclass>& jcaller, |
175 jlong ms, | 175 jlong ms, |
176 jboolean perceived) { | 176 jboolean perceived) { |
177 if (perceived) { | 177 if (perceived) { |
178 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromExitLatency_Perceived", | 178 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromExitLatency_Perceived", |
179 GetTimeDelta(ms)); | 179 GetTimeDelta(ms)); |
180 } else { | 180 } else { |
181 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromExitLatency_Actual", | 181 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromExitLatency_Actual", |
182 GetTimeDelta(ms)); | 182 GetTimeDelta(ms)); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 void LogFromNewMetric(JNIEnv* env, | 186 void LogFromNewMetric(JNIEnv* env, |
187 jclass jcaller, | 187 const JavaParamRef<jclass>& jcaller, |
188 jlong ms, | 188 jlong ms, |
189 jboolean perceived) { | 189 jboolean perceived) { |
190 if (perceived) { | 190 if (perceived) { |
191 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromNewLatency_Perceived", | 191 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromNewLatency_Perceived", |
192 GetTimeDelta(ms)); | 192 GetTimeDelta(ms)); |
193 } else { | 193 } else { |
194 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromNewLatency_Actual", | 194 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromNewLatency_Actual", |
195 GetTimeDelta(ms)); | 195 GetTimeDelta(ms)); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 void LogFromUserMetric(JNIEnv* env, | 199 void LogFromUserMetric(JNIEnv* env, |
200 jclass jcaller, | 200 const JavaParamRef<jclass>& jcaller, |
201 jlong ms, | 201 jlong ms, |
202 jboolean perceived) { | 202 jboolean perceived) { |
203 if (perceived) { | 203 if (perceived) { |
204 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromUserLatency_Perceived", | 204 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromUserLatency_Perceived", |
205 GetTimeDelta(ms)); | 205 GetTimeDelta(ms)); |
206 } else { | 206 } else { |
207 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromUserLatency_Actual", | 207 UMA_HISTOGRAM_TIMES("Tabs.SwitchFromUserLatency_Actual", |
208 GetTimeDelta(ms)); | 208 GetTimeDelta(ms)); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 TabModelJniBridge::~TabModelJniBridge() { | 212 TabModelJniBridge::~TabModelJniBridge() { |
213 TabModelList::RemoveTabModel(this); | 213 TabModelList::RemoveTabModel(this); |
214 } | 214 } |
215 | 215 |
216 bool TabModelJniBridge::Register(JNIEnv* env) { | 216 bool TabModelJniBridge::Register(JNIEnv* env) { |
217 return RegisterNativesImpl(env); | 217 return RegisterNativesImpl(env); |
218 } | 218 } |
219 | 219 |
220 static jlong Init(JNIEnv* env, jobject obj, jboolean is_incognito) { | 220 static jlong Init(JNIEnv* env, |
| 221 const JavaParamRef<jobject>& obj, |
| 222 jboolean is_incognito) { |
221 TabModel* tab_model = new TabModelJniBridge(env, obj, is_incognito); | 223 TabModel* tab_model = new TabModelJniBridge(env, obj, is_incognito); |
222 return reinterpret_cast<intptr_t>(tab_model); | 224 return reinterpret_cast<intptr_t>(tab_model); |
223 } | 225 } |
OLD | NEW |