 Chromium Code Reviews
 Chromium Code Reviews Issue 2623083002:
  [sql] Move time-machine support from third_party/sqlite to sql/  (Closed)
    
  
    Issue 2623083002:
  [sql] Move time-machine support from third_party/sqlite to sql/  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "sql/connection.h" | 
| 6 | 6 | 
| 7 #include <limits.h> | 7 #include <limits.h> | 
| 8 #include <stddef.h> | 8 #include <stddef.h> | 
| 9 #include <stdint.h> | 9 #include <stdint.h> | 
| 10 #include <string.h> | 10 #include <string.h> | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" | 
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" | 
| 28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" | 
| 29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" | 
| 30 #include "base/synchronization/lock.h" | 30 #include "base/synchronization/lock.h" | 
| 31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" | 
| 32 #include "base/trace_event/memory_dump_manager.h" | 32 #include "base/trace_event/memory_dump_manager.h" | 
| 33 #include "sql/connection_memory_dump_provider.h" | 33 #include "sql/connection_memory_dump_provider.h" | 
| 34 #include "sql/meta_table.h" | 34 #include "sql/meta_table.h" | 
| 35 #include "sql/statement.h" | 35 #include "sql/statement.h" | 
| 36 #include "sql/vfs_wrapper.h" | |
| 36 #include "third_party/sqlite/sqlite3.h" | 37 #include "third_party/sqlite/sqlite3.h" | 
| 37 | 38 | 
| 38 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) | 39 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) | 
| 39 #include "base/ios/ios_util.h" | 40 #include "base/ios/ios_util.h" | 
| 40 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 41 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 
| 41 #endif | 42 #endif | 
| 42 | 43 | 
| 43 namespace { | 44 namespace { | 
| 44 | 45 | 
| 45 // Spin for up to a second waiting for the lock to clear when setting | 46 // Spin for up to a second waiting for the lock to clear when setting | 
| (...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1683 | 1684 | 
| 1684 // If |poisoned_| is set, it means an error handler called | 1685 // If |poisoned_| is set, it means an error handler called | 
| 1685 // RazeAndClose(). Until regular Close() is called, the caller | 1686 // RazeAndClose(). Until regular Close() is called, the caller | 
| 1686 // should be treating the database as open, but is_open() currently | 1687 // should be treating the database as open, but is_open() currently | 
| 1687 // only considers the sqlite3 handle's state. | 1688 // only considers the sqlite3 handle's state. | 
| 1688 // TODO(shess): Revise is_open() to consider poisoned_, and review | 1689 // TODO(shess): Revise is_open() to consider poisoned_, and review | 
| 1689 // to see if any non-testing code even depends on it. | 1690 // to see if any non-testing code even depends on it. | 
| 1690 DLOG_IF(FATAL, poisoned_) << "sql::Connection is already open."; | 1691 DLOG_IF(FATAL, poisoned_) << "sql::Connection is already open."; | 
| 1691 poisoned_ = false; | 1692 poisoned_ = false; | 
| 1692 | 1693 | 
| 1693 int err = sqlite3_open(file_name.c_str(), &db_); | 1694 // Custom memory-mapping VFS which reads pages using regular I/O on first hit. | 
| 1695 sqlite3_vfs* vfs = VFSWrapper(); | |
| 1696 const char* vfs_name = (vfs ? vfs->zName : NULL); | |
| 
Marijn Kruisselbrink
2017/01/23 23:32:46
nit: this should probably also be nullptr (sorry,
 
Scott Hess - ex-Googler
2017/01/23 23:47:06
Sorry should be at my end - when you mentioned it
 | |
| 1697 int err = sqlite3_open_v2(file_name.c_str(), &db_, | |
| 1698 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, | |
| 1699 vfs_name); | |
| 1694 if (err != SQLITE_OK) { | 1700 if (err != SQLITE_OK) { | 
| 1695 // Extended error codes cannot be enabled until a handle is | 1701 // Extended error codes cannot be enabled until a handle is | 
| 1696 // available, fetch manually. | 1702 // available, fetch manually. | 
| 1697 err = sqlite3_extended_errcode(db_); | 1703 err = sqlite3_extended_errcode(db_); | 
| 1698 | 1704 | 
| 1699 // Histogram failures specific to initial open for debugging | 1705 // Histogram failures specific to initial open for debugging | 
| 1700 // purposes. | 1706 // purposes. | 
| 1701 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenFailure", err); | 1707 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenFailure", err); | 
| 1702 | 1708 | 
| 1703 OnSqliteError(err, NULL, "-- sqlite3_open()"); | 1709 OnSqliteError(err, NULL, "-- sqlite3_open()"); | 
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2048 const std::string& dump_name) { | 2054 const std::string& dump_name) { | 
| 2049 return memory_dump_provider_ && | 2055 return memory_dump_provider_ && | 
| 2050 memory_dump_provider_->ReportMemoryUsage(pmd, dump_name); | 2056 memory_dump_provider_->ReportMemoryUsage(pmd, dump_name); | 
| 2051 } | 2057 } | 
| 2052 | 2058 | 
| 2053 base::TimeTicks TimeSource::Now() { | 2059 base::TimeTicks TimeSource::Now() { | 
| 2054 return base::TimeTicks::Now(); | 2060 return base::TimeTicks::Now(); | 
| 2055 } | 2061 } | 
| 2056 | 2062 | 
| 2057 } // namespace sql | 2063 } // namespace sql | 
| OLD | NEW |