| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #endif | 59 #endif |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 DatabaseManager::~DatabaseManager() | 63 DatabaseManager::~DatabaseManager() |
| 64 { | 64 { |
| 65 } | 65 } |
| 66 | 66 |
| 67 class DatabaseCreationCallbackTask FINAL : public ExecutionContextTask { | 67 class DatabaseCreationCallbackTask FINAL : public ExecutionContextTask { |
| 68 public: | 68 public: |
| 69 static PassOwnPtr<DatabaseCreationCallbackTask> create(PassRefPtrWillBeRawPt
r<Database> database, PassOwnPtrWillBeRawPtr<DatabaseCallback> creationCallback) | 69 static PassOwnPtr<DatabaseCreationCallbackTask> create(PassRefPtrWillBeRawPt
r<Database> database, DatabaseCallback* creationCallback) |
| 70 { | 70 { |
| 71 return adoptPtr(new DatabaseCreationCallbackTask(database, creationCallb
ack)); | 71 return adoptPtr(new DatabaseCreationCallbackTask(database, creationCallb
ack)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void performTask(ExecutionContext*) OVERRIDE | 74 virtual void performTask(ExecutionContext*) OVERRIDE |
| 75 { | 75 { |
| 76 m_creationCallback->handleEvent(m_database.get()); | 76 m_creationCallback->handleEvent(m_database.get()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 DatabaseCreationCallbackTask(PassRefPtrWillBeRawPtr<Database> database, Pass
OwnPtrWillBeRawPtr<DatabaseCallback> callback) | 80 DatabaseCreationCallbackTask(PassRefPtrWillBeRawPtr<Database> database, Data
baseCallback* callback) |
| 81 : m_database(database) | 81 : m_database(database) |
| 82 , m_creationCallback(callback) | 82 , m_creationCallback(callback) |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 | 85 |
| 86 RefPtrWillBePersistent<Database> m_database; | 86 RefPtrWillBePersistent<Database> m_database; |
| 87 OwnPtrWillBePersistent<DatabaseCallback> m_creationCallback; | 87 Persistent<DatabaseCallback> m_creationCallback; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c
ontext) | 90 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c
ontext) |
| 91 { | 91 { |
| 92 ASSERT(m_databaseContextRegisteredCount >= 0); | 92 ASSERT(m_databaseContextRegisteredCount >= 0); |
| 93 ASSERT(m_databaseContextInstanceCount >= 0); | 93 ASSERT(m_databaseContextInstanceCount >= 0); |
| 94 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); | 94 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); |
| 95 return m_contextMap.get(context); | 95 return m_contextMap.get(context); |
| 96 } | 96 } |
| 97 | 97 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return nullptr; | 183 return nullptr; |
| 184 | 184 |
| 185 default: | 185 default: |
| 186 ASSERT_NOT_REACHED(); | 186 ASSERT_NOT_REACHED(); |
| 187 } | 187 } |
| 188 return nullptr; | 188 return nullptr; |
| 189 } | 189 } |
| 190 | 190 |
| 191 PassRefPtrWillBeRawPtr<Database> DatabaseManager::openDatabase(ExecutionContext*
context, | 191 PassRefPtrWillBeRawPtr<Database> DatabaseManager::openDatabase(ExecutionContext*
context, |
| 192 const String& name, const String& expectedVersion, const String& displayName
, | 192 const String& name, const String& expectedVersion, const String& displayName
, |
| 193 unsigned long estimatedSize, PassOwnPtrWillBeRawPtr<DatabaseCallback> creati
onCallback, | 193 unsigned long estimatedSize, DatabaseCallback* creationCallback, |
| 194 DatabaseError& error, String& errorMessage) | 194 DatabaseError& error, String& errorMessage) |
| 195 { | 195 { |
| 196 ASSERT(error == DatabaseError::None); | 196 ASSERT(error == DatabaseError::None); |
| 197 | 197 |
| 198 bool setVersionInNewDatabase = !creationCallback; | 198 bool setVersionInNewDatabase = !creationCallback; |
| 199 RefPtrWillBeRawPtr<DatabaseBackend> backend = openDatabaseBackend(context, n
ame, | 199 RefPtrWillBeRawPtr<DatabaseBackend> backend = openDatabaseBackend(context, n
ame, |
| 200 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); | 200 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er
ror, errorMessage); |
| 201 if (!backend) | 201 if (!backend) |
| 202 return nullptr; | 202 return nullptr; |
| 203 | 203 |
| 204 RefPtrWillBeRawPtr<Database> database = Database::create(context, backend); | 204 RefPtrWillBeRawPtr<Database> database = Database::create(context, backend); |
| 205 | 205 |
| 206 databaseContextFor(context)->setHasOpenDatabases(); | 206 databaseContextFor(context)->setHasOpenDatabases(); |
| 207 DatabaseClient::from(context)->didOpenDatabase(database, context->securityOr
igin()->host(), name, expectedVersion); | 207 DatabaseClient::from(context)->didOpenDatabase(database, context->securityOr
igin()->host(), name, expectedVersion); |
| 208 | 208 |
| 209 if (backend->isNew() && creationCallback.get()) { | 209 if (backend->isNew() && creationCallback) { |
| 210 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas
e %p\n", database.get()); | 210 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas
e %p\n", database.get()); |
| 211 database->executionContext()->postTask(DatabaseCreationCallbackTask::cre
ate(database, creationCallback)); | 211 database->executionContext()->postTask(DatabaseCreationCallbackTask::cre
ate(database, creationCallback)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 ASSERT(database); | 214 ASSERT(database); |
| 215 return database.release(); | 215 return database.release(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String
& name, bool createIfDoesNotExist) | 218 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String
& name, bool createIfDoesNotExist) |
| 219 { | 219 { |
| 220 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf
DoesNotExist); | 220 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf
DoesNotExist); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) | 223 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) |
| 224 { | 224 { |
| 225 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro
rMessageLevel, message)); | 225 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro
rMessageLevel, message)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |