Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: content/browser/tracing/background_tracing_manager_impl.h

Issue 1148393003: Implement Reactive Configuration in Background Tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 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 CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
7
8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/timer/timer.h"
13 #include "content/browser/tracing/tracing_controller_impl.h"
14 #include "content/public/browser/background_tracing_config.h"
15 #include "content/public/browser/background_tracing_manager.h"
16
17 namespace content {
18
19 class BackgroundTracingManagerImpl : public content::BackgroundTracingManager {
20 public:
21 static BackgroundTracingManagerImpl* GetInstance();
22
23 bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig>,
24 const ReceiveCallback&,
25 bool) override;
26 void WhenIdle(IdleCallback idle_callback) override;
27
28 void TriggerNamedEvent(TriggerHandle, StartedFinalizingCallback) override;
29 TriggerHandle RegisterTriggerType(const char* trigger_name) override;
30 void GetTriggerNameList(std::vector<std::string>* trigger_names) override;
31
32 void InvalidateTriggerHandlesForTesting() override;
33
34 private:
35 BackgroundTracingManagerImpl();
36 ~BackgroundTracingManagerImpl() override;
37
38 void EnableRecording(base::trace_event::CategoryFilter);
39 void EnableRecordingIfConfigNeedsIt();
40 void OnFinalizeStarted(scoped_refptr<base::RefCountedString>);
41 void OnFinalizeComplete();
42 void OnTracingTimeout();
43 void BeginFinalizing(StartedFinalizingCallback);
44
45 std::string GetTriggerNameFromHandle(TriggerHandle handle) const;
46 bool IsTriggerHandleValid(TriggerHandle handle) const;
47
48 bool IsAbleToTriggerTracing(TriggerHandle handle) const;
49 bool IsSupportedConfig(BackgroundTracingConfig* config);
50
51 base::trace_event::CategoryFilter GetCategoryFilterForCategoryPreset(
52 BackgroundTracingConfig::CategoryPreset) const;
53
54 class TraceDataEndpointWrapper
55 : public content::TracingController::TraceDataEndpoint {
56 public:
57 TraceDataEndpointWrapper(base::Callback<
58 void(scoped_refptr<base::RefCountedString>)> done_callback);
59
60 void ReceiveTraceFinalContents(const std::string& file_contents) override;
61
62 private:
63 ~TraceDataEndpointWrapper() override;
64
65 base::Callback<void(scoped_refptr<base::RefCountedString>)> done_callback_;
66 };
67
68 class TracingTimer {
69 public:
70 TracingTimer(StartedFinalizingCallback);
71
72 void StartTimer();
73 void CancelTimer();
74
75 private:
76 ~TracingTimer();
77
78 void TracingTimerFired();
79
80 base::OneShotTimer<TracingTimer> tracing_timer_;
81 BackgroundTracingManager::StartedFinalizingCallback callback_;
82 };
83
84 scoped_ptr<content::BackgroundTracingConfig> config_;
85 scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_;
86 std::map<TriggerHandle, std::string> trigger_handles_;
87 ReceiveCallback receive_callback_;
88
89 bool is_gathering_;
90 bool is_tracing_;
91 bool requires_anonymized_data_;
92 int trigger_handle_ids_;
93
94 IdleCallback idle_callback_;
95
96 friend struct base::DefaultLazyInstanceTraits<BackgroundTracingManagerImpl>;
97
98 DISALLOW_COPY_AND_ASSIGN(BackgroundTracingManagerImpl);
99 };
100
101 } // namespace content
102
103 #endif // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698