OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 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 BASE_TRACE_EVENT_TRACE_OPTIONS_H_ |
| 6 #define BASE_TRACE_EVENT_TRACE_OPTIONS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/base_export.h" |
| 11 |
| 12 namespace base { |
| 13 namespace trace_event { |
| 14 |
| 15 // Options determines how the trace buffer stores data. |
| 16 enum TraceRecordMode { |
| 17 // Record until the trace buffer is full. |
| 18 RECORD_UNTIL_FULL, |
| 19 |
| 20 // Record until the user ends the trace. The trace buffer is a fixed size |
| 21 // and we use it as a ring buffer during recording. |
| 22 RECORD_CONTINUOUSLY, |
| 23 |
| 24 // Echo to console. Events are discarded. |
| 25 ECHO_TO_CONSOLE, |
| 26 |
| 27 // Record until the trace buffer is full, but with a huge buffer size. |
| 28 RECORD_AS_MUCH_AS_POSSIBLE |
| 29 }; |
| 30 |
| 31 struct BASE_EXPORT TraceOptions { |
| 32 TraceOptions() |
| 33 : record_mode(RECORD_UNTIL_FULL), |
| 34 enable_sampling(false), |
| 35 enable_systrace(false), |
| 36 enable_argument_filter(false) {} |
| 37 |
| 38 explicit TraceOptions(TraceRecordMode record_mode) |
| 39 : record_mode(record_mode), |
| 40 enable_sampling(false), |
| 41 enable_systrace(false), |
| 42 enable_argument_filter(false) {} |
| 43 |
| 44 // |options_string| is a comma-delimited list of trace options. |
| 45 // Possible options are: "record-until-full", "record-continuously", |
| 46 // "trace-to-console", "enable-sampling" and "enable-systrace". |
| 47 // The first 3 options are trace recoding modes and hence |
| 48 // mutually exclusive. If more than one trace recording modes appear in the |
| 49 // options_string, the last one takes precedence. If none of the trace |
| 50 // recording mode is specified, recording mode is RECORD_UNTIL_FULL. |
| 51 // |
| 52 // The trace option will first be reset to the default option |
| 53 // (record_mode set to RECORD_UNTIL_FULL, enable_sampling and enable_systrace |
| 54 // set to false) before options parsed from |options_string| are applied on |
| 55 // it. |
| 56 // If |options_string| is invalid, the final state of trace_options is |
| 57 // undefined. |
| 58 // |
| 59 // Example: trace_options.SetFromString("record-until-full") |
| 60 // Example: trace_options.SetFromString( |
| 61 // "record-continuously, enable-sampling") |
| 62 // Example: trace_options.SetFromString("record-until-full, trace-to-console") |
| 63 // will set ECHO_TO_CONSOLE as the recording mode. |
| 64 // |
| 65 // Returns true on success. |
| 66 bool SetFromString(const std::string& options_string); |
| 67 |
| 68 std::string ToString() const; |
| 69 |
| 70 TraceRecordMode record_mode; |
| 71 bool enable_sampling; |
| 72 bool enable_systrace; |
| 73 bool enable_argument_filter; |
| 74 }; |
| 75 |
| 76 } // namespace trace_event |
| 77 } // namespace base |
| 78 |
| 79 #endif // BASE_TRACE_EVENT_TRACE_OPTIONS_H_ |
OLD | NEW |