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 "content/common/notification_service.h" | 10 #include "content/common/notification_service.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 TokenServiceTable* WebDatabase::GetTokenServiceTable() { | 69 TokenServiceTable* WebDatabase::GetTokenServiceTable() { |
70 return token_service_table_.get(); | 70 return token_service_table_.get(); |
71 } | 71 } |
72 | 72 |
73 WebAppsTable* WebDatabase::GetWebAppsTable() { | 73 WebAppsTable* WebDatabase::GetWebAppsTable() { |
74 return web_apps_table_.get(); | 74 return web_apps_table_.get(); |
75 } | 75 } |
76 | 76 |
| 77 WebIntentsTable* WebDatabase::GetWebIntentsTable() { |
| 78 return web_intents_table_.get(); |
| 79 } |
| 80 |
77 sql::Connection* WebDatabase::GetSQLConnection() { | 81 sql::Connection* WebDatabase::GetSQLConnection() { |
78 return &db_; | 82 return &db_; |
79 } | 83 } |
80 | 84 |
81 sql::InitStatus WebDatabase::Init(const FilePath& db_name) { | 85 sql::InitStatus WebDatabase::Init(const FilePath& db_name) { |
82 // When running in unit tests, there is already a NotificationService object. | 86 // When running in unit tests, there is already a NotificationService object. |
83 // Since only one can exist at a time per thread, check first. | 87 // Since only one can exist at a time per thread, check first. |
84 if (!NotificationService::current()) | 88 if (!NotificationService::current()) |
85 notification_service_.reset(new NotificationService); | 89 notification_service_.reset(new NotificationService); |
86 | 90 |
(...skipping 28 matching lines...) Expand all Loading... |
115 LOG(WARNING) << "Web database is too new."; | 119 LOG(WARNING) << "Web database is too new."; |
116 return sql::INIT_TOO_NEW; | 120 return sql::INIT_TOO_NEW; |
117 } | 121 } |
118 | 122 |
119 // Create the tables. | 123 // Create the tables. |
120 autofill_table_.reset(new AutofillTable(&db_, &meta_table_)); | 124 autofill_table_.reset(new AutofillTable(&db_, &meta_table_)); |
121 keyword_table_.reset(new KeywordTable(&db_, &meta_table_)); | 125 keyword_table_.reset(new KeywordTable(&db_, &meta_table_)); |
122 logins_table_.reset(new LoginsTable(&db_, &meta_table_)); | 126 logins_table_.reset(new LoginsTable(&db_, &meta_table_)); |
123 token_service_table_.reset(new TokenServiceTable(&db_, &meta_table_)); | 127 token_service_table_.reset(new TokenServiceTable(&db_, &meta_table_)); |
124 web_apps_table_.reset(new WebAppsTable(&db_, &meta_table_)); | 128 web_apps_table_.reset(new WebAppsTable(&db_, &meta_table_)); |
| 129 web_intents_table_.reset(new WebIntentsTable(&db_, &meta_table_)); |
125 | 130 |
126 // Initialize the tables. | 131 // Initialize the tables. |
127 if (!keyword_table_->Init() || !autofill_table_->Init() || | 132 if (!keyword_table_->Init() || !autofill_table_->Init() || |
128 !logins_table_->Init() || !web_apps_table_->Init() || | 133 !logins_table_->Init() || !web_apps_table_->Init() || |
129 !token_service_table_->Init()) { | 134 !token_service_table_->Init() || !web_intents_table_->Init() ) { |
130 LOG(WARNING) << "Unable to initialize the web database."; | 135 LOG(WARNING) << "Unable to initialize the web database."; |
131 return sql::INIT_FAILURE; | 136 return sql::INIT_FAILURE; |
132 } | 137 } |
133 | 138 |
134 // If the file on disk is an older database version, bring it up to date. | 139 // If the file on disk is an older database version, bring it up to date. |
135 // If the migration fails we return an error to caller and do not commit | 140 // If the migration fails we return an error to caller and do not commit |
136 // the migration. | 141 // the migration. |
137 sql::InitStatus migration_status = MigrateOldVersionsAsNeeded(); | 142 sql::InitStatus migration_status = MigrateOldVersionsAsNeeded(); |
138 if (migration_status != sql::INIT_OK) | 143 if (migration_status != sql::INIT_OK) |
139 return migration_status; | 144 return migration_status; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 300 |
296 // Add successive versions here. Each should set the version number and | 301 // Add successive versions here. Each should set the version number and |
297 // compatible version number as appropriate, then fall through to the next | 302 // compatible version number as appropriate, then fall through to the next |
298 // case. | 303 // case. |
299 | 304 |
300 case kCurrentVersionNumber: | 305 case kCurrentVersionNumber: |
301 // No migration needed. | 306 // No migration needed. |
302 return sql::INIT_OK; | 307 return sql::INIT_OK; |
303 } | 308 } |
304 } | 309 } |
OLD | NEW |