| 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 26 matching lines...) Expand all  Loading... | 
| 37 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 37 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 
| 38 #endif | 38 #endif | 
| 39 | 39 | 
| 40 namespace { | 40 namespace { | 
| 41 | 41 | 
| 42 // Spin for up to a second waiting for the lock to clear when setting | 42 // Spin for up to a second waiting for the lock to clear when setting | 
| 43 // up the database. | 43 // up the database. | 
| 44 // TODO(shess): Better story on this.  http://crbug.com/56559 | 44 // TODO(shess): Better story on this.  http://crbug.com/56559 | 
| 45 const int kBusyTimeoutSeconds = 1; | 45 const int kBusyTimeoutSeconds = 1; | 
| 46 | 46 | 
| 47 bool g_mmap_disabled_default = false; |  | 
| 48 |  | 
| 49 class ScopedBusyTimeout { | 47 class ScopedBusyTimeout { | 
| 50  public: | 48  public: | 
| 51   explicit ScopedBusyTimeout(sqlite3* db) | 49   explicit ScopedBusyTimeout(sqlite3* db) | 
| 52       : db_(db) { | 50       : db_(db) { | 
| 53   } | 51   } | 
| 54   ~ScopedBusyTimeout() { | 52   ~ScopedBusyTimeout() { | 
| 55     sqlite3_busy_timeout(db_, 0); | 53     sqlite3_busy_timeout(db_, 0); | 
| 56   } | 54   } | 
| 57 | 55 | 
| 58   int SetTimeout(base::TimeDelta timeout) { | 56   int SetTimeout(base::TimeDelta timeout) { | 
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 249   int basic_error = error & 0xff; | 247   int basic_error = error & 0xff; | 
| 250 | 248 | 
| 251   // These errors relate more to the runtime context of the system than to | 249   // These errors relate more to the runtime context of the system than to | 
| 252   // errors with a SQL statement or with the schema, so they aren't generally | 250   // errors with a SQL statement or with the schema, so they aren't generally | 
| 253   // interesting to flag.  This list is not comprehensive. | 251   // interesting to flag.  This list is not comprehensive. | 
| 254   return basic_error == SQLITE_BUSY || | 252   return basic_error == SQLITE_BUSY || | 
| 255       basic_error == SQLITE_NOTADB || | 253       basic_error == SQLITE_NOTADB || | 
| 256       basic_error == SQLITE_CORRUPT; | 254       basic_error == SQLITE_CORRUPT; | 
| 257 } | 255 } | 
| 258 | 256 | 
| 259 // static |  | 
| 260 void Connection::set_mmap_disabled_by_default() { |  | 
| 261     g_mmap_disabled_default = true; |  | 
| 262 } |  | 
| 263 |  | 
| 264 |  | 
| 265 void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) { | 257 void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) { | 
| 266   AssertIOAllowed(); | 258   AssertIOAllowed(); | 
| 267 | 259 | 
| 268   std::string debug_info; | 260   std::string debug_info; | 
| 269   const int error = (extended_error & 0xFF); | 261   const int error = (extended_error & 0xFF); | 
| 270   if (error == SQLITE_CORRUPT) { | 262   if (error == SQLITE_CORRUPT) { | 
| 271     // CollectCorruptionInfo() is implemented in terms of sql::Connection, | 263     // CollectCorruptionInfo() is implemented in terms of sql::Connection, | 
| 272     // prevent reentrant calls to the error callback. | 264     // prevent reentrant calls to the error callback. | 
| 273     // TODO(shess): Rewrite IntegrityCheckHelper() in terms of raw SQLite. | 265     // TODO(shess): Rewrite IntegrityCheckHelper() in terms of raw SQLite. | 
| 274     ErrorCallback original_callback = std::move(error_callback_); | 266     ErrorCallback original_callback = std::move(error_callback_); | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 348 Connection::Connection() | 340 Connection::Connection() | 
| 349     : db_(NULL), | 341     : db_(NULL), | 
| 350       page_size_(0), | 342       page_size_(0), | 
| 351       cache_size_(0), | 343       cache_size_(0), | 
| 352       exclusive_locking_(false), | 344       exclusive_locking_(false), | 
| 353       restrict_to_user_(false), | 345       restrict_to_user_(false), | 
| 354       transaction_nesting_(0), | 346       transaction_nesting_(0), | 
| 355       needs_rollback_(false), | 347       needs_rollback_(false), | 
| 356       in_memory_(false), | 348       in_memory_(false), | 
| 357       poisoned_(false), | 349       poisoned_(false), | 
| 358       mmap_disabled_(g_mmap_disabled_default), | 350       mmap_disabled_(false), | 
| 359       mmap_enabled_(false), | 351       mmap_enabled_(false), | 
| 360       total_changes_at_last_release_(0), | 352       total_changes_at_last_release_(0), | 
| 361       stats_histogram_(NULL), | 353       stats_histogram_(NULL), | 
| 362       commit_time_histogram_(NULL), | 354       commit_time_histogram_(NULL), | 
| 363       autocommit_time_histogram_(NULL), | 355       autocommit_time_histogram_(NULL), | 
| 364       update_time_histogram_(NULL), | 356       update_time_histogram_(NULL), | 
| 365       query_time_histogram_(NULL), | 357       query_time_histogram_(NULL), | 
| 366       clock_(new TimeSource()) { | 358       clock_(new TimeSource()) { | 
| 367 } | 359 } | 
| 368 | 360 | 
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1981   ignore_result(Execute(kNoWritableSchema)); | 1973   ignore_result(Execute(kNoWritableSchema)); | 
| 1982 | 1974 | 
| 1983   return ret; | 1975   return ret; | 
| 1984 } | 1976 } | 
| 1985 | 1977 | 
| 1986 base::TimeTicks TimeSource::Now() { | 1978 base::TimeTicks TimeSource::Now() { | 
| 1987   return base::TimeTicks::Now(); | 1979   return base::TimeTicks::Now(); | 
| 1988 } | 1980 } | 
| 1989 | 1981 | 
| 1990 }  // namespace sql | 1982 }  // namespace sql | 
| OLD | NEW | 
|---|