| 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 "chrome/browser/webdata/web_database.h" | 5 #include "chrome/browser/webdata/web_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| 10 #include "chrome/browser/webdata/autofill_table.h" | 10 #include "chrome/browser/webdata/autofill_table.h" |
| 11 #include "chrome/browser/webdata/keyword_table.h" | 11 #include "chrome/browser/webdata/keyword_table.h" |
| 12 #include "chrome/browser/webdata/logins_table.h" | 12 #include "chrome/browser/webdata/logins_table.h" |
| 13 #include "chrome/browser/webdata/token_service_table.h" | 13 #include "chrome/browser/webdata/token_service_table.h" |
| 14 #include "chrome/browser/webdata/web_apps_table.h" | 14 #include "chrome/browser/webdata/web_apps_table.h" |
| 15 #include "chrome/browser/webdata/web_intents_table.h" | 15 #include "chrome/browser/webdata/web_intents_table.h" |
| 16 #include "content/browser/notification_service_impl.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "sql/statement.h" | 17 #include "sql/statement.h" |
| 18 #include "sql/transaction.h" | 18 #include "sql/transaction.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Current version number. Note: when changing the current version number, | 22 // Current version number. Note: when changing the current version number, |
| 23 // corresponding changes must happen in the unit tests, and new migration test | 23 // corresponding changes must happen in the unit tests, and new migration test |
| 24 // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. | 24 // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. |
| 25 const int kCurrentVersionNumber = 42; | 25 const int kCurrentVersionNumber = 42; |
| 26 const int kCompatibleVersionNumber = 42; | 26 const int kCompatibleVersionNumber = 42; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 sql::Connection* WebDatabase::GetSQLConnection() { | 87 sql::Connection* WebDatabase::GetSQLConnection() { |
| 88 return &db_; | 88 return &db_; |
| 89 } | 89 } |
| 90 | 90 |
| 91 sql::InitStatus WebDatabase::Init(const FilePath& db_name) { | 91 sql::InitStatus WebDatabase::Init(const FilePath& db_name) { |
| 92 // When running in unit tests, there is already a NotificationService object. | 92 // When running in unit tests, there is already a NotificationService object. |
| 93 // Since only one can exist at a time per thread, check first. | 93 // Since only one can exist at a time per thread, check first. |
| 94 if (!content::NotificationService::current()) | 94 if (!content::NotificationService::current()) |
| 95 notification_service_.reset(new NotificationServiceImpl); | 95 notification_service_.reset(content::NotificationService::Create()); |
| 96 | 96 |
| 97 // Set the exceptional sqlite error handler. | 97 // Set the exceptional sqlite error handler. |
| 98 db_.set_error_delegate(GetErrorHandlerForWebDb()); | 98 db_.set_error_delegate(GetErrorHandlerForWebDb()); |
| 99 | 99 |
| 100 // We don't store that much data in the tables so use a small page size. | 100 // We don't store that much data in the tables so use a small page size. |
| 101 // This provides a large benefit for empty tables (which is very likely with | 101 // This provides a large benefit for empty tables (which is very likely with |
| 102 // the tables we create). | 102 // the tables we create). |
| 103 db_.set_page_size(2048); | 103 db_.set_page_size(2048); |
| 104 | 104 |
| 105 // We shouldn't have much data and what access we currently have is quite | 105 // We shouldn't have much data and what access we currently have is quite |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 328 |
| 329 // Add successive versions here. Each should set the version number and | 329 // Add successive versions here. Each should set the version number and |
| 330 // compatible version number as appropriate, then fall through to the next | 330 // compatible version number as appropriate, then fall through to the next |
| 331 // case. | 331 // case. |
| 332 | 332 |
| 333 case kCurrentVersionNumber: | 333 case kCurrentVersionNumber: |
| 334 // No migration needed. | 334 // No migration needed. |
| 335 return sql::INIT_OK; | 335 return sql::INIT_OK; |
| 336 } | 336 } |
| 337 } | 337 } |
| OLD | NEW |