memory_dump_provider.h 1.9 KB

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