2012-10-18 00:45:49 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "include/cef_trace.h"
|
|
|
|
#include "libcef/browser/context.h"
|
|
|
|
#include "libcef/browser/thread_util.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "libcef/browser/trace_subscriber.h"
|
2012-10-18 00:45:49 +02:00
|
|
|
|
2013-07-24 22:15:18 +02:00
|
|
|
#include "base/time/time.h"
|
2012-10-18 00:45:49 +02:00
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
bool CefBeginTracing(const CefString& categories,
|
|
|
|
CefRefPtr<CefCompletionCallback> callback) {
|
2012-10-18 00:45:49 +02:00
|
|
|
if (!CONTEXT_STATE_VALID()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "context not valid";
|
2012-10-18 00:45:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "called on invalid thread";
|
2012-10-18 00:45:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-03 20:06:25 +02:00
|
|
|
CefTraceSubscriber* subscriber = CefContext::Get()->GetTraceSubscriber();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!subscriber) {
|
2012-10-18 00:45:49 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-10-18 00:45:49 +02:00
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
return subscriber->BeginTracing(categories, callback);
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
bool CefEndTracing(const CefString& tracing_file,
|
|
|
|
CefRefPtr<CefEndTracingCallback> callback) {
|
2012-10-18 00:45:49 +02:00
|
|
|
if (!CONTEXT_STATE_VALID()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "context not valid";
|
2012-10-18 00:45:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "called on invalid thread";
|
2012-10-18 00:45:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-03 20:06:25 +02:00
|
|
|
CefTraceSubscriber* subscriber = CefContext::Get()->GetTraceSubscriber();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!subscriber) {
|
2012-10-18 00:45:49 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-10-18 00:45:49 +02:00
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
return subscriber->EndTracing(base::FilePath(tracing_file), callback);
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
2023-06-01 16:06:15 +02:00
|
|
|
int64_t CefNowFromSystemTraceTime() {
|
2015-11-10 21:18:16 +01:00
|
|
|
return base::TimeTicks::Now().ToInternalValue();
|
2013-03-15 20:57:20 +01:00
|
|
|
}
|