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/common/notification_service.h" | 16 #include "content/browser/notification_service_impl.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 = 40; | 25 const int kCurrentVersionNumber = 40; |
26 const int kCompatibleVersionNumber = 40; | 26 const int kCompatibleVersionNumber = 40; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return web_intents_table_.get(); | 84 return web_intents_table_.get(); |
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 (!NotificationService::current()) | 94 if (!content::NotificationService::current()) |
95 notification_service_.reset(new NotificationService); | 95 notification_service_.reset(new NotificationServiceImpl); |
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 // Add successive versions here. Each should set the version number and | 314 // Add successive versions here. Each should set the version number and |
315 // compatible version number as appropriate, then fall through to the next | 315 // compatible version number as appropriate, then fall through to the next |
316 // case. | 316 // case. |
317 | 317 |
318 case kCurrentVersionNumber: | 318 case kCurrentVersionNumber: |
319 // No migration needed. | 319 // No migration needed. |
320 return sql::INIT_OK; | 320 return sql::INIT_OK; |
321 } | 321 } |
322 } | 322 } |
OLD | NEW |