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