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

Side by Side Diff: chrome/browser/webdata/web_database_service.cc

Issue 12543034: Move creation of the various WebDatabaseTable types out of WebDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows release builds (COMDAT folding combined static functions being used for keys. Created 7 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_service.h" 5 #include "chrome/browser/webdata/web_database_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "chrome/browser/api/webdata/web_data_results.h" 9 #include "chrome/browser/api/webdata/web_data_results.h"
10 #include "chrome/browser/api/webdata/web_data_service_consumer.h" 10 #include "chrome/browser/api/webdata/web_data_service_consumer.h"
11 #include "chrome/browser/webdata/autofill_table.h"
12 #include "chrome/browser/webdata/keyword_table.h"
13 #include "chrome/browser/webdata/logins_table.h"
14 #include "chrome/browser/webdata/token_service_table.h"
15 #include "chrome/browser/webdata/web_apps_table.h"
11 #include "chrome/browser/webdata/web_data_request_manager.h" 16 #include "chrome/browser/webdata/web_data_request_manager.h"
12 #include "chrome/browser/webdata/web_data_service.h" 17 #include "chrome/browser/webdata/web_data_service.h"
18 #include "chrome/browser/webdata/web_intents_table.h"
13 // TODO(caitkp): Remove this autofill dependency. 19 // TODO(caitkp): Remove this autofill dependency.
14 #include "components/autofill/browser/autofill_country.h" 20 #include "components/autofill/browser/autofill_country.h"
15 21
16 using base::Bind; 22 using base::Bind;
17 using base::FilePath; 23 using base::FilePath;
18 using content::BrowserThread; 24 using content::BrowserThread;
19 25
20 26
21 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
22 // 28 //
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 friend class base::DeleteHelper<WebDataServiceBackend>; 71 friend class base::DeleteHelper<WebDataServiceBackend>;
66 72
67 virtual ~WebDataServiceBackend(); 73 virtual ~WebDataServiceBackend();
68 74
69 // Commit the current transaction. 75 // Commit the current transaction.
70 void Commit(); 76 void Commit();
71 77
72 // Path to database file. 78 // Path to database file.
73 FilePath db_path_; 79 FilePath db_path_;
74 80
81 scoped_ptr<AutofillTable> autofill_table_;
82 scoped_ptr<KeywordTable> keyword_table_;
83 scoped_ptr<LoginsTable> logins_table_;
84 scoped_ptr<TokenServiceTable> token_service_table_;
85 scoped_ptr<WebAppsTable> web_apps_table_;
86 scoped_ptr<WebIntentsTable> web_intents_table_;
87
75 scoped_ptr<WebDatabase> db_; 88 scoped_ptr<WebDatabase> db_;
76 89
77 // Keeps track of all pending requests made to the db. 90 // Keeps track of all pending requests made to the db.
78 scoped_refptr<WebDataRequestManager> request_manager_; 91 scoped_refptr<WebDataRequestManager> request_manager_;
79 92
80 // State of database initialization. Used to prevent the executing of tasks 93 // State of database initialization. Used to prevent the executing of tasks
81 // before the db is ready. 94 // before the db is ready.
82 sql::InitStatus init_status_; 95 sql::InitStatus init_status_;
83 96
84 // True if an attempt has been made to load the database (even if the attempt 97 // True if an attempt has been made to load the database (even if the attempt
(...skipping 22 matching lines...) Expand all
107 callback.Run(LoadDatabaseIfNecessary()); 120 callback.Run(LoadDatabaseIfNecessary());
108 } 121 }
109 } 122 }
110 123
111 sql::InitStatus WebDataServiceBackend::LoadDatabaseIfNecessary() { 124 sql::InitStatus WebDataServiceBackend::LoadDatabaseIfNecessary() {
112 if (init_complete_ || db_path_.empty()) { 125 if (init_complete_ || db_path_.empty()) {
113 return init_status_; 126 return init_status_;
114 } 127 }
115 init_complete_ = true; 128 init_complete_ = true;
116 db_.reset(new WebDatabase()); 129 db_.reset(new WebDatabase());
130
131 // All tables objects that participate in managing the database must
132 // be added here.
133 autofill_table_.reset(new AutofillTable());
134 db_->AddTable(autofill_table_.get());
135
136 keyword_table_.reset(new KeywordTable());
137 db_->AddTable(keyword_table_.get());
138
139 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password
140 // access, but for now, we still create it on all platforms since it deletes
141 // the old logins table. We can remove this after a while, e.g. in M22 or so.
142 logins_table_.reset(new LoginsTable());
143 db_->AddTable(logins_table_.get());
144
145 token_service_table_.reset(new TokenServiceTable());
146 db_->AddTable(token_service_table_.get());
147
148 web_apps_table_.reset(new WebAppsTable());
149 db_->AddTable(web_apps_table_.get());
150
151 // TODO(thakis): Add a migration to delete the SQL table used by
152 // WebIntentsTable, then remove this.
153 web_intents_table_.reset(new WebIntentsTable());
154 db_->AddTable(web_intents_table_.get());
155
117 init_status_ = db_->Init(db_path_, app_locale_); 156 init_status_ = db_->Init(db_path_, app_locale_);
118 if (init_status_ != sql::INIT_OK) { 157 if (init_status_ != sql::INIT_OK) {
119 LOG(ERROR) << "Cannot initialize the web database: " << init_status_; 158 LOG(ERROR) << "Cannot initialize the web database: " << init_status_;
120 db_.reset(NULL); 159 db_.reset(NULL);
121 return init_status_; 160 return init_status_;
122 } 161 }
123 162
124 db_->BeginTransaction(); 163 db_->BeginTransaction();
125 return init_status_; 164 return init_status_;
126 } 165 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 task, base::Passed(&request))); 292 task, base::Passed(&request)));
254 293
255 return handle; 294 return handle;
256 } 295 }
257 296
258 void WebDatabaseService::CancelRequest(WebDataServiceBase::Handle h) { 297 void WebDatabaseService::CancelRequest(WebDataServiceBase::Handle h) {
259 if (!wds_backend_) 298 if (!wds_backend_)
260 return; 299 return;
261 wds_backend_->request_manager()->CancelRequest(h); 300 wds_backend_->request_manager()->CancelRequest(h);
262 } 301 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database_migration_unittest.cc ('k') | chrome/browser/webdata/web_database_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698