| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 RefPtr<DatabaseBackendBase> backend = m_server->openDatabase(backendContext,
type, name, expectedVersion, | 192 RefPtr<DatabaseBackendBase> backend = m_server->openDatabase(backendContext,
type, name, expectedVersion, |
| 193 displayName, estimatedSize, setVersionInNewDatabase, error, errorMessage
); | 193 displayName, estimatedSize, setVersionInNewDatabase, error, errorMessage
); |
| 194 | 194 |
| 195 if (!backend) { | 195 if (!backend) { |
| 196 ASSERT(error != DatabaseError::None); | 196 ASSERT(error != DatabaseError::None); |
| 197 | 197 |
| 198 switch (error) { | 198 switch (error) { |
| 199 case DatabaseError::GenericSecurityError: | 199 case DatabaseError::GenericSecurityError: |
| 200 logOpenDatabaseError(context, name); | 200 logOpenDatabaseError(context, name); |
| 201 return 0; | 201 return nullptr; |
| 202 | 202 |
| 203 case DatabaseError::InvalidDatabaseState: | 203 case DatabaseError::InvalidDatabaseState: |
| 204 logErrorMessage(context, errorMessage); | 204 logErrorMessage(context, errorMessage); |
| 205 return 0; | 205 return nullptr; |
| 206 | 206 |
| 207 default: | 207 default: |
| 208 ASSERT_NOT_REACHED(); | 208 ASSERT_NOT_REACHED(); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 return backend.release(); | 212 return backend.release(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 PassRefPtr<Database> DatabaseManager::openDatabase(ExecutionContext* context, | 215 PassRefPtr<Database> DatabaseManager::openDatabase(ExecutionContext* context, |
| 216 const String& name, const String& expectedVersion, const String& displayName
, | 216 const String& name, const String& expectedVersion, const String& displayName
, |
| 217 unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, | 217 unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, |
| 218 DatabaseError& error, String& errorMessage) | 218 DatabaseError& error, String& errorMessage) |
| 219 { | 219 { |
| 220 ASSERT(error == DatabaseError::None); | 220 ASSERT(error == DatabaseError::None); |
| 221 | 221 |
| 222 bool setVersionInNewDatabase = !creationCallback; | 222 bool setVersionInNewDatabase = !creationCallback; |
| 223 RefPtr<DatabaseBackendBase> backend = openDatabaseBackend(context, DatabaseT
ype::Async, name, | 223 RefPtr<DatabaseBackendBase> backend = openDatabaseBackend(context, DatabaseT
ype::Async, name, |
| 224 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); | 224 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); |
| 225 if (!backend) | 225 if (!backend) |
| 226 return 0; | 226 return nullptr; |
| 227 | 227 |
| 228 RefPtr<Database> database = Database::create(context, backend); | 228 RefPtr<Database> database = Database::create(context, backend); |
| 229 | 229 |
| 230 RefPtr<DatabaseContext> databaseContext = databaseContextFor(context); | 230 RefPtr<DatabaseContext> databaseContext = databaseContextFor(context); |
| 231 databaseContext->setHasOpenDatabases(); | 231 databaseContext->setHasOpenDatabases(); |
| 232 DatabaseClient::from(context)->didOpenDatabase(database, context->securityOr
igin()->host(), name, expectedVersion); | 232 DatabaseClient::from(context)->didOpenDatabase(database, context->securityOr
igin()->host(), name, expectedVersion); |
| 233 | 233 |
| 234 if (backend->isNew() && creationCallback.get()) { | 234 if (backend->isNew() && creationCallback.get()) { |
| 235 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas
e %p\n", database.get()); | 235 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas
e %p\n", database.get()); |
| 236 database->m_executionContext->postTask(DatabaseCreationCallbackTask::cre
ate(database, creationCallback)); | 236 database->m_executionContext->postTask(DatabaseCreationCallbackTask::cre
ate(database, creationCallback)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 ASSERT(database); | 239 ASSERT(database); |
| 240 return database.release(); | 240 return database.release(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 PassRefPtr<DatabaseSync> DatabaseManager::openDatabaseSync(ExecutionContext* con
text, | 243 PassRefPtr<DatabaseSync> DatabaseManager::openDatabaseSync(ExecutionContext* con
text, |
| 244 const String& name, const String& expectedVersion, const String& displayName
, | 244 const String& name, const String& expectedVersion, const String& displayName
, |
| 245 unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, | 245 unsigned long estimatedSize, PassOwnPtr<DatabaseCallback> creationCallback, |
| 246 DatabaseError& error, String& errorMessage) | 246 DatabaseError& error, String& errorMessage) |
| 247 { | 247 { |
| 248 ASSERT(context->isContextThread()); | 248 ASSERT(context->isContextThread()); |
| 249 ASSERT(error == DatabaseError::None); | 249 ASSERT(error == DatabaseError::None); |
| 250 | 250 |
| 251 bool setVersionInNewDatabase = !creationCallback; | 251 bool setVersionInNewDatabase = !creationCallback; |
| 252 RefPtr<DatabaseBackendBase> backend = openDatabaseBackend(context, DatabaseT
ype::Sync, name, | 252 RefPtr<DatabaseBackendBase> backend = openDatabaseBackend(context, DatabaseT
ype::Sync, name, |
| 253 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); | 253 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); |
| 254 if (!backend) | 254 if (!backend) |
| 255 return 0; | 255 return nullptr; |
| 256 | 256 |
| 257 RefPtr<DatabaseSync> database = DatabaseSync::create(context, backend); | 257 RefPtr<DatabaseSync> database = DatabaseSync::create(context, backend); |
| 258 | 258 |
| 259 if (backend->isNew() && creationCallback.get()) { | 259 if (backend->isNew() && creationCallback.get()) { |
| 260 WTF_LOG(StorageAPI, "Invoking the creation callback for database %p\n",
database.get()); | 260 WTF_LOG(StorageAPI, "Invoking the creation callback for database %p\n",
database.get()); |
| 261 creationCallback->handleEvent(database.get()); | 261 creationCallback->handleEvent(database.get()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 ASSERT(database); | 264 ASSERT(database); |
| 265 return database.release(); | 265 return database.release(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 289 if (databaseContext) | 289 if (databaseContext) |
| 290 m_server->interruptAllDatabasesForContext(databaseContext->backend().get
()); | 290 m_server->interruptAllDatabasesForContext(databaseContext->backend().get
()); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) | 293 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) |
| 294 { | 294 { |
| 295 context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message)
; | 295 context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message)
; |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace WebCore | 298 } // namespace WebCore |
| OLD | NEW |