Chromium Code Reviews| Index: content/public/browser/background_tracing_manager.h |
| diff --git a/content/public/browser/background_tracing_manager.h b/content/public/browser/background_tracing_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..10ff43fee457738df8a26edda0e8e823f16dab3f |
| --- /dev/null |
| +++ b/content/public/browser/background_tracing_manager.h |
| @@ -0,0 +1,140 @@ |
| +// 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_MANAGER_H_ |
| +#define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
| + |
| +#include "base/memory/ref_counted_memory.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/trace_event/trace_event_impl.h" |
| +#include "base/values.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +class BackgroundTracingConfig : |
| + public base::RefCountedThreadSafe<BackgroundTracingConfig> { |
| + public: |
| + enum Mode { |
| + PREEMPTIVE_TRACING_MODE, |
| + REACTIVE_TRACING_MODE, |
| + }; |
| + |
| + enum CategoryPreset { |
| + BENCHMARK, |
| + BENCHMARK_DEEP, |
| + }; |
| + |
| + BackgroundTracingConfig(Mode); |
| + |
| + Mode mode; |
|
oystein (OOO til 10th of July)
2015/05/05 19:28:31
private or in the impl maybe?
|
| + |
| + static bool FromDict(const base::DictionaryValue*); |
| + void IntoDict(base::DictionaryValue*); |
|
oystein (OOO til 10th of July)
2015/05/05 19:28:31
Are these the to/from JSON things? I don't remembe
shatch
2015/05/05 20:20:23
Yep
|
| + |
| + protected: |
| + friend class base::RefCountedThreadSafe<BackgroundTracingConfig>; |
| + virtual ~BackgroundTracingConfig(); |
| +}; |
| + |
| +class 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; |
| + }; |
| + std::vector<MonitoringRule> configs; |
|
shatch
2015/05/05 18:50:21
Anybody got any thoughts on these configs?
oystein (OOO til 10th of July)
2015/05/05 19:28:31
Hmm. Maybe this should just be how it's stored int
shatch
2015/05/05 20:20:23
so something like:
class BackgroundTracingPreempt
oystein (OOO til 10th of July)
2015/05/05 20:40:10
I was thinking more that the config class which ge
|
| + CategoryPreset category_preset; |
| + |
| + static bool FromDict(const base::DictionaryValue*); |
| + void IntoDict(base::DictionaryValue*); |
| + |
| + protected: |
| + ~BackgroundTracingPreemptiveConfig() override; |
| +}; |
| + |
| +class 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; |
| + }; |
| + std::vector<TracingRule> configs; |
| + |
| + static bool FromDict(const base::DictionaryValue*); |
| + void IntoDict(base::DictionaryValue*); |
| + |
| + protected: |
| + ~BackgroundTracingReactiveConfig() override; |
| +}; |
| + |
| + |
| +// BackgroundTracingManager is used on the browser process to trigger the |
| +// collection of trace data and upload the results. Only the browser UI thread |
| +// is allowed to interact with the BackgroundTracingManager. All callbacks are |
| +// called on the UI thread. |
| +class BackgroundTracingManager { |
| + public: |
| + CONTENT_EXPORT static BackgroundTracingManager* GetInstance(); |
| + |
| + // Interface for trace data consumer. An implemnentation of this interface |
| + // is passed to SetActiveScenario() and receives the trace data. |
| + // This may happen on any thread. |
| + class UploadSink : |
|
shatch
2015/05/05 18:50:21
I moved this in here, should we just leave it out
oystein (OOO til 10th of July)
2015/05/05 19:28:31
Or maybe even just TracingUploadSink; they aren't
shatch
2015/05/05 20:20:23
I guess, but who else might use it? Kinda feels we
oystein (OOO til 10th of July)
2015/05/05 20:40:10
True enough.
|
| + public base::RefCountedThreadSafe<UploadSink> { |
| + public: |
| + virtual void Upload(const std::string&, base::Callback<void()>) = 0; |
| + virtual bool RequiresAnonymizedData() const = 0; |
| + |
| + protected: |
| + friend class base::RefCountedThreadSafe<UploadSink>; |
| + virtual ~UploadSink() {} |
| + }; |
| + |
| + virtual bool SetActiveScenario( |
| + scoped_refptr<BackgroundTracingConfig>, |
| + scoped_refptr<UploadSink>) = 0; |
| + |
| + typedef base::Callback<void()> IdleCallback; |
| + virtual void WhenIdle(IdleCallback idle_callback) = 0; |
| + |
| + typedef base::Callback<void(bool)> StartedFinalizingCallback; |
| + typedef size_t TriggerHandle; |
| + |
| + virtual void DidTriggerHappen(TriggerHandle, StartedFinalizingCallback) = 0; |
| + virtual TriggerHandle RegisterTriggerType(const char* trigger_name) = 0; |
| + virtual void GetTriggerNameList(std::vector<std::string>& trigger_names) = 0; |
| + virtual void InvalidateTriggerHandlesForTesting() = 0; |
| + |
| + protected: |
| + virtual ~BackgroundTracingManager() {} |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |