| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google 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 * 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "core/workers/WorkerGlobalScope.h" | 35 #include "core/workers/WorkerGlobalScope.h" |
| 36 #include "modules/webdatabase/Database.h" | 36 #include "modules/webdatabase/Database.h" |
| 37 #include "modules/webdatabase/DatabaseCallback.h" | 37 #include "modules/webdatabase/DatabaseCallback.h" |
| 38 #include "modules/webdatabase/DatabaseManager.h" | 38 #include "modules/webdatabase/DatabaseManager.h" |
| 39 #include "modules/webdatabase/DatabaseSync.h" | 39 #include "modules/webdatabase/DatabaseSync.h" |
| 40 #include "weborigin/SecurityOrigin.h" | 40 #include "weborigin/SecurityOrigin.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 PassRefPtr<Database> WorkerGlobalScopeWebDatabase::openDatabase(WorkerGlobalScop
e* context, const String& name, const String& version, const String& displayName
, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, Ex
ceptionState& es) | 44 PassRefPtr<Database> WorkerGlobalScopeWebDatabase::openDatabase(WorkerGlobalScop
e* context, const String& name, const String& version, const String& displayName
, unsigned estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, Excepti
onState& es) |
| 45 { | 45 { |
| 46 DatabaseManager& dbManager = DatabaseManager::manager(); | 46 DatabaseManager& dbManager = DatabaseManager::manager(); |
| 47 RefPtr<Database> database; | 47 RefPtr<Database> database; |
| 48 DatabaseError error = DatabaseError::None; | 48 DatabaseError error = DatabaseError::None; |
| 49 if (RuntimeEnabledFeatures::databaseEnabled() && context->securityOrigin()->
canAccessDatabase()) { | 49 if (RuntimeEnabledFeatures::databaseEnabled() && context->securityOrigin()->
canAccessDatabase()) { |
| 50 database = dbManager.openDatabase(context, name, version, displayName, e
stimatedSize, creationCallback, error); | 50 database = dbManager.openDatabase(context, name, version, displayName, e
stimatedSize, creationCallback, error); |
| 51 ASSERT(database || error != DatabaseError::None); | 51 ASSERT(database || error != DatabaseError::None); |
| 52 if (error != DatabaseError::None) | 52 if (error != DatabaseError::None) |
| 53 es.throwDOMException(DatabaseManager::exceptionCodeForDatabaseError(
error)); | 53 es.throwDOMException(DatabaseManager::exceptionCodeForDatabaseError(
error)); |
| 54 } else { | 54 } else { |
| 55 es.throwDOMException(SecurityError); | 55 es.throwDOMException(SecurityError); |
| 56 } | 56 } |
| 57 | 57 |
| 58 return database.release(); | 58 return database.release(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 PassRefPtr<DatabaseSync> WorkerGlobalScopeWebDatabase::openDatabaseSync(WorkerGl
obalScope* context, const String& name, const String& version, const String& dis
playName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCall
back, ExceptionState& es) | 61 PassRefPtr<DatabaseSync> WorkerGlobalScopeWebDatabase::openDatabaseSync(WorkerGl
obalScope* context, const String& name, const String& version, const String& dis
playName, unsigned estimatedSize, PassRefPtr<DatabaseCallback> creationCallback,
ExceptionState& es) |
| 62 { | 62 { |
| 63 DatabaseManager& dbManager = DatabaseManager::manager(); | 63 DatabaseManager& dbManager = DatabaseManager::manager(); |
| 64 RefPtr<DatabaseSync> database; | 64 RefPtr<DatabaseSync> database; |
| 65 DatabaseError error = DatabaseError::None; | 65 DatabaseError error = DatabaseError::None; |
| 66 if (RuntimeEnabledFeatures::databaseEnabled() && context->securityOrigin()->
canAccessDatabase()) { | 66 if (RuntimeEnabledFeatures::databaseEnabled() && context->securityOrigin()->
canAccessDatabase()) { |
| 67 database = dbManager.openDatabaseSync(context, name, version, displayNam
e, estimatedSize, creationCallback, error); | 67 database = dbManager.openDatabaseSync(context, name, version, displayNam
e, estimatedSize, creationCallback, error); |
| 68 ASSERT(database || error != DatabaseError::None); | 68 ASSERT(database || error != DatabaseError::None); |
| 69 if (error != DatabaseError::None) | 69 if (error != DatabaseError::None) |
| 70 es.throwDOMException(DatabaseManager::exceptionCodeForDatabaseError(
error)); | 70 es.throwDOMException(DatabaseManager::exceptionCodeForDatabaseError(
error)); |
| 71 } else { | 71 } else { |
| 72 es.throwDOMException(SecurityError); | 72 es.throwDOMException(SecurityError); |
| 73 } | 73 } |
| 74 | 74 |
| 75 return database.release(); | 75 return database.release(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace WebCore | 78 } // namespace WebCore |
| OLD | NEW |