OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H | 5 #ifndef SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H |
6 #define SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H | 6 #define SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/trace_event/memory_allocator_dump.h" |
12 #include "base/trace_event/memory_dump_provider.h" | 13 #include "base/trace_event/memory_dump_provider.h" |
13 | 14 |
14 struct sqlite3; | 15 struct sqlite3; |
15 | 16 |
16 namespace sql { | 17 namespace sql { |
17 | 18 |
18 class ConnectionMemoryDumpProvider | 19 class ConnectionMemoryDumpProvider |
19 : public base::trace_event::MemoryDumpProvider { | 20 : public base::trace_event::MemoryDumpProvider { |
20 public: | 21 public: |
21 ConnectionMemoryDumpProvider(sqlite3* db, const std::string& name); | 22 ConnectionMemoryDumpProvider(sqlite3* db, const std::string& name); |
22 ~ConnectionMemoryDumpProvider() override; | 23 ~ConnectionMemoryDumpProvider() override; |
23 | 24 |
24 void ResetDatabase(); | 25 void ResetDatabase(); |
25 | 26 |
26 // base::trace_event::MemoryDumpProvider implementation. | 27 // base::trace_event::MemoryDumpProvider implementation. |
27 bool OnMemoryDump( | 28 bool OnMemoryDump( |
28 const base::trace_event::MemoryDumpArgs& args, | 29 const base::trace_event::MemoryDumpArgs& args, |
29 base::trace_event::ProcessMemoryDump* process_memory_dump) override; | 30 base::trace_event::ProcessMemoryDump* process_memory_dump) override; |
30 | 31 |
| 32 // Called by sql::Connection when its owner asks to dump memory usage. |
| 33 bool ReportMemoryUsage(base::trace_event::MemoryAllocatorDump* mad); |
| 34 |
31 private: | 35 private: |
| 36 bool GetDbMemoryUsage(int* cache_size, |
| 37 int* schema_size, |
| 38 int* statement_size); |
| 39 |
| 40 std::string FormatDumpName() const; |
| 41 |
32 sqlite3* db_; // not owned. | 42 sqlite3* db_; // not owned. |
33 base::Lock lock_; | 43 base::Lock lock_; |
34 std::string connection_name_; | 44 std::string connection_name_; |
35 | 45 |
36 DISALLOW_COPY_AND_ASSIGN(ConnectionMemoryDumpProvider); | 46 DISALLOW_COPY_AND_ASSIGN(ConnectionMemoryDumpProvider); |
37 }; | 47 }; |
38 | 48 |
39 } // namespace sql | 49 } // namespace sql |
40 | 50 |
41 #endif // SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H | 51 #endif // SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H |
OLD | NEW |