| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) | 114 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) |
| 115 { | 115 { |
| 116 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context)) | 116 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context)) |
| 117 return databaseContext; | 117 return databaseContext; |
| 118 return DatabaseContext::create(context); | 118 return DatabaseContext::create(context); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext) | 121 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext) |
| 122 { | 122 { |
| 123 ExecutionContext* context = databaseContext->executionContext(); | 123 ExecutionContext* context = databaseContext->getExecutionContext(); |
| 124 m_contextMap.set(context, databaseContext); | 124 m_contextMap.set(context, databaseContext); |
| 125 #if ENABLE(ASSERT) | 125 #if ENABLE(ASSERT) |
| 126 m_databaseContextRegisteredCount++; | 126 m_databaseContextRegisteredCount++; |
| 127 #endif | 127 #endif |
| 128 } | 128 } |
| 129 | 129 |
| 130 void DatabaseManager::unregisterDatabaseContext(DatabaseContext* databaseContext
) | 130 void DatabaseManager::unregisterDatabaseContext(DatabaseContext* databaseContext
) |
| 131 { | 131 { |
| 132 ExecutionContext* context = databaseContext->executionContext(); | 132 ExecutionContext* context = databaseContext->getExecutionContext(); |
| 133 ASSERT(m_contextMap.get(context)); | 133 ASSERT(m_contextMap.get(context)); |
| 134 #if ENABLE(ASSERT) | 134 #if ENABLE(ASSERT) |
| 135 m_databaseContextRegisteredCount--; | 135 m_databaseContextRegisteredCount--; |
| 136 #endif | 136 #endif |
| 137 m_contextMap.remove(context); | 137 m_contextMap.remove(context); |
| 138 } | 138 } |
| 139 | 139 |
| 140 #if ENABLE(ASSERT) | 140 #if ENABLE(ASSERT) |
| 141 void DatabaseManager::didConstructDatabaseContext() | 141 void DatabaseManager::didConstructDatabaseContext() |
| 142 { | 142 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 162 exceptionState.throwDOMException(InvalidStateError, errorMessage); | 162 exceptionState.throwDOMException(InvalidStateError, errorMessage); |
| 163 return; | 163 return; |
| 164 default: | 164 default: |
| 165 ASSERT_NOT_REACHED(); | 165 ASSERT_NOT_REACHED(); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 static void logOpenDatabaseError(ExecutionContext* context, const String& name) | 169 static void logOpenDatabaseError(ExecutionContext* context, const String& name) |
| 170 { | 170 { |
| 171 WTF_LOG(StorageAPI, "Database %s for origin %s not allowed to be established
", name.ascii().data(), | 171 WTF_LOG(StorageAPI, "Database %s for origin %s not allowed to be established
", name.ascii().data(), |
| 172 context->securityOrigin()->toString().ascii().data()); | 172 context->getSecurityOrigin()->toString().ascii().data()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 Database* DatabaseManager::openDatabaseInternal(ExecutionContext* context, | 175 Database* DatabaseManager::openDatabaseInternal(ExecutionContext* context, |
| 176 const String& name, const String& expectedVersion, const String& displayName
, | 176 const String& name, const String& expectedVersion, const String& displayName
, |
| 177 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError& er
ror, String& errorMessage) | 177 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError& er
ror, String& errorMessage) |
| 178 { | 178 { |
| 179 ASSERT(error == DatabaseError::None); | 179 ASSERT(error == DatabaseError::None); |
| 180 | 180 |
| 181 DatabaseContext* backendContext = databaseContextFor(context)->backend(); | 181 DatabaseContext* backendContext = databaseContextFor(context)->backend(); |
| 182 if (DatabaseTracker::tracker().canEstablishDatabase(backendContext, name, di
splayName, estimatedSize, error)) { | 182 if (DatabaseTracker::tracker().canEstablishDatabase(backendContext, name, di
splayName, estimatedSize, error)) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 208 { | 208 { |
| 209 ASSERT(error == DatabaseError::None); | 209 ASSERT(error == DatabaseError::None); |
| 210 | 210 |
| 211 bool setVersionInNewDatabase = !creationCallback; | 211 bool setVersionInNewDatabase = !creationCallback; |
| 212 Database* database = openDatabaseInternal(context, name, | 212 Database* database = openDatabaseInternal(context, name, |
| 213 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); | 213 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); |
| 214 if (!database) | 214 if (!database) |
| 215 return nullptr; | 215 return nullptr; |
| 216 | 216 |
| 217 databaseContextFor(context)->setHasOpenDatabases(); | 217 databaseContextFor(context)->setHasOpenDatabases(); |
| 218 DatabaseClient::from(context)->didOpenDatabase(database, context->securityOr
igin()->host(), name, expectedVersion); | 218 DatabaseClient::from(context)->didOpenDatabase(database, context->getSecurit
yOrigin()->host(), name, expectedVersion); |
| 219 | 219 |
| 220 if (database->isNew() && creationCallback) { | 220 if (database->isNew() && creationCallback) { |
| 221 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas
e %p\n", database); | 221 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas
e %p\n", database); |
| 222 database->executionContext()->postTask(BLINK_FROM_HERE, DatabaseCreation
CallbackTask::create(database, creationCallback)); | 222 database->getExecutionContext()->postTask(BLINK_FROM_HERE, DatabaseCreat
ionCallbackTask::create(database, creationCallback)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 ASSERT(database); | 225 ASSERT(database); |
| 226 return database; | 226 return database; |
| 227 } | 227 } |
| 228 | 228 |
| 229 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String
& name, bool createIfDoesNotExist) | 229 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String
& name, bool createIfDoesNotExist) |
| 230 { | 230 { |
| 231 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf
DoesNotExist); | 231 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf
DoesNotExist); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) | 234 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) |
| 235 { | 235 { |
| 236 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro
rMessageLevel, message)); | 236 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro
rMessageLevel, message)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace blink | 239 } // namespace blink |
| OLD | NEW |