tracing.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_TEST_BASE_TRACING_H_
6#define CHROME_TEST_BASE_TRACING_H_
7
8#include <string>
9
10#include "base/compiler_specific.h"
11#include "base/time.h"
12
13namespace tracing {
14
15// Called from UI thread.
16// Begin tracing specified categories on the browser.
17// |categories| is a comma-delimited list of category wildcards. A category can
18// have an optional '-' prefix to make it an excluded category. Either all
19// categories must be included or all must be excluded.
20//
21// Example: BeginTracing("test_MyTest*");
22// Example: BeginTracing("test_MyTest*,test_OtherStuff");
23// Example: BeginTracing("-excluded_category1,-excluded_category2");
24//
25// See base/debug/trace_event.h for documentation of included and excluded
26// categories.
27bool BeginTracing(const std::string& categories) WARN_UNUSED_RESULT;
28
29// Called from UI thread.
30// Specify a watch event in order to use the WaitForWatchEvent function.
31// After |num_occurrences| of the given event have been seen on a particular
32// process, WaitForWatchEvent will return.
33bool BeginTracingWithWatch(const std::string& categories,
34                           const std::string& category_name,
35                           const std::string& event_name,
36                           int num_occurrences) WARN_UNUSED_RESULT;
37
38// Called from UI thread.
39// Wait on the event set with BeginTracingWithWatch. If non-zero, return after
40// |timeout| regardless of watch event notification. Returns true if watch event
41// occurred, false if it timed out.
42bool WaitForWatchEvent(base::TimeDelta timeout) WARN_UNUSED_RESULT;
43
44// Called from UI thread.
45// End trace and collect the trace output as a json string.
46bool EndTracing(std::string* json_trace_output) WARN_UNUSED_RESULT;
47
48}  // namespace tracing
49
50#endif  // CHROME_TEST_BASE_TRACING_H_
51