xref: /aosp_15_r20/external/cronet/base/android/meminfo_dump_provider.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2023 The Chromium Authors
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_ANDROID_MEMINFO_DUMP_PROVIDER_H_
6 #define BASE_ANDROID_MEMINFO_DUMP_PROVIDER_H_
7 
8 #include "base/base_export.h"
9 #include "base/no_destructor.h"
10 #include "base/time/time.h"
11 #include "base/trace_event/base_tracing.h"
12 
13 namespace base::android {
14 
15 class BASE_EXPORT MeminfoDumpProvider
16     : public base::trace_event::MemoryDumpProvider {
17  public:
18   // Returns the instance for testing.
19   static MeminfoDumpProvider& Initialize();
20   bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
21                     base::trace_event::ProcessMemoryDump* pmd) override;
22 
23   static constexpr char kDumpProviderName[] = "android_meminfo";
24   static constexpr char kDumpName[] = "meminfo";
25   static constexpr char kIsStaleName[] = "is_stale";
26   static constexpr char kPssMetricName[] = "other_pss";
27   static constexpr char kPrivateDirtyMetricName[] = "other_private_dirty";
28 
29  private:
30   friend class base::NoDestructor<MeminfoDumpProvider>;
31   MeminfoDumpProvider();
32 
33   base::TimeTicks last_collection_time_;
34 };
35 
36 }  // namespace base::android
37 
38 #endif  // BASE_ANDROID_MEMINFO_DUMP_PROVIDER_H_
39