tracing_manager.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2014 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. #ifndef COMPONENTS_FEEDBACK_TRACING_MANAGER_H_
  5. #define COMPONENTS_FEEDBACK_TRACING_MANAGER_H_
  6. #include "base/callback.h"
  7. #include "base/memory/scoped_refptr.h"
  8. namespace base {
  9. class RefCountedString;
  10. } // namespace base
  11. // Callback used for getting the output of a trace.
  12. using TraceDataCallback =
  13. base::OnceCallback<void(scoped_refptr<base::RefCountedString> trace_data)>;
  14. // This class is used to manage performance metrics that can be attached to
  15. // feedback reports. This class is a pure interface.
  16. //
  17. // When a performance trace is desired, TracingManager::RequestTrace() should
  18. // be invoked. The TracingManager will then start preparing a zipped version
  19. // of the performance data. That data can then be requested via GetTraceData().
  20. // When the data is no longer needed, it should be discarded via
  21. // DiscardTraceData().
  22. class TracingManager {
  23. public:
  24. virtual ~TracingManager();
  25. TracingManager(const TracingManager&) = delete;
  26. TracingManager& operator=(const TracingManager&) = delete;
  27. // Request a trace ending at the current time. If a trace is already being
  28. // collected, the id for that trace is returned.
  29. virtual int RequestTrace() = 0;
  30. // Get the trace data for |id|. On success, true is returned, and the data is
  31. // returned via |callback|. Returns false on failure.
  32. virtual bool GetTraceData(int id, TraceDataCallback callback) = 0;
  33. // Discard the data for trace |id|.
  34. virtual void DiscardTraceData(int id) = 0;
  35. protected:
  36. TracingManager();
  37. };
  38. #endif // COMPONENTS_FEEDBACK_TRACING_MANAGER_H_