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" | |
13 #include "base/trace_event/memory_dump_provider.h" | 12 #include "base/trace_event/memory_dump_provider.h" |
14 | 13 |
15 struct sqlite3; | 14 struct sqlite3; |
16 | 15 |
| 16 namespace base { |
| 17 namespace trace_event { |
| 18 class ProcessMemoryDump; |
| 19 } |
| 20 } |
| 21 |
17 namespace sql { | 22 namespace sql { |
18 | 23 |
19 class ConnectionMemoryDumpProvider | 24 class ConnectionMemoryDumpProvider |
20 : public base::trace_event::MemoryDumpProvider { | 25 : public base::trace_event::MemoryDumpProvider { |
21 public: | 26 public: |
22 ConnectionMemoryDumpProvider(sqlite3* db, const std::string& name); | 27 ConnectionMemoryDumpProvider(sqlite3* db, const std::string& name); |
23 ~ConnectionMemoryDumpProvider() override; | 28 ~ConnectionMemoryDumpProvider() override; |
24 | 29 |
25 void ResetDatabase(); | 30 void ResetDatabase(); |
26 | 31 |
27 // base::trace_event::MemoryDumpProvider implementation. | 32 // base::trace_event::MemoryDumpProvider implementation. |
28 bool OnMemoryDump( | 33 bool OnMemoryDump( |
29 const base::trace_event::MemoryDumpArgs& args, | 34 const base::trace_event::MemoryDumpArgs& args, |
30 base::trace_event::ProcessMemoryDump* process_memory_dump) override; | 35 base::trace_event::ProcessMemoryDump* process_memory_dump) override; |
31 | 36 |
32 // Reports memory usage into provided memory dump. | 37 // Reports memory usage into provided memory dump with the given |dump_name|. |
33 // Called by sql::Connection when its owner asks it to report memory usage. | 38 // Called by sql::Connection when its owner asks it to report memory usage. |
34 bool ReportMemoryUsage(base::trace_event::MemoryAllocatorDump* mad); | 39 bool ReportMemoryUsage(base::trace_event::ProcessMemoryDump* pmd, |
| 40 const std::string& dump_name); |
35 | 41 |
36 private: | 42 private: |
37 bool GetDbMemoryUsage(int* cache_size, | 43 bool GetDbMemoryUsage(int* cache_size, |
38 int* schema_size, | 44 int* schema_size, |
39 int* statement_size); | 45 int* statement_size); |
40 | 46 |
41 std::string FormatDumpName() const; | 47 std::string FormatDumpName() const; |
42 | 48 |
43 sqlite3* db_; // not owned. | 49 sqlite3* db_; // not owned. |
44 base::Lock lock_; | 50 base::Lock lock_; |
45 std::string connection_name_; | 51 std::string connection_name_; |
46 | 52 |
47 DISALLOW_COPY_AND_ASSIGN(ConnectionMemoryDumpProvider); | 53 DISALLOW_COPY_AND_ASSIGN(ConnectionMemoryDumpProvider); |
48 }; | 54 }; |
49 | 55 |
50 } // namespace sql | 56 } // namespace sql |
51 | 57 |
52 #endif // SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H | 58 #endif // SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H |
OLD | NEW |