summaryrefslogtreecommitdiffstats
path: root/content/browser/tracing/background_tracing_config_impl.h
blob: c3ff85cab1ccd3301e2e826ac7e01d9c9bb59d97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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_BROWSER_TRACING_BACKGROUND_TRACING_CONFIG_IMPL_H_
#define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_CONFIG_IMPL_H_

#include "base/memory/scoped_vector.h"
#include "content/common/content_export.h"
#include "content/public/browser/background_tracing_config.h"

namespace content {
class BackgroundTracingRule;

class CONTENT_EXPORT BackgroundTracingConfigImpl
    : public BackgroundTracingConfig {
 public:
  explicit BackgroundTracingConfigImpl(TracingMode tracing_mode);

  ~BackgroundTracingConfigImpl() override;

  // From BackgroundTracingConfig
  void IntoDict(base::DictionaryValue* dict) const override;

  enum CategoryPreset {
    BENCHMARK,
    BENCHMARK_DEEP,
    BENCHMARK_GPU,
    BENCHMARK_IPC,
    BENCHMARK_STARTUP,
  };

  CategoryPreset category_preset() const { return category_preset_; }
  void set_category_preset(CategoryPreset category_preset) {
    category_preset_ = category_preset;
  }

  const ScopedVector<BackgroundTracingRule>& rules() const { return rules_; }

  void AddPreemptiveRule(const base::DictionaryValue* dict);
  void AddReactiveRule(
      const base::DictionaryValue* dict,
      BackgroundTracingConfigImpl::CategoryPreset category_preset);

  static scoped_ptr<BackgroundTracingConfigImpl> PreemptiveFromDict(
      const base::DictionaryValue* dict);
  static scoped_ptr<BackgroundTracingConfigImpl> ReactiveFromDict(
      const base::DictionaryValue* dict);

  static scoped_ptr<BackgroundTracingConfigImpl> FromDict(
      const base::DictionaryValue* dict);

  static std::string CategoryPresetToString(
      BackgroundTracingConfigImpl::CategoryPreset category_preset);
  static bool StringToCategoryPreset(
      const std::string& category_preset_string,
      BackgroundTracingConfigImpl::CategoryPreset* category_preset);

 private:
  CategoryPreset category_preset_;
  ScopedVector<BackgroundTracingRule> rules_;

  DISALLOW_COPY_AND_ASSIGN(BackgroundTracingConfigImpl);
};

}  // namespace content

#endif  // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_CONFIG_IMPL_H_