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/trace_subscriber.h"
|
|
|
|
#include "libcef/browser/context.h"
|
|
|
|
#include "libcef/browser/thread_util.h"
|
|
|
|
|
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()) {
|
|
|
|
NOTREACHED() << "context not valid";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
|
|
NOTREACHED() << "called on invalid thread";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-03 20:06:25 +02:00
|
|
|
CefTraceSubscriber* subscriber = CefContext::Get()->GetTraceSubscriber();
|
2012-10-18 00:45:49 +02:00
|
|
|
if (!subscriber)
|
|
|
|
return false;
|
|
|
|
|
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()) {
|
|
|
|
NOTREACHED() << "context not valid";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
|
|
NOTREACHED() << "called on invalid thread";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-03 20:06:25 +02:00
|
|
|
CefTraceSubscriber* subscriber = CefContext::Get()->GetTraceSubscriber();
|
2012-10-18 00:45:49 +02:00
|
|
|
if (!subscriber)
|
|
|
|
return false;
|
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
return subscriber->EndTracing(base::FilePath(tracing_file), callback);
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
2013-03-15 20:57:20 +01:00
|
|
|
int64 CefNowFromSystemTraceTime() {
|
|
|
|
return base::TimeTicks::NowFromSystemTraceTime().ToInternalValue();
|
|
|
|
}
|