| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool Connection::OpenInMemory() { | 106 bool Connection::OpenInMemory() { |
| 107 return OpenInternal(":memory:"); | 107 return OpenInternal(":memory:"); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void Connection::Close() { | 110 void Connection::Close() { |
| 111 statement_cache_.clear(); | 111 statement_cache_.clear(); |
| 112 DCHECK(open_statements_.empty()); | 112 DCHECK(open_statements_.empty()); |
| 113 if (db_) { | 113 if (db_) { |
| 114 // TODO(shess): Some additional code to debug http://crbug.com/95527 . |
| 115 // If you are reading this due to link errors or something, it can |
| 116 // be safely removed. |
| 117 #if defined(HAS_SQLITE3_95527) |
| 118 unsigned int nTouched = 0; |
| 119 sqlite3_95527(db_, &nTouched); |
| 120 |
| 121 // If a VERY large amount of memory was touched, crash. This |
| 122 // should never happen. |
| 123 // TODO(shess): Pull this in. It should be page_size * page_cache |
| 124 // or something like that, 4M or 16M. For now it's just to |
| 125 // prevent optimization. |
| 126 CHECK_LT(nTouched, 1000*1000*1000U); |
| 127 #endif |
| 114 sqlite3_close(db_); | 128 sqlite3_close(db_); |
| 115 db_ = NULL; | 129 db_ = NULL; |
| 116 } | 130 } |
| 117 } | 131 } |
| 118 | 132 |
| 119 void Connection::Preload() { | 133 void Connection::Preload() { |
| 120 if (!db_) { | 134 if (!db_) { |
| 121 NOTREACHED(); | 135 NOTREACHED(); |
| 122 return; | 136 return; |
| 123 } | 137 } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 431 |
| 418 int Connection::OnSqliteError(int err, sql::Statement *stmt) { | 432 int Connection::OnSqliteError(int err, sql::Statement *stmt) { |
| 419 if (error_delegate_.get()) | 433 if (error_delegate_.get()) |
| 420 return error_delegate_->OnError(err, this, stmt); | 434 return error_delegate_->OnError(err, this, stmt); |
| 421 // The default handling is to assert on debug and to ignore on release. | 435 // The default handling is to assert on debug and to ignore on release. |
| 422 NOTREACHED() << GetErrorMessage(); | 436 NOTREACHED() << GetErrorMessage(); |
| 423 return err; | 437 return err; |
| 424 } | 438 } |
| 425 | 439 |
| 426 } // namespace sql | 440 } // namespace sql |
| OLD | NEW |