| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 DCHECK(isMainThread()); | 229 DCHECK(isMainThread()); |
| 230 m_contextThreadSecurityOrigin = | 230 m_contextThreadSecurityOrigin = |
| 231 m_databaseContext->getSecurityOrigin()->isolatedCopy(); | 231 m_databaseContext->getSecurityOrigin()->isolatedCopy(); |
| 232 | 232 |
| 233 m_databaseAuthorizer = DatabaseAuthorizer::create(infoTableName); | 233 m_databaseAuthorizer = DatabaseAuthorizer::create(infoTableName); |
| 234 | 234 |
| 235 if (m_name.isNull()) | 235 if (m_name.isNull()) |
| 236 m_name = ""; | 236 m_name = ""; |
| 237 | 237 |
| 238 { | 238 { |
| 239 SafePointAwareMutexLocker locker(guidMutex()); | 239 MutexLocker locker(guidMutex()); |
| 240 m_guid = guidForOriginAndName(getSecurityOrigin()->toString(), name); | 240 m_guid = guidForOriginAndName(getSecurityOrigin()->toString(), name); |
| 241 guidCount().add(m_guid); | 241 guidCount().add(m_guid); |
| 242 } | 242 } |
| 243 | 243 |
| 244 m_filename = DatabaseManager::manager().fullPathForDatabase( | 244 m_filename = DatabaseManager::manager().fullPathForDatabase( |
| 245 getSecurityOrigin(), m_name); | 245 getSecurityOrigin(), m_name); |
| 246 | 246 |
| 247 m_databaseThreadSecurityOrigin = | 247 m_databaseThreadSecurityOrigin = |
| 248 m_contextThreadSecurityOrigin->isolatedCopy(); | 248 m_contextThreadSecurityOrigin->isolatedCopy(); |
| 249 ASSERT(m_databaseContext->databaseThread()); | 249 ASSERT(m_databaseContext->databaseThread()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 void Database::closeDatabase() { | 383 void Database::closeDatabase() { |
| 384 if (!m_opened) | 384 if (!m_opened) |
| 385 return; | 385 return; |
| 386 | 386 |
| 387 releaseStore(&m_opened, 0); | 387 releaseStore(&m_opened, 0); |
| 388 m_sqliteDatabase.close(); | 388 m_sqliteDatabase.close(); |
| 389 // See comment at the top this file regarding calling removeOpenDatabase(). | 389 // See comment at the top this file regarding calling removeOpenDatabase(). |
| 390 DatabaseTracker::tracker().removeOpenDatabase(this); | 390 DatabaseTracker::tracker().removeOpenDatabase(this); |
| 391 { | 391 { |
| 392 SafePointAwareMutexLocker locker(guidMutex()); | 392 MutexLocker locker(guidMutex()); |
| 393 | 393 |
| 394 ASSERT(guidCount().contains(m_guid)); | 394 ASSERT(guidCount().contains(m_guid)); |
| 395 if (guidCount().remove(m_guid)) { | 395 if (guidCount().remove(m_guid)) { |
| 396 guidToVersionMap().erase(m_guid); | 396 guidToVersionMap().erase(m_guid); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 String Database::version() const { | 401 String Database::version() const { |
| 402 // Note: In multi-process browsers the cached value may be accurate, but we | 402 // Note: In multi-process browsers the cached value may be accurate, but we |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 447 } |
| 448 if (!m_sqliteDatabase.turnOnIncrementalAutoVacuum()) | 448 if (!m_sqliteDatabase.turnOnIncrementalAutoVacuum()) |
| 449 DLOG(ERROR) << "Unable to turn on incremental auto-vacuum (" | 449 DLOG(ERROR) << "Unable to turn on incremental auto-vacuum (" |
| 450 << m_sqliteDatabase.lastError() << " " | 450 << m_sqliteDatabase.lastError() << " " |
| 451 << m_sqliteDatabase.lastErrorMsg() << ")"; | 451 << m_sqliteDatabase.lastErrorMsg() << ")"; |
| 452 | 452 |
| 453 m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime); | 453 m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime); |
| 454 | 454 |
| 455 String currentVersion; | 455 String currentVersion; |
| 456 { | 456 { |
| 457 SafePointAwareMutexLocker locker(guidMutex()); | 457 MutexLocker locker(guidMutex()); |
| 458 | 458 |
| 459 GuidVersionMap::iterator entry = guidToVersionMap().find(m_guid); | 459 GuidVersionMap::iterator entry = guidToVersionMap().find(m_guid); |
| 460 if (entry != guidToVersionMap().end()) { | 460 if (entry != guidToVersionMap().end()) { |
| 461 // Map null string to empty string (see updateGuidVersionMap()). | 461 // Map null string to empty string (see updateGuidVersionMap()). |
| 462 currentVersion = | 462 currentVersion = |
| 463 entry->value.isNull() ? emptyString : entry->value.isolatedCopy(); | 463 entry->value.isNull() ? emptyString : entry->value.isolatedCopy(); |
| 464 STORAGE_DVLOG(1) << "Current cached version for guid " << m_guid << " is " | 464 STORAGE_DVLOG(1) << "Current cached version for guid " << m_guid << " is " |
| 465 << currentVersion; | 465 << currentVersion; |
| 466 | 466 |
| 467 // Note: In multi-process browsers the cached value may be | 467 // Note: In multi-process browsers the cached value may be |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 m_databaseAuthorizer->enable(); | 661 m_databaseAuthorizer->enable(); |
| 662 | 662 |
| 663 return result; | 663 return result; |
| 664 } | 664 } |
| 665 | 665 |
| 666 void Database::setExpectedVersion(const String& version) { | 666 void Database::setExpectedVersion(const String& version) { |
| 667 m_expectedVersion = version.isolatedCopy(); | 667 m_expectedVersion = version.isolatedCopy(); |
| 668 } | 668 } |
| 669 | 669 |
| 670 String Database::getCachedVersion() const { | 670 String Database::getCachedVersion() const { |
| 671 SafePointAwareMutexLocker locker(guidMutex()); | 671 MutexLocker locker(guidMutex()); |
| 672 return guidToVersionMap().get(m_guid).isolatedCopy(); | 672 return guidToVersionMap().get(m_guid).isolatedCopy(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 void Database::setCachedVersion(const String& actualVersion) { | 675 void Database::setCachedVersion(const String& actualVersion) { |
| 676 // Update the in memory database version map. | 676 // Update the in memory database version map. |
| 677 SafePointAwareMutexLocker locker(guidMutex()); | 677 MutexLocker locker(guidMutex()); |
| 678 updateGuidVersionMap(m_guid, actualVersion); | 678 updateGuidVersionMap(m_guid, actualVersion); |
| 679 } | 679 } |
| 680 | 680 |
| 681 bool Database::getActualVersionForTransaction(String& actualVersion) { | 681 bool Database::getActualVersionForTransaction(String& actualVersion) { |
| 682 ASSERT(m_sqliteDatabase.transactionInProgress()); | 682 ASSERT(m_sqliteDatabase.transactionInProgress()); |
| 683 // Note: In multi-process browsers the cached value may be inaccurate. So we | 683 // Note: In multi-process browsers the cached value may be inaccurate. So we |
| 684 // retrieve the value from the database and update the cached value here. | 684 // retrieve the value from the database and update the cached value here. |
| 685 return getVersionFromDatabase(actualVersion, true); | 685 return getVersionFromDatabase(actualVersion, true); |
| 686 } | 686 } |
| 687 | 687 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 if (getDatabaseContext()->databaseThread()->isDatabaseThread()) | 946 if (getDatabaseContext()->databaseThread()->isDatabaseThread()) |
| 947 return m_databaseThreadSecurityOrigin.get(); | 947 return m_databaseThreadSecurityOrigin.get(); |
| 948 return nullptr; | 948 return nullptr; |
| 949 } | 949 } |
| 950 | 950 |
| 951 bool Database::opened() { | 951 bool Database::opened() { |
| 952 return static_cast<bool>(acquireLoad(&m_opened)); | 952 return static_cast<bool>(acquireLoad(&m_opened)); |
| 953 } | 953 } |
| 954 | 954 |
| 955 } // namespace blink | 955 } // namespace blink |
| OLD | NEW |