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