| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 in_memory_(false), | 221 in_memory_(false), |
| 222 poisoned_(false) { | 222 poisoned_(false) { |
| 223 } | 223 } |
| 224 | 224 |
| 225 Connection::~Connection() { | 225 Connection::~Connection() { |
| 226 Close(); | 226 Close(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool Connection::Open(const base::FilePath& path) { | 229 bool Connection::Open(const base::FilePath& path) { |
| 230 if (!histogram_tag_.empty()) { | 230 if (!histogram_tag_.empty()) { |
| 231 int64 size_64 = 0; | 231 int64_t size_64 = 0; |
| 232 if (base::GetFileSize(path, &size_64)) { | 232 if (base::GetFileSize(path, &size_64)) { |
| 233 size_t sample = static_cast<size_t>(size_64 / 1024); | 233 size_t sample = static_cast<size_t>(size_64 / 1024); |
| 234 std::string full_histogram_name = "Sqlite.SizeKB." + histogram_tag_; | 234 std::string full_histogram_name = "Sqlite.SizeKB." + histogram_tag_; |
| 235 base::HistogramBase* histogram = | 235 base::HistogramBase* histogram = |
| 236 base::Histogram::FactoryGet( | 236 base::Histogram::FactoryGet( |
| 237 full_histogram_name, 1, 1000000, 50, | 237 full_histogram_name, 1, 1000000, 50, |
| 238 base::HistogramBase::kUmaTargetedHistogramFlag); | 238 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 239 if (histogram) | 239 if (histogram) |
| 240 histogram->Add(sample); | 240 histogram->Add(sample); |
| 241 } | 241 } |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 if (!statement.is_valid()) | 828 if (!statement.is_valid()) |
| 829 return false; | 829 return false; |
| 830 | 830 |
| 831 while (statement.Step()) { | 831 while (statement.Step()) { |
| 832 if (!base::strcasecmp(statement.ColumnString(1).c_str(), column_name)) | 832 if (!base::strcasecmp(statement.ColumnString(1).c_str(), column_name)) |
| 833 return true; | 833 return true; |
| 834 } | 834 } |
| 835 return false; | 835 return false; |
| 836 } | 836 } |
| 837 | 837 |
| 838 int64 Connection::GetLastInsertRowId() const { | 838 int64_t Connection::GetLastInsertRowId() const { |
| 839 if (!db_) { | 839 if (!db_) { |
| 840 DLOG_IF(FATAL, !poisoned_) << "Illegal use of connection without a db"; | 840 DLOG_IF(FATAL, !poisoned_) << "Illegal use of connection without a db"; |
| 841 return 0; | 841 return 0; |
| 842 } | 842 } |
| 843 return sqlite3_last_insert_rowid(db_); | 843 return sqlite3_last_insert_rowid(db_); |
| 844 } | 844 } |
| 845 | 845 |
| 846 int Connection::GetLastChangeCount() const { | 846 int Connection::GetLastChangeCount() const { |
| 847 if (!db_) { | 847 if (!db_) { |
| 848 DLOG_IF(FATAL, !poisoned_) << "Illegal use of connection without a db"; | 848 DLOG_IF(FATAL, !poisoned_) << "Illegal use of connection without a db"; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 // Best effort to put things back as they were before. | 1133 // Best effort to put things back as they were before. |
| 1134 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; | 1134 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; |
| 1135 ignore_result(Execute(kNoWritableSchema)); | 1135 ignore_result(Execute(kNoWritableSchema)); |
| 1136 | 1136 |
| 1137 return ret; | 1137 return ret; |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 } // namespace sql | 1140 } // namespace sql |
| OLD | NEW |