| 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 <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // released all statements. | 118 // released all statements. |
| 119 statement_cache_.clear(); | 119 statement_cache_.clear(); |
| 120 DCHECK(open_statements_.empty()); | 120 DCHECK(open_statements_.empty()); |
| 121 | 121 |
| 122 // Additionally clear the prepared statements, because they contain | 122 // Additionally clear the prepared statements, because they contain |
| 123 // weak references to this connection. This case has come up when | 123 // weak references to this connection. This case has come up when |
| 124 // error-handling code is hit in production. | 124 // error-handling code is hit in production. |
| 125 ClearCache(); | 125 ClearCache(); |
| 126 | 126 |
| 127 if (db_) { | 127 if (db_) { |
| 128 // TODO(shess): Some additional code to debug http://crbug.com/95527 . | |
| 129 // If you are reading this due to link errors or something, it can | |
| 130 // be safely removed. | |
| 131 #if defined(HAS_SQLITE3_95527) | |
| 132 unsigned int nTouched = 0; | |
| 133 sqlite3_95527(db_, &nTouched); | |
| 134 | |
| 135 // If a VERY large amount of memory was touched, crash. This | |
| 136 // should never happen. | |
| 137 // TODO(shess): Pull this in. It should be page_size * page_cache | |
| 138 // or something like that, 4M or 16M. For now it's just to | |
| 139 // prevent optimization. | |
| 140 CHECK_LT(nTouched, 1000*1000*1000U); | |
| 141 #endif | |
| 142 | |
| 143 // TODO(shess): Histogram for failure. | 128 // TODO(shess): Histogram for failure. |
| 144 sqlite3_close(db_); | 129 sqlite3_close(db_); |
| 145 db_ = NULL; | 130 db_ = NULL; |
| 146 } | 131 } |
| 147 } | 132 } |
| 148 | 133 |
| 149 void Connection::Preload() { | 134 void Connection::Preload() { |
| 150 if (!db_) { | 135 if (!db_) { |
| 151 DLOG(FATAL) << "Cannot preload null db"; | 136 DLOG(FATAL) << "Cannot preload null db"; |
| 152 return; | 137 return; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 469 |
| 485 int Connection::OnSqliteError(int err, sql::Statement *stmt) { | 470 int Connection::OnSqliteError(int err, sql::Statement *stmt) { |
| 486 if (error_delegate_.get()) | 471 if (error_delegate_.get()) |
| 487 return error_delegate_->OnError(err, this, stmt); | 472 return error_delegate_->OnError(err, this, stmt); |
| 488 // The default handling is to assert on debug and to ignore on release. | 473 // The default handling is to assert on debug and to ignore on release. |
| 489 DLOG(FATAL) << GetErrorMessage(); | 474 DLOG(FATAL) << GetErrorMessage(); |
| 490 return err; | 475 return err; |
| 491 } | 476 } |
| 492 | 477 |
| 493 } // namespace sql | 478 } // namespace sql |
| OLD | NEW |