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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 : m_databaseContextRegisteredCount(0) | 68 : m_databaseContextRegisteredCount(0) |
69 , m_databaseContextInstanceCount(0) | 69 , m_databaseContextInstanceCount(0) |
70 #endif | 70 #endif |
71 { | 71 { |
72 } | 72 } |
73 | 73 |
74 DatabaseManager::~DatabaseManager() | 74 DatabaseManager::~DatabaseManager() |
75 { | 75 { |
76 } | 76 } |
77 | 77 |
78 class DatabaseCreationCallbackTask final : public ExecutionContextTask { | 78 static void databaseCallbackHandleEvent(DatabaseCallback* callback, Database* da tabase) |
hiroshige
2016/06/26 10:42:37
This is just for ignoring DatabaseCallback::handle
tzik
2016/06/26 14:16:50
Could you leave that as a comment?
hiroshige
2016/06/27 07:28:38
Done.
| |
79 public: | 79 { |
80 static std::unique_ptr<DatabaseCreationCallbackTask> create(Database* databa se, DatabaseCallback* creationCallback) | 80 callback->handleEvent(database); |
81 { | 81 } |
82 return wrapUnique(new DatabaseCreationCallbackTask(database, creationCal lback)); | |
83 } | |
84 | |
85 void performTask(ExecutionContext*) override | |
86 { | |
87 m_creationCallback->handleEvent(m_database.get()); | |
88 } | |
89 | |
90 private: | |
91 DatabaseCreationCallbackTask(Database* database, DatabaseCallback* callback) | |
92 : m_database(database) | |
93 , m_creationCallback(callback) | |
94 { | |
95 } | |
96 | |
97 Persistent<Database> m_database; | |
98 Persistent<DatabaseCallback> m_creationCallback; | |
99 }; | |
100 | 82 |
101 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c ontext) | 83 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c ontext) |
102 { | 84 { |
103 ASSERT(m_databaseContextRegisteredCount >= 0); | 85 ASSERT(m_databaseContextRegisteredCount >= 0); |
104 ASSERT(m_databaseContextInstanceCount >= 0); | 86 ASSERT(m_databaseContextInstanceCount >= 0); |
105 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); | 87 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); |
106 return m_contextMap.get(context); | 88 return m_contextMap.get(context); |
107 } | 89 } |
108 | 90 |
109 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) | 91 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 Database* database = openDatabaseInternal(context, name, | 189 Database* database = openDatabaseInternal(context, name, |
208 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er ror, errorMessage); | 190 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er ror, errorMessage); |
209 if (!database) | 191 if (!database) |
210 return nullptr; | 192 return nullptr; |
211 | 193 |
212 databaseContextFor(context)->setHasOpenDatabases(); | 194 databaseContextFor(context)->setHasOpenDatabases(); |
213 DatabaseClient::from(context)->didOpenDatabase(database, context->getSecurit yOrigin()->host(), name, expectedVersion); | 195 DatabaseClient::from(context)->didOpenDatabase(database, context->getSecurit yOrigin()->host(), name, expectedVersion); |
214 | 196 |
215 if (database->isNew() && creationCallback) { | 197 if (database->isNew() && creationCallback) { |
216 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas e %p\n", database); | 198 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas e %p\n", database); |
217 database->getExecutionContext()->postTask(BLINK_FROM_HERE, DatabaseCreat ionCallbackTask::create(database, creationCallback), "openDatabase"); | 199 database->getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThr eadTask(&databaseCallbackHandleEvent, wrapPersistent(creationCallback), wrapPers istent(database)), "openDatabase"); |
218 } | 200 } |
219 | 201 |
220 ASSERT(database); | 202 ASSERT(database); |
221 return database; | 203 return database; |
222 } | 204 } |
223 | 205 |
224 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String & name, bool createIfDoesNotExist) | 206 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String & name, bool createIfDoesNotExist) |
225 { | 207 { |
226 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf DoesNotExist); | 208 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf DoesNotExist); |
227 } | 209 } |
228 | 210 |
229 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m essage) | 211 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m essage) |
230 { | 212 { |
231 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro rMessageLevel, message)); | 213 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro rMessageLevel, message)); |
232 } | 214 } |
233 | 215 |
234 } // namespace blink | 216 } // namespace blink |
OLD | NEW |