diff --git a/include/capi/cef_trace_capi.h b/include/capi/cef_trace_capi.h index d3ba7868b..f17fe5c40 100644 --- a/include/capi/cef_trace_capi.h +++ b/include/capi/cef_trace_capi.h @@ -90,6 +90,13 @@ CEF_EXPORT int cef_get_trace_buffer_percent_full_async(); /// CEF_EXPORT int cef_end_tracing_async(); +/// +// Returns the current system trace time or, if none is defined, the current +// high-res time. Can be used by clients to synchronize with the time +// information in trace events. +/// +CEF_EXPORT int64 cef_now_from_system_trace_time(); + /// // Implement this structure to receive trace notifications. The functions of // this structure will be called on the browser process UI thread. diff --git a/include/cef_trace.h b/include/cef_trace.h index 08c8e30b9..5346c367a 100644 --- a/include/cef_trace.h +++ b/include/cef_trace.h @@ -121,4 +121,12 @@ bool CefGetTraceBufferPercentFullAsync(); /*--cef()--*/ bool CefEndTracingAsync(); +/// +// Returns the current system trace time or, if none is defined, the current +// high-res time. Can be used by clients to synchronize with the time +// information in trace events. +/// +/*--cef()--*/ +int64 CefNowFromSystemTraceTime(); + #endif // CEF_INCLUDE_CEF_TRACE_H_ diff --git a/libcef/browser/trace_impl.cc b/libcef/browser/trace_impl.cc index 9da4a4172..37f2af425 100644 --- a/libcef/browser/trace_impl.cc +++ b/libcef/browser/trace_impl.cc @@ -9,6 +9,7 @@ #include "libcef/browser/thread_util.h" #include "base/debug/trace_event.h" +#include "base/time.h" bool CefBeginTracing(CefRefPtr client, const CefString& categories) { @@ -65,6 +66,9 @@ bool CefEndTracingAsync() { return subscriber->EndTracingAsync(); } +int64 CefNowFromSystemTraceTime() { + return base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); +} // The below functions can be called from any process. diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index f84b73100..e12d857f7 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -492,6 +492,16 @@ CEF_EXPORT int cef_end_tracing_async() { return _retval; } +CEF_EXPORT int64 cef_now_from_system_trace_time() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = CefNowFromSystemTraceTime(); + + // Return type: simple + return _retval; +} + CEF_EXPORT int cef_parse_url(const cef_string_t* url, struct _cef_urlparts_t* parts) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index 9c6f37d0e..967b8418f 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -475,6 +475,16 @@ CEF_GLOBAL bool CefEndTracingAsync() { return _retval?true:false; } +CEF_GLOBAL int64 CefNowFromSystemTraceTime() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = cef_now_from_system_trace_time(); + + // Return type: simple + return _retval; +} + CEF_GLOBAL bool CefParseURL(const CefString& url, CefURLParts& parts) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/tests/unittests/tracing_unittest.cc b/tests/unittests/tracing_unittest.cc index c260e9f4d..fbeeaa01b 100644 --- a/tests/unittests/tracing_unittest.cc +++ b/tests/unittests/tracing_unittest.cc @@ -398,3 +398,9 @@ TRACING_TEST(TraceEventAsyncEnd0, CEF_TRACE_EVENT_ASYNC_END0); TRACING_TEST(TraceEventAsyncEnd1, CEF_TRACE_EVENT_ASYNC_END1); TRACING_TEST(TraceEventAsyncEnd2, CEF_TRACE_EVENT_ASYNC_END2); TRACING_TEST(TraceEventCopyAsyncEnd0, CEF_TRACE_EVENT_COPY_ASYNC_END0); + + +TEST(TracingTest, NowFromSystemTraceTime) { + int64 val = CefNowFromSystemTraceTime(); + EXPECT_NE(val, 0); +}