| 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 "webkit/dom_storage/dom_storage_database.h" | 5 #include "webkit/dom_storage/dom_storage_database.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "sql/diagnostic_error_delegate.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 FilePath::CharType kJournal[] = FILE_PATH_LITERAL("-journal"); | 16 const base::FilePath::CharType kJournal[] = FILE_PATH_LITERAL("-journal"); |
| 17 | 17 |
| 18 class HistogramUniquifier { | 18 class HistogramUniquifier { |
| 19 public: | 19 public: |
| 20 static const char* name() { return "Sqlite.DomStorageDatabase.Error"; } | 20 static const char* name() { return "Sqlite.DomStorageDatabase.Error"; } |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() { | 23 sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() { |
| 24 return new sql::DiagnosticErrorDelegate<HistogramUniquifier>(); | 24 return new sql::DiagnosticErrorDelegate<HistogramUniquifier>(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // anon namespace | 27 } // anon namespace |
| 28 | 28 |
| 29 namespace dom_storage { | 29 namespace dom_storage { |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 FilePath DomStorageDatabase::GetJournalFilePath( | 32 base::FilePath DomStorageDatabase::GetJournalFilePath( |
| 33 const FilePath& database_path) { | 33 const base::FilePath& database_path) { |
| 34 FilePath::StringType journal_file_name = | 34 base::FilePath::StringType journal_file_name = |
| 35 database_path.BaseName().value() + kJournal; | 35 database_path.BaseName().value() + kJournal; |
| 36 return database_path.DirName().Append(journal_file_name); | 36 return database_path.DirName().Append(journal_file_name); |
| 37 } | 37 } |
| 38 | 38 |
| 39 DomStorageDatabase::DomStorageDatabase(const FilePath& file_path) | 39 DomStorageDatabase::DomStorageDatabase(const base::FilePath& file_path) |
| 40 : file_path_(file_path) { | 40 : file_path_(file_path) { |
| 41 // Note: in normal use we should never get an empty backing path here. | 41 // Note: in normal use we should never get an empty backing path here. |
| 42 // However, the unit test for this class can contruct an instance | 42 // However, the unit test for this class can contruct an instance |
| 43 // with an empty path. | 43 // with an empty path. |
| 44 Init(); | 44 Init(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DomStorageDatabase::DomStorageDatabase() { | 47 DomStorageDatabase::DomStorageDatabase() { |
| 48 Init(); | 48 Init(); |
| 49 } | 49 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 CreateTableV2() && | 295 CreateTableV2() && |
| 296 CommitChanges(false, values) && | 296 CommitChanges(false, values) && |
| 297 migration.Commit(); | 297 migration.Commit(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void DomStorageDatabase::Close() { | 300 void DomStorageDatabase::Close() { |
| 301 db_.reset(NULL); | 301 db_.reset(NULL); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace dom_storage | 304 } // namespace dom_storage |
| OLD | NEW |