OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 open_error_ = SQLITE_ERROR; | 114 open_error_ = SQLITE_ERROR; |
115 open_error_message_ = CString(); | 115 open_error_message_ = CString(); |
116 } | 116 } |
117 | 117 |
118 void SQLiteDatabase::SetMaximumSize(int64_t size) { | 118 void SQLiteDatabase::SetMaximumSize(int64_t size) { |
119 if (size < 0) | 119 if (size < 0) |
120 size = 0; | 120 size = 0; |
121 | 121 |
122 int current_page_size = PageSize(); | 122 int current_page_size = PageSize(); |
123 | 123 |
124 ASSERT(current_page_size || !db_); | 124 DCHECK(current_page_size || !db_); |
125 int64_t new_max_page_count = current_page_size ? size / current_page_size : 0; | 125 int64_t new_max_page_count = current_page_size ? size / current_page_size : 0; |
126 | 126 |
127 MutexLocker locker(authorizer_lock_); | 127 MutexLocker locker(authorizer_lock_); |
128 EnableAuthorizer(false); | 128 EnableAuthorizer(false); |
129 | 129 |
130 SQLiteStatement statement( | 130 SQLiteStatement statement( |
131 *this, "PRAGMA max_page_count = " + String::Number(new_max_page_count)); | 131 *this, "PRAGMA max_page_count = " + String::Number(new_max_page_count)); |
132 statement.Prepare(); | 132 statement.Prepare(); |
133 if (statement.Step() != kSQLResultRow) | 133 if (statement.Step() != kSQLResultRow) |
134 DLOG(ERROR) << "Failed to set maximum size of database to " << size | 134 DLOG(ERROR) << "Failed to set maximum size of database to " << size |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 : open_error_message_.Data(); | 254 : open_error_message_.Data(); |
255 } | 255 } |
256 | 256 |
257 int SQLiteDatabase::AuthorizerFunction(void* user_data, | 257 int SQLiteDatabase::AuthorizerFunction(void* user_data, |
258 int action_code, | 258 int action_code, |
259 const char* parameter1, | 259 const char* parameter1, |
260 const char* parameter2, | 260 const char* parameter2, |
261 const char* /*databaseName*/, | 261 const char* /*databaseName*/, |
262 const char* /*trigger_or_view*/) { | 262 const char* /*trigger_or_view*/) { |
263 DatabaseAuthorizer* auth = static_cast<DatabaseAuthorizer*>(user_data); | 263 DatabaseAuthorizer* auth = static_cast<DatabaseAuthorizer*>(user_data); |
264 ASSERT(auth); | 264 DCHECK(auth); |
265 | 265 |
266 switch (action_code) { | 266 switch (action_code) { |
267 case SQLITE_CREATE_INDEX: | 267 case SQLITE_CREATE_INDEX: |
268 return auth->CreateIndex(parameter1, parameter2); | 268 return auth->CreateIndex(parameter1, parameter2); |
269 case SQLITE_CREATE_TABLE: | 269 case SQLITE_CREATE_TABLE: |
270 return auth->CreateTable(parameter1); | 270 return auth->CreateTable(parameter1); |
271 case SQLITE_CREATE_TEMP_INDEX: | 271 case SQLITE_CREATE_TEMP_INDEX: |
272 return auth->CreateTempIndex(parameter1, parameter2); | 272 return auth->CreateTempIndex(parameter1, parameter2); |
273 case SQLITE_CREATE_TEMP_TABLE: | 273 case SQLITE_CREATE_TEMP_TABLE: |
274 return auth->CreateTempTable(parameter1); | 274 return auth->CreateTempTable(parameter1); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 case SQLITE_ANALYZE: | 322 case SQLITE_ANALYZE: |
323 return auth->AllowAnalyze(parameter1); | 323 return auth->AllowAnalyze(parameter1); |
324 case SQLITE_CREATE_VTABLE: | 324 case SQLITE_CREATE_VTABLE: |
325 return auth->CreateVTable(parameter1, parameter2); | 325 return auth->CreateVTable(parameter1, parameter2); |
326 case SQLITE_DROP_VTABLE: | 326 case SQLITE_DROP_VTABLE: |
327 return auth->DropVTable(parameter1, parameter2); | 327 return auth->DropVTable(parameter1, parameter2); |
328 case SQLITE_FUNCTION: | 328 case SQLITE_FUNCTION: |
329 return auth->AllowFunction(parameter2); | 329 return auth->AllowFunction(parameter2); |
330 #endif | 330 #endif |
331 default: | 331 default: |
332 ASSERT_NOT_REACHED(); | 332 NOTREACHED(); |
333 return kSQLAuthDeny; | 333 return kSQLAuthDeny; |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 void SQLiteDatabase::SetAuthorizer(DatabaseAuthorizer* auth) { | 337 void SQLiteDatabase::SetAuthorizer(DatabaseAuthorizer* auth) { |
338 if (!db_) { | 338 if (!db_) { |
339 NOTREACHED() << "Attempt to set an authorizer on a non-open SQL database"; | 339 NOTREACHED() << "Attempt to set an authorizer on a non-open SQL database"; |
340 return; | 340 return; |
341 } | 341 } |
342 | 342 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 default: | 386 default: |
387 if (!ExecuteCommand("PRAGMA auto_vacuum = 2")) | 387 if (!ExecuteCommand("PRAGMA auto_vacuum = 2")) |
388 return false; | 388 return false; |
389 RunVacuumCommand(); | 389 RunVacuumCommand(); |
390 error = LastError(); | 390 error = LastError(); |
391 return (error == SQLITE_OK); | 391 return (error == SQLITE_OK); |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 } // namespace blink | 395 } // namespace blink |
OLD | NEW |