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 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "modules/webdatabase/DatabaseManager.h" | 26 #include "modules/webdatabase/DatabaseManager.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionMessages.h" | 28 #include "bindings/core/v8/ExceptionMessages.h" |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
32 #include "core/dom/ExecutionContextTask.h" | |
33 #include "core/dom/TaskRunnerHelper.h" | 32 #include "core/dom/TaskRunnerHelper.h" |
34 #include "core/inspector/ConsoleMessage.h" | 33 #include "core/inspector/ConsoleMessage.h" |
| 34 #include "core/inspector/InspectorInstrumentation.h" |
35 #include "modules/webdatabase/Database.h" | 35 #include "modules/webdatabase/Database.h" |
36 #include "modules/webdatabase/DatabaseCallback.h" | 36 #include "modules/webdatabase/DatabaseCallback.h" |
37 #include "modules/webdatabase/DatabaseClient.h" | 37 #include "modules/webdatabase/DatabaseClient.h" |
38 #include "modules/webdatabase/DatabaseContext.h" | 38 #include "modules/webdatabase/DatabaseContext.h" |
39 #include "modules/webdatabase/DatabaseTask.h" | 39 #include "modules/webdatabase/DatabaseTask.h" |
40 #include "modules/webdatabase/DatabaseTracker.h" | 40 #include "modules/webdatabase/DatabaseTracker.h" |
41 #include "modules/webdatabase/StorageLog.h" | 41 #include "modules/webdatabase/StorageLog.h" |
42 #include "platform/weborigin/SecurityOrigin.h" | 42 #include "platform/weborigin/SecurityOrigin.h" |
43 #include "public/platform/WebTraceLocation.h" | 43 #include "public/platform/WebTraceLocation.h" |
44 #include "wtf/PtrUtil.h" | 44 #include "wtf/PtrUtil.h" |
(...skipping 11 matching lines...) Expand all Loading... |
56 | 56 |
57 DatabaseManager::DatabaseManager() | 57 DatabaseManager::DatabaseManager() |
58 { | 58 { |
59 } | 59 } |
60 | 60 |
61 DatabaseManager::~DatabaseManager() {} | 61 DatabaseManager::~DatabaseManager() {} |
62 | 62 |
63 // This is just for ignoring DatabaseCallback::handleEvent()'s return value. | 63 // This is just for ignoring DatabaseCallback::handleEvent()'s return value. |
64 static void databaseCallbackHandleEvent(DatabaseCallback* callback, | 64 static void databaseCallbackHandleEvent(DatabaseCallback* callback, |
65 Database* database) { | 65 Database* database) { |
| 66 InspectorInstrumentation::AsyncTask asyncTask(database->getExecutionContext(), |
| 67 callback); |
66 callback->handleEvent(database); | 68 callback->handleEvent(database); |
67 } | 69 } |
68 | 70 |
69 DatabaseContext* DatabaseManager::existingDatabaseContextFor( | 71 DatabaseContext* DatabaseManager::existingDatabaseContextFor( |
70 ExecutionContext* context) { | 72 ExecutionContext* context) { |
71 ASSERT(m_databaseContextRegisteredCount >= 0); | 73 ASSERT(m_databaseContextRegisteredCount >= 0); |
72 ASSERT(m_databaseContextInstanceCount >= 0); | 74 ASSERT(m_databaseContextInstanceCount >= 0); |
73 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); | 75 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); |
74 return m_contextMap.get(context); | 76 return m_contextMap.get(context); |
75 } | 77 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 if (!database) | 191 if (!database) |
190 return nullptr; | 192 return nullptr; |
191 | 193 |
192 databaseContextFor(context)->setHasOpenDatabases(); | 194 databaseContextFor(context)->setHasOpenDatabases(); |
193 DatabaseClient::from(context)->didOpenDatabase( | 195 DatabaseClient::from(context)->didOpenDatabase( |
194 database, context->getSecurityOrigin()->host(), name, expectedVersion); | 196 database, context->getSecurityOrigin()->host(), name, expectedVersion); |
195 | 197 |
196 if (database->isNew() && creationCallback) { | 198 if (database->isNew() && creationCallback) { |
197 STORAGE_DVLOG(1) << "Scheduling DatabaseCreationCallbackTask for database " | 199 STORAGE_DVLOG(1) << "Scheduling DatabaseCreationCallbackTask for database " |
198 << database; | 200 << database; |
199 database->getExecutionContext()->postTask( | 201 InspectorInstrumentation::asyncTaskScheduled( |
200 TaskType::DatabaseAccess, BLINK_FROM_HERE, | 202 database->getExecutionContext(), "openDatabase", creationCallback); |
201 createSameThreadTask(&databaseCallbackHandleEvent, | 203 TaskRunnerHelper::get(TaskType::DatabaseAccess, |
202 wrapPersistent(creationCallback), | 204 database->getExecutionContext()) |
203 wrapPersistent(database)), | 205 ->postTask(BLINK_FROM_HERE, WTF::bind(&databaseCallbackHandleEvent, |
204 "openDatabase"); | 206 wrapPersistent(creationCallback), |
| 207 wrapPersistent(database))); |
205 } | 208 } |
206 | 209 |
207 ASSERT(database); | 210 ASSERT(database); |
208 return database; | 211 return database; |
209 } | 212 } |
210 | 213 |
211 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, | 214 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, |
212 const String& name, | 215 const String& name, |
213 bool createIfDoesNotExist) { | 216 bool createIfDoesNotExist) { |
214 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, | 217 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, |
215 createIfDoesNotExist); | 218 createIfDoesNotExist); |
216 } | 219 } |
217 | 220 |
218 void DatabaseManager::logErrorMessage(ExecutionContext* context, | 221 void DatabaseManager::logErrorMessage(ExecutionContext* context, |
219 const String& message) { | 222 const String& message) { |
220 context->addConsoleMessage( | 223 context->addConsoleMessage( |
221 ConsoleMessage::create(StorageMessageSource, ErrorMessageLevel, message)); | 224 ConsoleMessage::create(StorageMessageSource, ErrorMessageLevel, message)); |
222 } | 225 } |
223 | 226 |
224 } // namespace blink | 227 } // namespace blink |
OLD | NEW |