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

Side by Side Diff: webkit/dom_storage/dom_storage_database.cc

Issue 15104003: Remove last client of sql::DiagnosticErrorDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Convert to error callback. Created 7 years, 7 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/sql.gyp ('k') | no next file » | 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 "webkit/dom_storage/dom_storage_database.h" 5 #include "webkit/dom_storage/dom_storage_database.h"
6 6
7 #include "base/bind.h"
7 #include "base/file_util.h" 8 #include "base/file_util.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "sql/diagnostic_error_delegate.h"
10 #include "sql/statement.h" 10 #include "sql/statement.h"
11 #include "sql/transaction.h" 11 #include "sql/transaction.h"
12 #include "third_party/sqlite/sqlite3.h" 12 #include "third_party/sqlite/sqlite3.h"
13 13
14 namespace { 14 namespace {
15 15
16 const base::FilePath::CharType kJournal[] = FILE_PATH_LITERAL("-journal"); 16 const base::FilePath::CharType kJournal[] = FILE_PATH_LITERAL("-journal");
17 17
18 class HistogramUniquifier { 18 void DatabaseErrorCallback(int error, sql::Statement* stmt) {
19 public: 19 // Without a callback to ignore errors,
20 static const char* name() { return "Sqlite.DomStorageDatabase.Error"; } 20 // DomStorageDatabaseTest.TestCanOpenFileThatIsNotADatabase fails with:
21 }; 21 // ERROR:connection.cc(735)] sqlite error 522, errno 0: disk I/O error
22 22 // FATAL:connection.cc(750)] disk I/O error
23 sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() { 23 // <backtrace>
24 return new sql::DiagnosticErrorDelegate<HistogramUniquifier>(); 24 // <crash>
25 //
26 // TODO(shess): If/when infrastructure lands which can allow tests
27 // to handle SQLite errors appropriately, remove this.
25 } 28 }
26 29
27 } // anon namespace 30 } // anon namespace
28 31
29 namespace dom_storage { 32 namespace dom_storage {
30 33
31 // static 34 // static
32 base::FilePath DomStorageDatabase::GetJournalFilePath( 35 base::FilePath DomStorageDatabase::GetJournalFilePath(
33 const base::FilePath& database_path) { 36 const base::FilePath& database_path) {
34 base::FilePath::StringType journal_file_name = 37 base::FilePath::StringType journal_file_name =
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 155
153 if (!database_exists && !create_if_needed) { 156 if (!database_exists && !create_if_needed) {
154 // If the file doesn't exist already and we haven't been asked to create 157 // If the file doesn't exist already and we haven't been asked to create
155 // a file on disk, then we don't bother opening the database. This means 158 // a file on disk, then we don't bother opening the database. This means
156 // we wait until we absolutely need to put something onto disk before we 159 // we wait until we absolutely need to put something onto disk before we
157 // do so. 160 // do so.
158 return false; 161 return false;
159 } 162 }
160 163
161 db_.reset(new sql::Connection()); 164 db_.reset(new sql::Connection());
162 db_->set_error_delegate(GetErrorHandlerForDomStorageDatabase()); 165 db_->set_histogram_tag("DomStorageDatabase");
marja 2013/05/23 05:32:29 Will we get the same error histogram information v
Scott Hess - ex-Googler 2013/05/23 05:45:37 Old School: Complicated function template calling
166 db_->set_error_callback(base::Bind(&DatabaseErrorCallback));
163 167
164 if (file_path_.empty()) { 168 if (file_path_.empty()) {
165 // This code path should only be triggered by unit tests. 169 // This code path should only be triggered by unit tests.
166 if (!db_->OpenInMemory()) { 170 if (!db_->OpenInMemory()) {
167 NOTREACHED() << "Unable to open DOM storage database in memory."; 171 NOTREACHED() << "Unable to open DOM storage database in memory.";
168 failed_to_open_ = true; 172 failed_to_open_ = true;
169 return false; 173 return false;
170 } 174 }
171 } else { 175 } else {
172 if (!db_->Open(file_path_)) { 176 if (!db_->Open(file_path_)) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 CreateTableV2() && 299 CreateTableV2() &&
296 CommitChanges(false, values) && 300 CommitChanges(false, values) &&
297 migration.Commit(); 301 migration.Commit();
298 } 302 }
299 303
300 void DomStorageDatabase::Close() { 304 void DomStorageDatabase::Close() {
301 db_.reset(NULL); 305 db_.reset(NULL);
302 } 306 }
303 307
304 } // namespace dom_storage 308 } // namespace dom_storage
OLDNEW
« no previous file with comments | « sql/sql.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698