Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: sql/connection.cc

Issue 2626823008: [sql] Move time-machine support from third_party/sqlite to sql/ (Closed)
Patch Set: ps output Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/BUILD.gn ('k') | sql/sqlite_features_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index d220c8e8d78906aad8f9064bd752ea811ec43cf6..a4fa48f534c3af60ac527b830f51b2347949027b 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -33,6 +33,7 @@
#include "sql/connection_memory_dump_provider.h"
#include "sql/meta_table.h"
#include "sql/statement.h"
+#include "sql/vfs_wrapper.h"
#include "third_party/sqlite/sqlite3.h"
#if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE)
@@ -40,8 +41,24 @@
#include "third_party/sqlite/src/ext/icu/sqliteicu.h"
#endif
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreServices/CoreServices.h>
+#endif
+
namespace {
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+void gross() {
+ CFPreferencesSetAppValue(CFSTR("CSBackupDebugLogging"),
+ kCFBooleanTrue,
+ kCFPreferencesCurrentApplication);
+}
+#else
+void gross() {
+}
+#endif
+
// Spin for up to a second waiting for the lock to clear when setting
// up the database.
// TODO(shess): Better story on this. http://crbug.com/56559
@@ -159,6 +176,7 @@ void InitializeSqlite() {
base::AutoLock lock(g_sqlite_init_lock.Get());
static bool first_call = true;
if (first_call) {
+ gross();
sqlite3_initialize();
// Schedule callback to record memory footprint histograms at 10m, 1h, and
@@ -1690,7 +1708,12 @@ bool Connection::OpenInternal(const std::string& file_name,
DLOG_IF(FATAL, poisoned_) << "sql::Connection is already open.";
poisoned_ = false;
- int err = sqlite3_open(file_name.c_str(), &db_);
+ // Custom memory-mapping VFS which reads pages using regular I/O on first hit.
+ sqlite3_vfs* vfs = VFSWrapper();
+ const char* vfs_name = (vfs ? vfs->zName : NULL);
+ int err = sqlite3_open_v2(file_name.c_str(), &db_,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
+ vfs_name);
if (err != SQLITE_OK) {
// Extended error codes cannot be enabled until a handle is
// available, fetch manually.
« no previous file with comments | « sql/BUILD.gn ('k') | sql/sqlite_features_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698