summaryrefslogtreecommitdiffstats
path: root/sql/connection_memory_dump_provider.h
diff options
context:
space:
mode:
authorssid <ssid@chromium.org>2016-01-13 06:21:57 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-13 14:23:13 +0000
commit3be5b1ecdf66f6eaaa0ba98f9b36cc2d93bf54d9 (patch)
tree20326a0c236d72a2e28b007f1782116cf301b07c /sql/connection_memory_dump_provider.h
parent3a6f49f649c3c413ca10fc60ec85f39532ac9e45 (diff)
downloadchromium_src-3be5b1ecdf66f6eaaa0ba98f9b36cc2d93bf54d9.zip
chromium_src-3be5b1ecdf66f6eaaa0ba98f9b36cc2d93bf54d9.tar.gz
chromium_src-3be5b1ecdf66f6eaaa0ba98f9b36cc2d93bf54d9.tar.bz2
[tracing] Add separate dump provider for sql connection
The sql connection memory dump is not thread safe since the connections can get deleted while a dump is happening. To make this thread safe, this CL introduces a dump provider class owned by the connection. This class holds a lock when dumping and deleting the database. Also, to workaround thread safe dump provider registration, it uses the UnregisterAndDeleteDumpProviderAsync api added in crrev.com/1430073002. BUG=466141 Review URL: https://codereview.chromium.org/1434993002 Cr-Commit-Position: refs/heads/master@{#369161}
Diffstat (limited to 'sql/connection_memory_dump_provider.h')
-rw-r--r--sql/connection_memory_dump_provider.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/sql/connection_memory_dump_provider.h b/sql/connection_memory_dump_provider.h
new file mode 100644
index 0000000..bcad0f8
--- /dev/null
+++ b/sql/connection_memory_dump_provider.h
@@ -0,0 +1,41 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H
+#define SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+#include "base/trace_event/memory_dump_provider.h"
+
+struct sqlite3;
+
+namespace sql {
+
+class ConnectionMemoryDumpProvider
+ : public base::trace_event::MemoryDumpProvider {
+ public:
+ ConnectionMemoryDumpProvider(sqlite3* db, const std::string& name);
+ ~ConnectionMemoryDumpProvider() override;
+
+ void ResetDatabase();
+
+ // base::trace_event::MemoryDumpProvider implementation.
+ bool OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* process_memory_dump) override;
+
+ private:
+ sqlite3* db_; // not owned.
+ base::Lock lock_;
+ std::string connection_name_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectionMemoryDumpProvider);
+};
+
+} // namespace sql
+
+#endif // SQL_CONNECTION_MEMORY_DUMP_PROVIDER_H