OLD | NEW |
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_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
7 | 7 |
8 #include "base/trace_event/trace_event_impl.h" | 8 #include "base/trace_event/trace_event_impl.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // void Upload(const base::RefCountedString* data, | 32 // void Upload(const base::RefCountedString* data, |
33 // base::Closure done_callback) { | 33 // base::Closure done_callback) { |
34 // BrowserThread::PostTaskAndReply( | 34 // BrowserThread::PostTaskAndReply( |
35 // BrowserThread::FILE, | 35 // BrowserThread::FILE, |
36 // FROM_HERE, | 36 // FROM_HERE, |
37 // base::Bind(&DoUploadOnFileThread, data), | 37 // base::Bind(&DoUploadOnFileThread, data), |
38 // done_callback | 38 // done_callback |
39 // ); | 39 // ); |
40 // } | 40 // } |
41 // | 41 // |
42 typedef base::Callback<void(const base::RefCountedString*, base::Closure)> | 42 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&, |
43 ReceiveCallback; | 43 base::Closure)> ReceiveCallback; |
44 | 44 |
45 // Set the triggering rules for when to start recording. | 45 // Set the triggering rules for when to start recording. |
46 // | 46 // |
47 // In preemptive mode, recording begins immediately and any calls to | 47 // In preemptive mode, recording begins immediately and any calls to |
48 // TriggerNamedEvent() will potentially trigger the trace to finalize and get | 48 // TriggerNamedEvent() will potentially trigger the trace to finalize and get |
49 // uploaded to the specified upload_sink. Once the trace has been uploaded, | 49 // uploaded to the specified upload_sink. Once the trace has been uploaded, |
50 // tracing will be enabled again. | 50 // tracing will be enabled again. |
51 // | 51 // |
52 // In reactive mode, recording begins when TriggerNamedEvent() is called, and | 52 // In reactive mode, recording begins when TriggerNamedEvent() is called, and |
53 // continues until either the next call to TriggerNamedEvent, or a timeout | 53 // continues until either the next call to TriggerNamedEvent, or a timeout |
54 // occurs. Tracing will not be re-enabled after the trace is finalized and | 54 // occurs. Tracing will not be re-enabled after the trace is finalized and |
55 // uploaded to the upload_sink. | 55 // uploaded to the upload_sink. |
56 // | 56 // |
57 // Calls to SetActiveScenario() with a config will fail if tracing is | 57 // Calls to SetActiveScenario() with a config will fail if tracing is |
58 // currently on. Use WhenIdle to register a callback to get notified when | 58 // currently on. Use WhenIdle to register a callback to get notified when |
59 // the manager is idle and a config can be set again. | 59 // the manager is idle and a config can be set again. |
| 60 enum DataFiltering { |
| 61 NO_DATA_FILTERING, |
| 62 ANONYMIZE_DATA, |
| 63 }; |
60 virtual bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig> config, | 64 virtual bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig> config, |
61 const ReceiveCallback& receive_callback, | 65 const ReceiveCallback& receive_callback, |
62 bool requires_anonymized_data) = 0; | 66 DataFiltering data_filtering) = 0; |
63 | 67 |
64 // Notifies the caller when the manager is idle (not recording or uploading), | 68 // Notifies the caller when the manager is idle (not recording or uploading), |
65 // so that a call to SetActiveScenario() is likely to succeed. | 69 // so that a call to SetActiveScenario() is likely to succeed. |
66 typedef base::Callback<void()> IdleCallback; | 70 typedef base::Callback<void()> IdleCallback; |
67 virtual void WhenIdle(IdleCallback idle_callback) = 0; | 71 virtual void WhenIdle(IdleCallback idle_callback) = 0; |
68 | 72 |
69 typedef base::Callback<void(bool)> StartedFinalizingCallback; | 73 typedef base::Callback<void(bool)> StartedFinalizingCallback; |
70 typedef int TriggerHandle; | 74 typedef int TriggerHandle; |
71 | 75 |
72 // Notifies that a manual trigger event has occurred, and we may need to | 76 // Notifies that a manual trigger event has occurred, and we may need to |
73 // either begin recording or finalize the trace, depending on the config. | 77 // either begin recording or finalize the trace, depending on the config. |
74 // If the trigger specified isn't active in the config, this will do nothing. | 78 // If the trigger specified isn't active in the config, this will do nothing. |
75 virtual void TriggerNamedEvent( | 79 virtual void TriggerNamedEvent( |
76 TriggerHandle trigger_handle, | 80 TriggerHandle trigger_handle, |
77 StartedFinalizingCallback started_callback) = 0; | 81 StartedFinalizingCallback started_callback) = 0; |
78 | 82 |
79 // Registers a manual trigger handle, and returns a TriggerHandle which can | 83 // Registers a manual trigger handle, and returns a TriggerHandle which can |
80 // be passed to DidTriggerHappen(). | 84 // be passed to DidTriggerHappen(). |
81 virtual TriggerHandle RegisterTriggerType(const char* trigger_name) = 0; | 85 virtual TriggerHandle RegisterTriggerType(const char* trigger_name) = 0; |
82 | 86 |
83 // Returns a list of all registered triggers. | 87 // Returns a list of all registered triggers. |
84 virtual void GetTriggerNameList(std::vector<std::string>* trigger_names) = 0; | 88 virtual void GetTriggerNameList(std::vector<std::string>* trigger_names) = 0; |
85 | 89 |
86 virtual void InvalidateTriggerHandlesForTesting() = 0; | 90 virtual void InvalidateTriggerHandlesForTesting() = 0; |
87 | 91 virtual void SetTracingEnabledCallbackForTesting( |
| 92 const base::Closure& callback) = 0; |
88 virtual void FireTimerForTesting() = 0; | 93 virtual void FireTimerForTesting() = 0; |
89 | 94 |
90 protected: | 95 protected: |
91 virtual ~BackgroundTracingManager() {} | 96 virtual ~BackgroundTracingManager() {} |
92 }; | 97 }; |
93 | 98 |
94 } // namespace content | 99 } // namespace content |
95 | 100 |
96 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | 101 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
OLD | NEW |