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

Side by Side Diff: chrome/browser/webdata/web_database_service_impl.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: Self review. 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_impl.h" 5 #include "chrome/browser/webdata/web_database_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "chrome/browser/api/webdata/web_data_results.h" 10 #include "chrome/browser/api/webdata/web_data_results.h"
11 #include "chrome/browser/api/webdata/web_data_service_consumer.h" 11 #include "chrome/browser/api/webdata/web_data_service_consumer.h"
12 // TODO(caitkp): Remove this autofill dependency. 12 // TODO(caitkp): Remove this autofill dependency.
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/webdata/autofill_table.h"
15 #include "chrome/browser/webdata/keyword_table.h"
16 #include "chrome/browser/webdata/logins_table.h"
17 #include "chrome/browser/webdata/token_service_table.h"
18 #include "chrome/browser/webdata/web_apps_table.h"
14 #include "chrome/browser/webdata/web_data_request_manager.h" 19 #include "chrome/browser/webdata/web_data_request_manager.h"
15 #include "chrome/browser/webdata/web_data_service.h" 20 #include "chrome/browser/webdata/web_data_service.h"
21 #include "chrome/browser/webdata/web_intents_table.h"
16 #include "components/autofill/browser/autofill_country.h" 22 #include "components/autofill/browser/autofill_country.h"
17 23
18 using base::Bind; 24 using base::Bind;
19 using base::FilePath; 25 using base::FilePath;
20 using content::BrowserThread; 26 using content::BrowserThread;
21 27
22 28
23 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
24 // 30 //
25 // WebDatabaseServiceInternal implementation. 31 // WebDatabaseServiceInternal implementation.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 friend class base::DeleteHelper<WebDatabaseServiceInternal>; 75 friend class base::DeleteHelper<WebDatabaseServiceInternal>;
70 76
71 virtual ~WebDatabaseServiceInternal(); 77 virtual ~WebDatabaseServiceInternal();
72 78
73 // Commit the current transaction. 79 // Commit the current transaction.
74 void Commit(); 80 void Commit();
75 81
76 // Path to database file. 82 // Path to database file.
77 FilePath db_path_; 83 FilePath db_path_;
78 84
85 scoped_ptr<AutofillTable> autofill_table_;
86 scoped_ptr<KeywordTable> keyword_table_;
87 scoped_ptr<LoginsTable> logins_table_;
88 scoped_ptr<TokenServiceTable> token_service_table_;
89 scoped_ptr<WebAppsTable> web_apps_table_;
90 scoped_ptr<WebIntentsTable> web_intents_table_;
91
79 scoped_ptr<WebDatabase> db_; 92 scoped_ptr<WebDatabase> db_;
80 93
81 // Keeps track of all pending requests made to the db. 94 // Keeps track of all pending requests made to the db.
82 scoped_refptr<WebDataRequestManager> request_manager_; 95 scoped_refptr<WebDataRequestManager> request_manager_;
83 96
84 // State of database initialization. Used to prevent the executing of tasks 97 // State of database initialization. Used to prevent the executing of tasks
85 // before the db is ready. 98 // before the db is ready.
86 sql::InitStatus init_status_; 99 sql::InitStatus init_status_;
87 100
88 // True if an attempt has been made to load the database (even if the attempt 101 // True if an attempt has been made to load the database (even if the attempt
(...skipping 29 matching lines...) Expand all
118 callback.Run(LoadDatabaseIfNecessary()); 131 callback.Run(LoadDatabaseIfNecessary());
119 } 132 }
120 } 133 }
121 134
122 sql::InitStatus WebDatabaseServiceInternal::LoadDatabaseIfNecessary() { 135 sql::InitStatus WebDatabaseServiceInternal::LoadDatabaseIfNecessary() {
123 if (init_complete_ || db_path_.empty()) { 136 if (init_complete_ || db_path_.empty()) {
124 return init_status_; 137 return init_status_;
125 } 138 }
126 init_complete_ = true; 139 init_complete_ = true;
127 db_.reset(new WebDatabase()); 140 db_.reset(new WebDatabase());
141
142 // All tables objects that participate in managing the database must
143 // be added here.
144 autofill_table_.reset(new AutofillTable());
145 db_->AddTable(autofill_table_.get());
146
147 keyword_table_.reset(new KeywordTable());
148 db_->AddTable(keyword_table_.get());
149
150 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password
151 // access, but for now, we still create it on all platforms since it deletes
152 // the old logins table. We can remove this after a while, e.g. in M22 or so.
153 logins_table_.reset(new LoginsTable());
154 db_->AddTable(logins_table_.get());
155
156 token_service_table_.reset(new TokenServiceTable());
157 db_->AddTable(token_service_table_.get());
158
159 web_apps_table_.reset(new WebAppsTable());
160 db_->AddTable(web_apps_table_.get());
161
162 // TODO(thakis): Add a migration to delete the SQL table used by
163 // WebIntentsTable, then remove this.
164 web_intents_table_.reset(new WebIntentsTable());
165 db_->AddTable(web_intents_table_.get());
166
128 init_status_ = db_->Init(db_path_, app_locale_); 167 init_status_ = db_->Init(db_path_, app_locale_);
129 if (init_status_ != sql::INIT_OK) { 168 if (init_status_ != sql::INIT_OK) {
130 LOG(ERROR) << "Cannot initialize the web database: " << init_status_; 169 LOG(ERROR) << "Cannot initialize the web database: " << init_status_;
131 db_.reset(NULL); 170 db_.reset(NULL);
132 return init_status_; 171 return init_status_;
133 } 172 }
134 173
135 db_->BeginTransaction(); 174 db_->BeginTransaction();
136 return init_status_; 175 return init_status_;
137 } 176 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void WebDatabaseServiceImpl::CancelRequest(WebDataServiceBase::Handle h) { 300 void WebDatabaseServiceImpl::CancelRequest(WebDataServiceBase::Handle h) {
262 if (wdbs_internal_) 301 if (wdbs_internal_)
263 wdbs_internal_->request_manager()->CancelRequest(h); 302 wdbs_internal_->request_manager()->CancelRequest(h);
264 } 303 }
265 304
266 // Testing 305 // Testing
267 void WebDatabaseServiceImpl::set_init_complete(bool complete) { 306 void WebDatabaseServiceImpl::set_init_complete(bool complete) {
268 if (wdbs_internal_) 307 if (wdbs_internal_)
269 wdbs_internal_->set_init_complete(complete); 308 wdbs_internal_->set_init_complete(complete);
270 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698