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 class BackgroundTracingUploadSink; |
| 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 // Set the triggering rules for when to start recording. |
| 25 // |
| 26 // In preemptive mode, recording begins immediately and any calls to |
| 27 // TriggerNamedEvent() will potentially trigger the trace to finalize and get |
| 28 // uploaded to the specified upload_sink. Once the trace has been uploaded, |
| 29 // tracing will be enabled again. |
| 30 // |
| 31 // In reactive mode, recording begins when TriggerNamedEvent() is called, and |
| 32 // continues until either the next call to TriggerNamedEvent, or a timeout |
| 33 // occurs. Tracing will not be re-enabled after the trace is finalized and |
| 34 // uploaded to the upload_sink. |
| 35 // |
| 36 // Calls to SetActiveScenario() with a config will fail if tracing is |
| 37 // currently on. Use WhenIdle to register a callback to get notified when |
| 38 // the manager is idle and a config can be set again. |
| 39 virtual bool SetActiveScenario( |
| 40 scoped_ptr<BackgroundTracingConfig> config, |
| 41 scoped_refptr<BackgroundTracingUploadSink> upload_sink) = 0; |
| 42 |
| 43 // Notifies the caller when the manager is idle (not recording or uploading), |
| 44 // so that a call to SetActiveScenario() is likely to succeed. |
| 45 typedef base::Callback<void()> IdleCallback; |
| 46 virtual void WhenIdle(IdleCallback idle_callback) = 0; |
| 47 |
| 48 typedef base::Callback<void(bool)> StartedFinalizingCallback; |
| 49 typedef int TriggerHandle; |
| 50 |
| 51 // Notifies that a manual trigger event has occurred, and we may need to |
| 52 // either begin recording or finalize the trace, depending on the config. |
| 53 // If the trigger specified isn't active in the config, this will do nothing. |
| 54 virtual void TriggerNamedEvent( |
| 55 TriggerHandle, |
| 56 StartedFinalizingCallback started_callback) = 0; |
| 57 |
| 58 // Registers a manual trigger handle, and returns a TriggerHandle which can |
| 59 // be passed to DidTriggerHappen(). |
| 60 virtual TriggerHandle RegisterTriggerType(const char* trigger_name) = 0; |
| 61 |
| 62 // Returns a list of all registered triggers. |
| 63 virtual void GetTriggerNameList(std::vector<std::string>& trigger_names) = 0; |
| 64 |
| 65 virtual void InvalidateTriggerHandlesForTesting() = 0; |
| 66 |
| 67 protected: |
| 68 virtual ~BackgroundTracingManager() {} |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
OLD | NEW |