Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: sql/connection.cc

Issue 16788002: Remove sql::ErrorDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase conflict Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sql/connection.h ('k') | sql/sqlite_features_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_util.h" 10 #include "base/file_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } // namespace 67 } // namespace
68 68
69 namespace sql { 69 namespace sql {
70 70
71 bool StatementID::operator<(const StatementID& other) const { 71 bool StatementID::operator<(const StatementID& other) const {
72 if (number_ != other.number_) 72 if (number_ != other.number_)
73 return number_ < other.number_; 73 return number_ < other.number_;
74 return strcmp(str_, other.str_) < 0; 74 return strcmp(str_, other.str_) < 0;
75 } 75 }
76 76
77 ErrorDelegate::~ErrorDelegate() {
78 }
79
80 Connection::StatementRef::StatementRef(Connection* connection, 77 Connection::StatementRef::StatementRef(Connection* connection,
81 sqlite3_stmt* stmt, 78 sqlite3_stmt* stmt,
82 bool was_valid) 79 bool was_valid)
83 : connection_(connection), 80 : connection_(connection),
84 stmt_(stmt), 81 stmt_(stmt),
85 was_valid_(was_valid) { 82 was_valid_(was_valid) {
86 if (connection) 83 if (connection)
87 connection_->StatementRefCreated(this); 84 connection_->StatementRefCreated(this);
88 } 85 }
89 86
(...skipping 25 matching lines...) Expand all
115 } 112 }
116 113
117 Connection::Connection() 114 Connection::Connection()
118 : db_(NULL), 115 : db_(NULL),
119 page_size_(0), 116 page_size_(0),
120 cache_size_(0), 117 cache_size_(0),
121 exclusive_locking_(false), 118 exclusive_locking_(false),
122 transaction_nesting_(0), 119 transaction_nesting_(0),
123 needs_rollback_(false), 120 needs_rollback_(false),
124 in_memory_(false), 121 in_memory_(false),
125 poisoned_(false) {} 122 poisoned_(false) {
123 }
126 124
127 Connection::~Connection() { 125 Connection::~Connection() {
128 Close(); 126 Close();
129 } 127 }
130 128
131 bool Connection::Open(const base::FilePath& path) { 129 bool Connection::Open(const base::FilePath& path) {
132 if (!histogram_tag_.empty()) { 130 if (!histogram_tag_.empty()) {
133 int64 size_64 = 0; 131 int64 size_64 = 0;
134 if (file_util::GetFileSize(path, &size_64)) { 132 if (file_util::GetFileSize(path, &size_64)) {
135 size_t sample = static_cast<size_t>(size_64 / 1024); 133 size_t sample = static_cast<size_t>(size_64 / 1024);
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // Always log the error. 753 // Always log the error.
756 LOG(ERROR) << "sqlite error " << err 754 LOG(ERROR) << "sqlite error " << err
757 << ", errno " << GetLastErrno() 755 << ", errno " << GetLastErrno()
758 << ": " << GetErrorMessage(); 756 << ": " << GetErrorMessage();
759 757
760 if (!error_callback_.is_null()) { 758 if (!error_callback_.is_null()) {
761 error_callback_.Run(err, stmt); 759 error_callback_.Run(err, stmt);
762 return err; 760 return err;
763 } 761 }
764 762
765 // TODO(shess): Remove |error_delegate_| once everything is
766 // converted to |error_callback_|.
767 if (error_delegate_.get())
768 return error_delegate_->OnError(err, this, stmt);
769
770 // The default handling is to assert on debug and to ignore on release. 763 // The default handling is to assert on debug and to ignore on release.
771 DLOG(FATAL) << GetErrorMessage(); 764 DLOG(FATAL) << GetErrorMessage();
772 return err; 765 return err;
773 } 766 }
774 767
775 // TODO(shess): Allow specifying integrity_check versus quick_check. 768 // TODO(shess): Allow specifying integrity_check versus quick_check.
776 // TODO(shess): Allow specifying maximum results (default 100 lines). 769 // TODO(shess): Allow specifying maximum results (default 100 lines).
777 bool Connection::IntegrityCheck(std::vector<std::string>* messages) { 770 bool Connection::IntegrityCheck(std::vector<std::string>* messages) {
778 messages->clear(); 771 messages->clear();
779 772
(...skipping 21 matching lines...) Expand all
801 } 794 }
802 795
803 // Best effort to put things back as they were before. 796 // Best effort to put things back as they were before.
804 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; 797 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF";
805 ignore_result(Execute(kNoWritableSchema)); 798 ignore_result(Execute(kNoWritableSchema));
806 799
807 return ret; 800 return ret;
808 } 801 }
809 802
810 } // namespace sql 803 } // namespace sql
OLDNEW
« no previous file with comments | « sql/connection.h ('k') | sql/sqlite_features_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698