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 #include "sql/connection_memory_dump_provider.h" | 5 #include "sql/connection_memory_dump_provider.h" |
6 | 6 |
| 7 #include <inttypes.h> |
| 8 |
7 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
8 #include "base/trace_event/process_memory_dump.h" | 10 #include "base/trace_event/process_memory_dump.h" |
9 #include "third_party/sqlite/sqlite3.h" | 11 #include "third_party/sqlite/sqlite3.h" |
10 | 12 |
11 namespace sql { | 13 namespace sql { |
12 | 14 |
13 ConnectionMemoryDumpProvider::ConnectionMemoryDumpProvider( | 15 ConnectionMemoryDumpProvider::ConnectionMemoryDumpProvider( |
14 sqlite3* db, | 16 sqlite3* db, |
15 const std::string& name) | 17 const std::string& name) |
16 : db_(db), connection_name_(name) {} | 18 : db_(db), connection_name_(name) {} |
(...skipping 29 matching lines...) Expand all Loading... |
46 DCHECK_EQ(SQLITE_OK, status); | 48 DCHECK_EQ(SQLITE_OK, status); |
47 status = sqlite3_db_status(db_, SQLITE_DBSTATUS_SCHEMA_USED, &schema_size, | 49 status = sqlite3_db_status(db_, SQLITE_DBSTATUS_SCHEMA_USED, &schema_size, |
48 &dummy_int, 0 /* resetFlag */); | 50 &dummy_int, 0 /* resetFlag */); |
49 DCHECK_EQ(SQLITE_OK, status); | 51 DCHECK_EQ(SQLITE_OK, status); |
50 status = sqlite3_db_status(db_, SQLITE_DBSTATUS_STMT_USED, &statement_size, | 52 status = sqlite3_db_status(db_, SQLITE_DBSTATUS_STMT_USED, &statement_size, |
51 &dummy_int, 0 /* resetFlag */); | 53 &dummy_int, 0 /* resetFlag */); |
52 DCHECK_EQ(SQLITE_OK, status); | 54 DCHECK_EQ(SQLITE_OK, status); |
53 } | 55 } |
54 | 56 |
55 std::string name = base::StringPrintf( | 57 std::string name = base::StringPrintf( |
56 "sqlite/%s_connection/%p", | 58 "sqlite/%s_connection/0x%" PRIXPTR, |
57 connection_name_.empty() ? "Unknown" : connection_name_.c_str(), this); | 59 connection_name_.empty() ? "Unknown" : connection_name_.c_str(), |
| 60 reinterpret_cast<uintptr_t>(this)); |
58 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); | 61 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); |
59 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 62 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
60 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 63 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
61 cache_size + schema_size + statement_size); | 64 cache_size + schema_size + statement_size); |
62 dump->AddScalar("cache_size", | 65 dump->AddScalar("cache_size", |
63 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 66 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
64 cache_size); | 67 cache_size); |
65 dump->AddScalar("schema_size", | 68 dump->AddScalar("schema_size", |
66 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 69 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
67 schema_size); | 70 schema_size); |
68 dump->AddScalar("statement_size", | 71 dump->AddScalar("statement_size", |
69 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 72 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
70 statement_size); | 73 statement_size); |
71 return true; | 74 return true; |
72 } | 75 } |
73 | 76 |
74 } // namespace sql | 77 } // namespace sql |
OLD | NEW |