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.
5 #ifndef SQL_DATABASE_MEMORY_DUMP_PROVIDER_H_
6 #define SQL_DATABASE_MEMORY_DUMP_PROVIDER_H_
10 #include "base/macros.h"
11 #include "base/synchronization/lock.h"
12 #include "base/trace_event/memory_dump_provider.h"
17 namespace trace_event {
18 class ProcessMemoryDump;
24 class DatabaseMemoryDumpProvider
25 : public base::trace_event::MemoryDumpProvider {
27 DatabaseMemoryDumpProvider(sqlite3* db, const std::string& name);
28 ~DatabaseMemoryDumpProvider() override;
32 // base::trace_event::MemoryDumpProvider implementation.
34 const base::trace_event::MemoryDumpArgs& args,
35 base::trace_event::ProcessMemoryDump* process_memory_dump) override;
37 // Reports memory usage into provided memory dump with the given |dump_name|.
38 // Called by sql::Database when its owner asks it to report memory usage.
39 bool ReportMemoryUsage(base::trace_event::ProcessMemoryDump* pmd,
40 const std::string& dump_name);
43 bool GetDbMemoryUsage(int* cache_size, int* schema_size, int* statement_size);
45 std::string FormatDumpName() const;
47 sqlite3* db_; // not owned.
49 std::string connection_name_;
51 DISALLOW_COPY_AND_ASSIGN(DatabaseMemoryDumpProvider);
56 #endif // SQL_DATABASE_MEMORY_DUMP_PROVIDER_H_