memory_dump_provider.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
  5. #define BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_
  6. #include "base/base_export.h"
  7. #include "base/macros.h"
  8. #include "base/process/process_handle.h"
  9. #include "base/trace_event/memory_dump_request_args.h"
  10. namespace base {
  11. namespace trace_event {
  12. class ProcessMemoryDump;
  13. // The contract interface that memory dump providers must implement.
  14. class BASE_EXPORT MemoryDumpProvider {
  15. public:
  16. // Optional arguments for MemoryDumpManager::RegisterDumpProvider().
  17. struct Options {
  18. Options() : dumps_on_single_thread_task_runner(false) {}
  19. // |dumps_on_single_thread_task_runner| is true if the dump provider runs on
  20. // a SingleThreadTaskRunner, which is usually the case. It is faster to run
  21. // all providers that run on the same thread together without thread hops.
  22. bool dumps_on_single_thread_task_runner;
  23. };
  24. virtual ~MemoryDumpProvider() = default;
  25. // Called by the MemoryDumpManager when generating memory dumps.
  26. // The |args| specify if the embedder should generate light/heavy dumps on
  27. // dump requests. The embedder should return true if the |pmd| was
  28. // successfully populated, false if something went wrong and the dump should
  29. // be considered invalid.
  30. // (Note, the MemoryDumpManager has a fail-safe logic which will disable the
  31. // MemoryDumpProvider for the entire trace session if it fails consistently).
  32. virtual bool OnMemoryDump(const MemoryDumpArgs& args,
  33. ProcessMemoryDump* pmd) = 0;
  34. protected:
  35. MemoryDumpProvider() = default;
  36. DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider);
  37. };
  38. } // namespace trace_event
  39. } // namespace base
  40. #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_