This source file includes following definitions.
- openDatabase
- openDatabaseSync
#include "config.h"
#include "modules/webdatabase/WorkerGlobalScopeWebDatabase.h"
#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/workers/WorkerGlobalScope.h"
#include "modules/webdatabase/Database.h"
#include "modules/webdatabase/DatabaseCallback.h"
#include "modules/webdatabase/DatabaseManager.h"
#include "modules/webdatabase/DatabaseSync.h"
#include "platform/weborigin/SecurityOrigin.h"
namespace WebCore {
PassRefPtrWillBeRawPtr<Database> WorkerGlobalScopeWebDatabase::openDatabase(WorkerGlobalScope& context, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, ExceptionState& exceptionState)
{
DatabaseManager& dbManager = DatabaseManager::manager();
RefPtrWillBeRawPtr<Database> database = nullptr;
DatabaseError error = DatabaseError::None;
if (RuntimeEnabledFeatures::databaseEnabled() && context.securityOrigin()->canAccessDatabase()) {
String errorMessage;
database = dbManager.openDatabase(&context, name, version, displayName, estimatedSize, creationCallback, error, errorMessage);
ASSERT(database || error != DatabaseError::None);
if (error != DatabaseError::None)
DatabaseManager::throwExceptionForDatabaseError(error, errorMessage, exceptionState);
} else {
exceptionState.throwSecurityError("Access to the WebDatabase API is denied in this context.");
}
return database.release();
}
PassRefPtrWillBeRawPtr<DatabaseSync> WorkerGlobalScopeWebDatabase::openDatabaseSync(WorkerGlobalScope& context, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, ExceptionState& exceptionState)
{
DatabaseManager& dbManager = DatabaseManager::manager();
RefPtrWillBeRawPtr<DatabaseSync> database = nullptr;
DatabaseError error = DatabaseError::None;
if (RuntimeEnabledFeatures::databaseEnabled() && context.securityOrigin()->canAccessDatabase()) {
String errorMessage;
database = dbManager.openDatabaseSync(&context, name, version, displayName, estimatedSize, creationCallback, error, errorMessage);
ASSERT(database || error != DatabaseError::None);
if (error != DatabaseError::None)
DatabaseManager::throwExceptionForDatabaseError(error, errorMessage, exceptionState);
} else {
exceptionState.throwSecurityError("Access to the WebDatabase API is denied in this context.");
}
return database.release();
}
}