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

Side by Side Diff: base/android/early_trace_event_binding.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 "base/android/early_trace_event_binding.h" 5 #include "base/android/early_trace_event_binding.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "jni/EarlyTraceEvent_jni.h" 12 #include "jni/EarlyTraceEvent_jni.h"
13 13
14 namespace base { 14 namespace base {
15 namespace android { 15 namespace android {
16 16
17 const char kEarlyJavaCategory[] = "EarlyJava"; 17 const char kEarlyJavaCategory[] = "EarlyJava";
18 18
19 static jlong GetTimeTicksNowUs(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
20 return TimeTicks::Now().ToInternalValue();
21 }
22
23 static void RecordEarlyEvent(JNIEnv* env, 19 static void RecordEarlyEvent(JNIEnv* env,
24 const JavaParamRef<jclass>& clazz, 20 const JavaParamRef<jclass>& clazz,
25 const JavaParamRef<jstring>& jname, 21 const JavaParamRef<jstring>& jname,
26 jlong begin_time_ms, 22 jlong begin_time_ms,
27 jlong end_time_ms, 23 jlong end_time_ms,
28 jint thread_id) { 24 jint thread_id) {
29 std::string name = ConvertJavaStringToUTF8(env, jname); 25 std::string name = ConvertJavaStringToUTF8(env, jname);
30 int64_t begin_us = begin_time_ms * 1000; 26 int64_t begin_us = begin_time_ms * 1000;
31 int64_t end_us = end_time_ms * 1000; 27 int64_t end_us = end_time_ms * 1000;
32 28
33 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( 29 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(
34 TRACE_EVENT_PHASE_BEGIN, kEarlyJavaCategory, name.c_str(), 30 TRACE_EVENT_PHASE_BEGIN, kEarlyJavaCategory, name.c_str(),
35 trace_event_internal::kNoId, thread_id, 31 trace_event_internal::kNoId, thread_id,
36 TimeTicks::FromInternalValue(begin_us), TRACE_EVENT_FLAG_COPY); 32 TimeTicks::FromInternalValue(begin_us), TRACE_EVENT_FLAG_COPY);
37 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( 33 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(
38 TRACE_EVENT_PHASE_END, kEarlyJavaCategory, name.c_str(), 34 TRACE_EVENT_PHASE_END, kEarlyJavaCategory, name.c_str(),
39 trace_event_internal::kNoId, thread_id, 35 trace_event_internal::kNoId, thread_id,
40 TimeTicks::FromInternalValue(end_us), TRACE_EVENT_FLAG_COPY); 36 TimeTicks::FromInternalValue(end_us), TRACE_EVENT_FLAG_COPY);
41 } 37 }
42 38
43 bool RegisterEarlyTraceEvent(JNIEnv* env) { 39 bool RegisterEarlyTraceEvent(JNIEnv* env) {
44 return RegisterNativesImpl(env); 40 return RegisterNativesImpl(env);
45 } 41 }
46 42
47 } // namespace android 43 } // namespace android
48 } // namespace base 44 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698