• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4 
5 #include "include/cef_trace.h"
6 #include "libcef/browser/context.h"
7 #include "libcef/browser/thread_util.h"
8 #include "libcef/browser/trace_subscriber.h"
9 
10 #include "base/time/time.h"
11 
CefBeginTracing(const CefString & categories,CefRefPtr<CefCompletionCallback> callback)12 bool CefBeginTracing(const CefString& categories,
13                      CefRefPtr<CefCompletionCallback> callback) {
14   if (!CONTEXT_STATE_VALID()) {
15     NOTREACHED() << "context not valid";
16     return false;
17   }
18 
19   if (!CEF_CURRENTLY_ON_UIT()) {
20     NOTREACHED() << "called on invalid thread";
21     return false;
22   }
23 
24   CefTraceSubscriber* subscriber = CefContext::Get()->GetTraceSubscriber();
25   if (!subscriber)
26     return false;
27 
28   return subscriber->BeginTracing(categories, callback);
29 }
30 
CefEndTracing(const CefString & tracing_file,CefRefPtr<CefEndTracingCallback> callback)31 bool CefEndTracing(const CefString& tracing_file,
32                    CefRefPtr<CefEndTracingCallback> callback) {
33   if (!CONTEXT_STATE_VALID()) {
34     NOTREACHED() << "context not valid";
35     return false;
36   }
37 
38   if (!CEF_CURRENTLY_ON_UIT()) {
39     NOTREACHED() << "called on invalid thread";
40     return false;
41   }
42 
43   CefTraceSubscriber* subscriber = CefContext::Get()->GetTraceSubscriber();
44   if (!subscriber)
45     return false;
46 
47   return subscriber->EndTracing(base::FilePath(tracing_file), callback);
48 }
49 
CefNowFromSystemTraceTime()50 int64 CefNowFromSystemTraceTime() {
51   return base::TimeTicks::Now().ToInternalValue();
52 }
53