| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 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 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // | 241 // |
| 242 // For DatabaseBackend, we open the SQLite database on the DatabaseThread, | 242 // For DatabaseBackend, we open the SQLite database on the DatabaseThread, |
| 243 // and hence we should also close it on that same thread. This means that th
e | 243 // and hence we should also close it on that same thread. This means that th
e |
| 244 // SQLite database need to be closed by another mechanism (see | 244 // SQLite database need to be closed by another mechanism (see |
| 245 // DatabaseContext::stopDatabases()). By the time we get here, the SQLite | 245 // DatabaseContext::stopDatabases()). By the time we get here, the SQLite |
| 246 // database should have already been closed. | 246 // database should have already been closed. |
| 247 | 247 |
| 248 ASSERT(!m_opened); | 248 ASSERT(!m_opened); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void DatabaseBackendBase::trace(Visitor*) | 251 void DatabaseBackendBase::trace(Visitor* visitor) |
| 252 { | 252 { |
| 253 visitor->trace(m_databaseAuthorizer); |
| 253 } | 254 } |
| 254 | 255 |
| 255 void DatabaseBackendBase::closeDatabase() | 256 void DatabaseBackendBase::closeDatabase() |
| 256 { | 257 { |
| 257 if (!m_opened) | 258 if (!m_opened) |
| 258 return; | 259 return; |
| 259 | 260 |
| 260 m_sqliteDatabase.close(); | 261 m_sqliteDatabase.close(); |
| 261 m_opened = false; | 262 m_opened = false; |
| 262 databaseContext()->didCloseDatabase(*this); | 263 databaseContext()->didCloseDatabase(*this); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // If the expected version isn't the empty string, ensure that the current d
atabase version we have matches that version. Otherwise, set an exception. | 406 // If the expected version isn't the empty string, ensure that the current d
atabase version we have matches that version. Otherwise, set an exception. |
| 406 // If the expected version is the empty string, then we always return with w
hatever version of the database we have. | 407 // If the expected version is the empty string, then we always return with w
hatever version of the database we have. |
| 407 if ((!m_new || shouldSetVersionInNewDatabase) && m_expectedVersion.length()
&& m_expectedVersion != currentVersion) { | 408 if ((!m_new || shouldSetVersionInNewDatabase) && m_expectedVersion.length()
&& m_expectedVersion != currentVersion) { |
| 408 reportOpenDatabaseResult(6, InvalidStateError, 0); | 409 reportOpenDatabaseResult(6, InvalidStateError, 0); |
| 409 errorMessage = "unable to open database, version mismatch, '" + m_expect
edVersion + "' does not match the currentVersion of '" + currentVersion + "'"; | 410 errorMessage = "unable to open database, version mismatch, '" + m_expect
edVersion + "' does not match the currentVersion of '" + currentVersion + "'"; |
| 410 m_sqliteDatabase.close(); | 411 m_sqliteDatabase.close(); |
| 411 return false; | 412 return false; |
| 412 } | 413 } |
| 413 | 414 |
| 414 ASSERT(m_databaseAuthorizer); | 415 ASSERT(m_databaseAuthorizer); |
| 415 m_sqliteDatabase.setAuthorizer(m_databaseAuthorizer); | 416 m_sqliteDatabase.setAuthorizer(m_databaseAuthorizer.get()); |
| 416 | 417 |
| 417 databaseContext()->didOpenDatabase(*this); | 418 databaseContext()->didOpenDatabase(*this); |
| 418 // See comment at the top this file regarding calling addOpenDatabase(). | 419 // See comment at the top this file regarding calling addOpenDatabase(). |
| 419 DatabaseTracker::tracker().addOpenDatabase(this); | 420 DatabaseTracker::tracker().addOpenDatabase(this); |
| 420 m_opened = true; | 421 m_opened = true; |
| 421 | 422 |
| 422 // Declare success: | 423 // Declare success: |
| 423 error = DatabaseError::None; // Clear the presumed error from above. | 424 error = DatabaseError::None; // Clear the presumed error from above. |
| 424 onExitCaller.setOpenSucceeded(); | 425 onExitCaller.setOpenSucceeded(); |
| 425 | 426 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 { | 664 { |
| 664 executionContext()->addConsoleMessage(StorageMessageSource, ErrorMessageLeve
l, message); | 665 executionContext()->addConsoleMessage(StorageMessageSource, ErrorMessageLeve
l, message); |
| 665 } | 666 } |
| 666 | 667 |
| 667 ExecutionContext* DatabaseBackendBase::executionContext() const | 668 ExecutionContext* DatabaseBackendBase::executionContext() const |
| 668 { | 669 { |
| 669 return databaseContext()->executionContext(); | 670 return databaseContext()->executionContext(); |
| 670 } | 671 } |
| 671 | 672 |
| 672 } // namespace WebCore | 673 } // namespace WebCore |
| OLD | NEW |