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 #ifndef SQL_CONNECTION_H_ | 5 #ifndef SQL_CONNECTION_H_ |
6 #define SQL_CONNECTION_H_ | 6 #define SQL_CONNECTION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 // organically. | 174 // organically. |
175 // | 175 // |
176 // This function assumes your class is using a meta table on the current | 176 // This function assumes your class is using a meta table on the current |
177 // database, as it openes a transaction on the meta table to force the | 177 // database, as it openes a transaction on the meta table to force the |
178 // database to be initialized. You should feel free to initialize the meta | 178 // database to be initialized. You should feel free to initialize the meta |
179 // table after calling preload since the meta table will already be in the | 179 // table after calling preload since the meta table will already be in the |
180 // database if it exists, and if it doesn't exist, the database won't | 180 // database if it exists, and if it doesn't exist, the database won't |
181 // generally exist either. | 181 // generally exist either. |
182 void Preload(); | 182 void Preload(); |
183 | 183 |
184 // Raze the database to the ground. This approximates creating a | |
185 // fresh database from scratch, within the constraints of SQLite's | |
186 // locking protocol (locks and open handles can make doing this with | |
187 // filesystem operations problematic). Returns true if the database | |
Greg Billock
2012/03/31 01:23:50
Does this mean it won't necessarily work? It seems
Scott Hess - ex-Googler
2012/04/04 01:28:25
My broad background with this change is:
A) corrup
Greg Billock
2012/04/04 19:49:21
Sounds good. I don't know if any of that's worth m
| |
188 // was razed. | |
189 // | |
190 // false is returned if the database is locked by some other | |
191 // process. RazeWithTimeout() may be used if appropriate. | |
Greg Billock
2012/03/31 01:23:50
What's the use case for that kind of call?
Scott Hess - ex-Googler
2012/04/04 01:28:25
Most (all?) profile databases are exclusive-access
Greg Billock
2012/04/04 19:49:21
Do you envision using this most typically for WebS
Scott Hess - ex-Googler
2012/04/04 20:28:52
Mostly it's for profile dbs, but I believe websql
| |
192 // | |
193 // NOTE(shess): Raze() will DCHECK in the following situations: | |
194 // - database is not open. | |
195 // - the connection has a transaction open. | |
196 // - a SQLite issue occurs which is structural in nature (like the | |
197 // statements used are broken). | |
198 // Since Raze() is expected to be called in unexpected situations, | |
199 // these all return false, since it is unlikely that the caller | |
200 // could fix them. | |
201 bool Raze(); | |
202 bool RazeWithTimout(base::TimeDelta timeout); | |
203 | |
184 // Transactions -------------------------------------------------------------- | 204 // Transactions -------------------------------------------------------------- |
185 | 205 |
186 // Transaction management. We maintain a virtual transaction stack to emulate | 206 // Transaction management. We maintain a virtual transaction stack to emulate |
187 // nested transactions since sqlite can't do nested transactions. The | 207 // nested transactions since sqlite can't do nested transactions. The |
188 // limitation is you can't roll back a sub transaction: if any transaction | 208 // limitation is you can't roll back a sub transaction: if any transaction |
189 // fails, all transactions open will also be rolled back. Any nested | 209 // fails, all transactions open will also be rolled back. Any nested |
190 // transactions after one has rolled back will return fail for Begin(). If | 210 // transactions after one has rolled back will return fail for Begin(). If |
191 // Begin() fails, you must not call Commit or Rollback(). | 211 // Begin() fails, you must not call Commit or Rollback(). |
192 // | 212 // |
193 // Normally you should use sql::Transaction to manage a transaction, which | 213 // Normally you should use sql::Transaction to manage a transaction, which |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 // This object handles errors resulting from all forms of executing sqlite | 421 // This object handles errors resulting from all forms of executing sqlite |
402 // commands or statements. It can be null which means default handling. | 422 // commands or statements. It can be null which means default handling. |
403 scoped_refptr<ErrorDelegate> error_delegate_; | 423 scoped_refptr<ErrorDelegate> error_delegate_; |
404 | 424 |
405 DISALLOW_COPY_AND_ASSIGN(Connection); | 425 DISALLOW_COPY_AND_ASSIGN(Connection); |
406 }; | 426 }; |
407 | 427 |
408 } // namespace sql | 428 } // namespace sql |
409 | 429 |
410 #endif // SQL_CONNECTION_H_ | 430 #endif // SQL_CONNECTION_H_ |
OLD | NEW |