OLD | NEW |
---|---|
(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_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | |
6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | |
7 | |
8 #include "base/trace_event/trace_event_impl.h" | |
9 #include "base/values.h" | |
10 #include "content/common/content_export.h" | |
11 | |
12 namespace content { | |
13 struct BackgroundTracingConfig; | |
14 struct BackgroundTracingUploadConfig; | |
15 | |
16 // BackgroundTracingManager is used on the browser process to trigger the | |
17 // collection of trace data and upload the results. Only the browser UI thread | |
18 // is allowed to interact with the BackgroundTracingManager. All callbacks are | |
19 // called on the UI thread. | |
20 class BackgroundTracingManager { | |
21 public: | |
22 CONTENT_EXPORT static BackgroundTracingManager* GetInstance(); | |
23 | |
24 typedef base::Callback<void(base::RefCountedString*, base::Callback<void()>)> | |
no sievers
2015/05/20 19:22:39
const base::RefCountedString*?
no sievers
2015/05/20 19:22:39
nit: base::Callback<void()> -> base::Closure
no sievers
2015/05/20 19:22:40
Can you document what the arguments are?
Esp. for
shatch
2015/05/20 19:53:55
Done.
shatch
2015/05/20 19:53:55
Done.
| |
25 ReceiveCallback; | |
26 | |
27 // Set the triggering rules for when to start recording. | |
28 // | |
29 // In preemptive mode, recording begins immediately and any calls to | |
30 // TriggerNamedEvent() will potentially trigger the trace to finalize and get | |
31 // uploaded to the specified upload_sink. Once the trace has been uploaded, | |
32 // tracing will be enabled again. | |
33 // | |
34 // In reactive mode, recording begins when TriggerNamedEvent() is called, and | |
35 // continues until either the next call to TriggerNamedEvent, or a timeout | |
36 // occurs. Tracing will not be re-enabled after the trace is finalized and | |
37 // uploaded to the upload_sink. | |
38 // | |
39 // Calls to SetActiveScenario() with a config will fail if tracing is | |
40 // currently on. Use WhenIdle to register a callback to get notified when | |
41 // the manager is idle and a config can be set again. | |
42 virtual bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig> config, | |
43 const ReceiveCallback& receive_callback, | |
44 bool requires_anonymized_data) = 0; | |
45 | |
46 // Notifies the caller when the manager is idle (not recording or uploading), | |
47 // so that a call to SetActiveScenario() is likely to succeed. | |
48 typedef base::Callback<void()> IdleCallback; | |
49 virtual void WhenIdle(IdleCallback idle_callback) = 0; | |
50 | |
51 typedef base::Callback<void(bool)> StartedFinalizingCallback; | |
52 typedef int TriggerHandle; | |
53 | |
54 // Notifies that a manual trigger event has occurred, and we may need to | |
55 // either begin recording or finalize the trace, depending on the config. | |
56 // If the trigger specified isn't active in the config, this will do nothing. | |
57 virtual void TriggerNamedEvent( | |
58 TriggerHandle, | |
no sievers
2015/05/20 19:22:39
nit: 'TriggerHandle trigger_handle' for consistenc
shatch
2015/05/20 19:53:55
Done.
| |
59 StartedFinalizingCallback started_callback) = 0; | |
60 | |
61 // Registers a manual trigger handle, and returns a TriggerHandle which can | |
62 // be passed to DidTriggerHappen(). | |
63 virtual TriggerHandle RegisterTriggerType(const char* trigger_name) = 0; | |
64 | |
65 // Returns a list of all registered triggers. | |
66 virtual void GetTriggerNameList(std::vector<std::string>& trigger_names) = 0; | |
no sievers
2015/05/20 19:22:39
nit: 'std::vector<std::string>*', by pointer when
shatch
2015/05/20 19:53:55
Done.
| |
67 | |
68 virtual void InvalidateTriggerHandlesForTesting() = 0; | |
69 | |
70 protected: | |
71 virtual ~BackgroundTracingManager() {} | |
72 }; | |
73 | |
74 } // namespace content | |
75 | |
76 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | |
OLD | NEW |