OLD | NEW |
(Empty) | |
| 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 COMPONENTS_TRACING_GRAPHICS_MEMORY_DUMP_PROVIDER_ANDROID_H_ |
| 6 #define COMPONENTS_TRACING_GRAPHICS_MEMORY_DUMP_PROVIDER_ANDROID_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/memory/singleton.h" |
| 12 #include "base/trace_event/memory_dump_provider.h" |
| 13 #include "components/tracing/tracing_export.h" |
| 14 |
| 15 namespace tracing { |
| 16 |
| 17 // Dump provider which collects memory stats about graphics memory on Android. |
| 18 // This requires the presence of the memtrack_helper daemon, which must be |
| 19 // executed separetely via a (root) adb shell command. The dump provider will |
| 20 // fail (and hence disabled by the MemoryDumpManager) in absence of the helper. |
| 21 // See the design-doc https://goo.gl/4Y30p9 for more details. |
| 22 class TRACING_EXPORT GraphicsMemoryDumpProvider |
| 23 : public base::trace_event::MemoryDumpProvider { |
| 24 public: |
| 25 static GraphicsMemoryDumpProvider* GetInstance(); |
| 26 |
| 27 // MemoryDumpProvider implementation. |
| 28 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 29 base::trace_event::ProcessMemoryDump* pmd) override; |
| 30 |
| 31 private: |
| 32 friend struct base::DefaultSingletonTraits<GraphicsMemoryDumpProvider>; |
| 33 |
| 34 void ParseResponseAndAddToDump(const char* buf, |
| 35 size_t length, |
| 36 base::trace_event::ProcessMemoryDump* pmd); |
| 37 |
| 38 GraphicsMemoryDumpProvider(); |
| 39 ~GraphicsMemoryDumpProvider() override; |
| 40 |
| 41 static const char kDumpBaseName[]; // Used by the unittest. |
| 42 |
| 43 // Stores key names coming from the memtrack helper in long-lived storage. |
| 44 // This is to allow using cheap char* strings in tracing without copies. |
| 45 base::hash_set<std::string> key_names_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(GraphicsMemoryDumpProvider); |
| 48 }; |
| 49 |
| 50 } // namespace tracing |
| 51 |
| 52 #endif // COMPONENTS_TRACING_GRAPHICS_MEMORY_DUMP_PROVIDER_ANDROID_H_ |
OLD | NEW |