skia_trace_memory_dump_impl.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 SKIA_EXT_SKIA_TRACE_MEMORY_DUMP_IMPL_H_
  5. #define SKIA_EXT_SKIA_TRACE_MEMORY_DUMP_IMPL_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include "base/memory/raw_ptr.h"
  9. #include "base/trace_event/memory_dump_request_args.h"
  10. #include "third_party/skia/include/core/SkTraceMemoryDump.h"
  11. namespace base {
  12. namespace trace_event {
  13. class ProcessMemoryDump;
  14. }
  15. }
  16. namespace skia {
  17. class SK_API SkiaTraceMemoryDumpImpl : public SkTraceMemoryDump {
  18. public:
  19. // This should never outlive the OnMemoryDump call since the
  20. // ProcessMemoryDump is valid only in that timeframe. Optional
  21. // |dump_name_prefix| argument specifies the prefix appended to the dump
  22. // name skia provides. By default it is taken as empty string.
  23. SkiaTraceMemoryDumpImpl(
  24. base::trace_event::MemoryDumpLevelOfDetail level_of_detail,
  25. base::trace_event::ProcessMemoryDump* process_memory_dump);
  26. SkiaTraceMemoryDumpImpl(
  27. const std::string& dump_name_prefix,
  28. base::trace_event::MemoryDumpLevelOfDetail level_of_detail,
  29. base::trace_event::ProcessMemoryDump* process_memory_dump);
  30. SkiaTraceMemoryDumpImpl(const SkiaTraceMemoryDumpImpl&) = delete;
  31. SkiaTraceMemoryDumpImpl& operator=(const SkiaTraceMemoryDumpImpl&) = delete;
  32. ~SkiaTraceMemoryDumpImpl() override;
  33. // SkTraceMemoryDump implementation:
  34. void dumpNumericValue(const char* dumpName,
  35. const char* valueName,
  36. const char* units,
  37. uint64_t value) override;
  38. void dumpStringValue(const char* dump_name,
  39. const char* value_name,
  40. const char* value) override;
  41. void setMemoryBacking(const char* dumpName,
  42. const char* backingType,
  43. const char* backingObjectId) override;
  44. void setDiscardableMemoryBacking(
  45. const char* dumpName,
  46. const SkDiscardableMemory& discardableMemoryObject) override;
  47. LevelOfDetail getRequestedDetails() const override;
  48. bool shouldDumpWrappedObjects() const override;
  49. protected:
  50. base::trace_event::ProcessMemoryDump* process_memory_dump() {
  51. return process_memory_dump_;
  52. }
  53. private:
  54. std::string dump_name_prefix_;
  55. raw_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump_;
  56. // Stores the level of detail for the current dump.
  57. LevelOfDetail request_level_;
  58. };
  59. } // namespace skia
  60. #endif // SKIA_EXT_SKIA_TRACE_MEMORY_DUMP_IMPL_H_