diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-04-05 14:08:31 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-04-11 07:46:53 +0000 |
commit | 6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (patch) | |
tree | ab00f70a5e89278d6a0d16ff0c42578dc4d84a2d /chromium/sql | |
parent | e733310db58160074f574c429d48f8308c0afe17 (diff) | |
download | qtwebengine-chromium-6a4cabb866f66d4128a97cdc6d9d08ce074f1247.tar.gz |
BASELINE: Update Chromium to 57.0.2987.144
Change-Id: I29db402ff696c71a04c4dbaec822c2e53efe0267
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/sql')
-rw-r--r-- | chromium/sql/connection.cc | 6 | ||||
-rw-r--r-- | chromium/sql/connection.h | 7 | ||||
-rw-r--r-- | chromium/sql/connection_memory_dump_provider.cc | 78 | ||||
-rw-r--r-- | chromium/sql/connection_memory_dump_provider.h | 17 |
4 files changed, 84 insertions, 24 deletions
diff --git a/chromium/sql/connection.cc b/chromium/sql/connection.cc index 788329bafd3..d220c8e8d78 100644 --- a/chromium/sql/connection.cc +++ b/chromium/sql/connection.cc @@ -2044,6 +2044,12 @@ bool Connection::IntegrityCheckHelper( return ret; } +bool Connection::ReportMemoryUsage(base::trace_event::ProcessMemoryDump* pmd, + const std::string& dump_name) { + return memory_dump_provider_ && + memory_dump_provider_->ReportMemoryUsage(pmd, dump_name); +} + base::TimeTicks TimeSource::Now() { return base::TimeTicks::Now(); } diff --git a/chromium/sql/connection.h b/chromium/sql/connection.h index 0fb251dd8cc..639c333ed4d 100644 --- a/chromium/sql/connection.h +++ b/chromium/sql/connection.h @@ -28,6 +28,9 @@ struct sqlite3_stmt; namespace base { class FilePath; class HistogramBase; +namespace trace_event { +class ProcessMemoryDump; +} } namespace sql { @@ -251,6 +254,10 @@ class SQL_EXPORT Connection { // get diagnostic information about the database. std::string GetDiagnosticInfo(int extended_error, Statement* statement); + // Reports memory usage into provided memory dump with the given name. + bool ReportMemoryUsage(base::trace_event::ProcessMemoryDump* pmd, + const std::string& dump_name); + // Initialization ------------------------------------------------------------ // Initializes the SQL connection for the given file, returning true if the diff --git a/chromium/sql/connection_memory_dump_provider.cc b/chromium/sql/connection_memory_dump_provider.cc index eaee9b43e3b..5eecf71cb64 100644 --- a/chromium/sql/connection_memory_dump_provider.cc +++ b/chromium/sql/connection_memory_dump_provider.cc @@ -33,32 +33,12 @@ bool ConnectionMemoryDumpProvider::OnMemoryDump( int cache_size = 0; int schema_size = 0; int statement_size = 0; - { - // Lock is acquired here so that db_ is not reset in ResetDatabase when - // collecting stats. - base::AutoLock lock(lock_); - if (!db_) { - return false; - } - - // The high water mark is not tracked for the following usages. - int dummy_int; - int status = sqlite3_db_status(db_, SQLITE_DBSTATUS_CACHE_USED, &cache_size, - &dummy_int, 0 /* resetFlag */); - DCHECK_EQ(SQLITE_OK, status); - status = sqlite3_db_status(db_, SQLITE_DBSTATUS_SCHEMA_USED, &schema_size, - &dummy_int, 0 /* resetFlag */); - DCHECK_EQ(SQLITE_OK, status); - status = sqlite3_db_status(db_, SQLITE_DBSTATUS_STMT_USED, &statement_size, - &dummy_int, 0 /* resetFlag */); - DCHECK_EQ(SQLITE_OK, status); + if (!GetDbMemoryUsage(&cache_size, &schema_size, &statement_size)) { + return false; } - std::string name = base::StringPrintf( - "sqlite/%s_connection/0x%" PRIXPTR, - connection_name_.empty() ? "Unknown" : connection_name_.c_str(), - reinterpret_cast<uintptr_t>(this)); - base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); + base::trace_event::MemoryAllocatorDump* dump = + pmd->CreateAllocatorDump(FormatDumpName()); dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, base::trace_event::MemoryAllocatorDump::kUnitsBytes, cache_size + schema_size + statement_size); @@ -74,4 +54,54 @@ bool ConnectionMemoryDumpProvider::OnMemoryDump( return true; } +bool ConnectionMemoryDumpProvider::ReportMemoryUsage( + base::trace_event::ProcessMemoryDump* pmd, + const std::string& dump_name) { + int cache_size = 0; + int schema_size = 0; + int statement_size = 0; + if (!GetDbMemoryUsage(&cache_size, &schema_size, &statement_size)) + return false; + + auto* mad = pmd->CreateAllocatorDump(dump_name); + mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, + base::trace_event::MemoryAllocatorDump::kUnitsBytes, + cache_size + schema_size + statement_size); + pmd->AddSuballocation(mad->guid(), FormatDumpName()); + + return true; +} + +bool ConnectionMemoryDumpProvider::GetDbMemoryUsage(int* cache_size, + int* schema_size, + int* statement_size) { + // Lock is acquired here so that db_ is not reset in ResetDatabase when + // collecting stats. + base::AutoLock lock(lock_); + if (!db_) { + return false; + } + + // The high water mark is not tracked for the following usages. + int dummy_int; + int status = sqlite3_db_status(db_, SQLITE_DBSTATUS_CACHE_USED, cache_size, + &dummy_int, 0 /* resetFlag */); + DCHECK_EQ(SQLITE_OK, status); + status = sqlite3_db_status(db_, SQLITE_DBSTATUS_SCHEMA_USED, schema_size, + &dummy_int, 0 /* resetFlag */); + DCHECK_EQ(SQLITE_OK, status); + status = sqlite3_db_status(db_, SQLITE_DBSTATUS_STMT_USED, statement_size, + &dummy_int, 0 /* resetFlag */); + DCHECK_EQ(SQLITE_OK, status); + + return true; +} + +std::string ConnectionMemoryDumpProvider::FormatDumpName() const { + return base::StringPrintf( + "sqlite/%s_connection/0x%" PRIXPTR, + connection_name_.empty() ? "Unknown" : connection_name_.c_str(), + reinterpret_cast<uintptr_t>(this)); +} + } // namespace sql diff --git a/chromium/sql/connection_memory_dump_provider.h b/chromium/sql/connection_memory_dump_provider.h index bcad0f8ca5a..73b2bd82d23 100644 --- a/chromium/sql/connection_memory_dump_provider.h +++ b/chromium/sql/connection_memory_dump_provider.h @@ -13,6 +13,12 @@ struct sqlite3; +namespace base { +namespace trace_event { +class ProcessMemoryDump; +} +} + namespace sql { class ConnectionMemoryDumpProvider @@ -28,7 +34,18 @@ class ConnectionMemoryDumpProvider const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* process_memory_dump) override; + // Reports memory usage into provided memory dump with the given |dump_name|. + // Called by sql::Connection when its owner asks it to report memory usage. + bool ReportMemoryUsage(base::trace_event::ProcessMemoryDump* pmd, + const std::string& dump_name); + private: + bool GetDbMemoryUsage(int* cache_size, + int* schema_size, + int* statement_size); + + std::string FormatDumpName() const; + sqlite3* db_; // not owned. base::Lock lock_; std::string connection_name_; |