Chromium Code Reviews| Index: content/public/browser/background_tracing_config.h |
| diff --git a/content/public/browser/background_tracing_config.h b/content/public/browser/background_tracing_config.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9acec8e1b2ecabd70765dd98e0bc6ad8a16d76bd |
| --- /dev/null |
| +++ b/content/public/browser/background_tracing_config.h |
| @@ -0,0 +1,120 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_CONFIG_H_ |
| +#define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_CONFIG_H_ |
| + |
| +#include "base/memory/ref_counted_memory.h" |
| +#include "base/trace_event/trace_event_impl.h" |
| +#include "base/values.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +// BackgroundTracingConfig is passed to the BackgroundTracingManager to |
| +// setup the trigger rules used to enable/disable background tracing. |
| +class CONTENT_EXPORT BackgroundTracingConfig |
| + : public base::RefCountedThreadSafe<BackgroundTracingConfig> { |
| + public: |
| + enum Mode { |
|
no sievers
2015/05/11 21:13:27
each interface/struct/enum should be in a separate
shatch
2015/05/12 21:00:05
Yeah I saw that rule but wasn't clear if that also
|
| + PREEMPTIVE_TRACING_MODE, |
| + REACTIVE_TRACING_MODE, |
| + }; |
| + enum CategoryPreset { |
| + BENCHMARK, |
| + BENCHMARK_DEEP, |
| + }; |
| + |
| + Mode mode() const; |
| + |
| + static BackgroundTracingConfig* FromDict(const base::DictionaryValue* dict); |
| + void IntoDict(base::DictionaryValue* dict); |
| + |
| + protected: |
| + friend class base::RefCountedThreadSafe<BackgroundTracingConfig>; |
| + |
| + BackgroundTracingConfig(Mode mode); |
| + virtual ~BackgroundTracingConfig(); |
| + |
| + Mode mode_; |
| +}; |
| + |
| +// BackgroundTracingPreemptiveConfig holds trigger rules for use during |
| +// preemptive tracing. Tracing will be enabled immediately, and whenever |
| +// a trigger occurs, the trace will be finalized. |
| +class CONTENT_EXPORT BackgroundTracingPreemptiveConfig |
| + : public BackgroundTracingConfig { |
| + public: |
| + BackgroundTracingPreemptiveConfig(); |
| + |
| + enum RuleType { |
| + MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED, |
| + MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE, |
| + MONITOR_AND_DUMP_WHEN_BROWSER_STARTED, |
| + }; |
| + struct HistogramTriggerInfo { |
| + std::string histogram_name_to_trigger_on; |
| + int histogram_bin_to_trigger_on; |
| + }; |
| + struct NamedTriggerInfo { |
| + std::string trigger_name; |
| + }; |
| + struct MonitoringRule { |
| + RuleType type; |
| + HistogramTriggerInfo histogram_trigger_info; |
| + NamedTriggerInfo named_trigger_info; |
| + }; |
| + |
| + void AddHistogramTriggerRule(const std::string& histogram_name, |
| + int histogram_bin); |
| + void AddNamedTriggerRule(const std::string& trigger_name); |
| + |
| + CategoryPreset category_preset() const; |
| + const std::vector<MonitoringRule>& configs() const; |
| + |
| + static BackgroundTracingPreemptiveConfig* FromDict( |
| + const base::DictionaryValue* dict); |
| + void AsDict(base::DictionaryValue* dict); |
| + |
| + protected: |
| + ~BackgroundTracingPreemptiveConfig() override; |
| + |
| + std::vector<MonitoringRule> configs_; |
| + CategoryPreset category_preset_; |
| +}; |
| + |
| +// BackgroundTracingReactiveConfig holds trigger rules for use during |
| +// reactive tracing. Tracing will be not be enabled immediately, rather |
| +// the BackgroundTracingManager will wait for a trigger to occur, and |
| +// enable tracing at that point. Tracing will be finalized later, either |
| +// after some time has elapsed or the trigger occurs again. |
| +class CONTENT_EXPORT BackgroundTracingReactiveConfig |
| + : public BackgroundTracingConfig { |
| + public: |
| + BackgroundTracingReactiveConfig(); |
| + |
| + enum RuleType { TRACE_ON_TRIGGER_UNTIL_10S_OR_NEXT_TRIGGER_OR_FULL }; |
| + struct TracingRule { |
| + RuleType type; |
| + std::string trigger_name; |
| + CategoryPreset category_preset; |
| + }; |
| + |
| + void AddTracingRule(RuleType rule_type, |
| + const char* trigger_name, |
| + CategoryPreset category_preset); |
| + |
| + static BackgroundTracingReactiveConfig* FromDict( |
| + const base::DictionaryValue* dict); |
| + void AsDict(base::DictionaryValue* dict); |
| + |
| + protected: |
| + ~BackgroundTracingReactiveConfig() override; |
| + |
| + std::vector<TracingRule> configs; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_CONFIG_H_ |