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

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: Record only until full in the reactive case Created 5 years, 6 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_ 6 #define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
7 7
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 12 matching lines...) Expand all
23 const ReceiveCallback&, 23 const ReceiveCallback&,
24 bool) override; 24 bool) override;
25 void WhenIdle(IdleCallback idle_callback) override; 25 void WhenIdle(IdleCallback idle_callback) override;
26 26
27 void TriggerNamedEvent(TriggerHandle, StartedFinalizingCallback) override; 27 void TriggerNamedEvent(TriggerHandle, StartedFinalizingCallback) override;
28 TriggerHandle RegisterTriggerType(const char* trigger_name) override; 28 TriggerHandle RegisterTriggerType(const char* trigger_name) override;
29 void GetTriggerNameList(std::vector<std::string>* trigger_names) override; 29 void GetTriggerNameList(std::vector<std::string>* trigger_names) override;
30 30
31 void InvalidateTriggerHandlesForTesting() override; 31 void InvalidateTriggerHandlesForTesting() override;
32 32
33 void FireTimerForTesting() override;
34
33 private: 35 private:
34 BackgroundTracingManagerImpl(); 36 BackgroundTracingManagerImpl();
35 ~BackgroundTracingManagerImpl() override; 37 ~BackgroundTracingManagerImpl() override;
36 38
37 void EnableRecording(std::string category_filter_str); 39 void EnableRecording(std::string, base::trace_event::TraceRecordMode);
38 void EnableRecordingIfConfigNeedsIt(); 40 void EnableRecordingIfConfigNeedsIt();
39 void OnFinalizeStarted(scoped_refptr<base::RefCountedString>); 41 void OnFinalizeStarted(scoped_refptr<base::RefCountedString>);
40 void OnFinalizeComplete(); 42 void OnFinalizeComplete();
41 void BeginFinalizing(StartedFinalizingCallback); 43 void BeginFinalizing(StartedFinalizingCallback);
42 44
43 std::string GetTriggerNameFromHandle(TriggerHandle handle) const; 45 std::string GetTriggerNameFromHandle(TriggerHandle handle) const;
44 bool IsTriggerHandleValid(TriggerHandle handle) const; 46 bool IsTriggerHandleValid(TriggerHandle handle) const;
45 47
46 bool IsAbleToTriggerTracing(TriggerHandle handle) const; 48 bool IsAbleToTriggerTracing(TriggerHandle handle) const;
47 bool IsSupportedConfig(BackgroundTracingConfig* config); 49 bool IsSupportedConfig(BackgroundTracingConfig* config);
48 50
49 std::string GetCategoryFilterStringForCategoryPreset( 51 std::string GetCategoryFilterStringForCategoryPreset(
50 BackgroundTracingConfig::CategoryPreset) const; 52 BackgroundTracingConfig::CategoryPreset) const;
51 53
52 class TraceDataEndpointWrapper 54 class TraceDataEndpointWrapper
53 : public content::TracingController::TraceDataEndpoint { 55 : public content::TracingController::TraceDataEndpoint {
54 public: 56 public:
55 TraceDataEndpointWrapper(base::Callback< 57 TraceDataEndpointWrapper(base::Callback<
56 void(scoped_refptr<base::RefCountedString>)> done_callback); 58 void(scoped_refptr<base::RefCountedString>)> done_callback);
57 59
58 void ReceiveTraceFinalContents(const std::string& file_contents) override; 60 void ReceiveTraceFinalContents(const std::string& file_contents) override;
59 61
60 private: 62 private:
61 ~TraceDataEndpointWrapper() override; 63 ~TraceDataEndpointWrapper() override;
62 64
63 base::Callback<void(scoped_refptr<base::RefCountedString>)> done_callback_; 65 base::Callback<void(scoped_refptr<base::RefCountedString>)> done_callback_;
64 }; 66 };
65 67
68 class TracingTimer {
69 public:
70 TracingTimer(StartedFinalizingCallback);
dsinclair 2015/06/03 14:15:30 nit: explicit TracingTimer(StartedFinalizingCallba
fmeawad 2015/06/03 18:00:18 Done.
71 ~TracingTimer();
72
73 void StartTimer();
74 void CancelTimer();
75
76 void FireTimerForTesting();
77
78 private:
79 void TracingTimerFired();
80
81 base::OneShotTimer<TracingTimer> tracing_timer_;
82 BackgroundTracingManager::StartedFinalizingCallback callback_;
dsinclair 2015/06/03 14:15:30 nit: Why does this need the BackgroundTracingManag
fmeawad 2015/06/03 18:00:18 Done.
83 };
84
66 scoped_ptr<content::BackgroundTracingConfig> config_; 85 scoped_ptr<content::BackgroundTracingConfig> config_;
67 scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_; 86 scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_;
68 std::map<TriggerHandle, std::string> trigger_handles_; 87 std::map<TriggerHandle, std::string> trigger_handles_;
88 scoped_ptr<TracingTimer> tracing_timer_;
69 ReceiveCallback receive_callback_; 89 ReceiveCallback receive_callback_;
70 90
71 bool is_gathering_; 91 bool is_gathering_;
72 bool is_tracing_; 92 bool is_tracing_;
73 bool requires_anonymized_data_; 93 bool requires_anonymized_data_;
74 int trigger_handle_ids_; 94 int trigger_handle_ids_;
75 95
76 IdleCallback idle_callback_; 96 IdleCallback idle_callback_;
77 97
78 friend struct base::DefaultLazyInstanceTraits<BackgroundTracingManagerImpl>; 98 friend struct base::DefaultLazyInstanceTraits<BackgroundTracingManagerImpl>;
79 99
80 DISALLOW_COPY_AND_ASSIGN(BackgroundTracingManagerImpl); 100 DISALLOW_COPY_AND_ASSIGN(BackgroundTracingManagerImpl);
81 }; 101 };
82 102
83 } // namespace content 103 } // namespace content
84 104
85 #endif // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_ 105 #endif // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698