OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 // FIXME: Everything from now on should be done on another thread. | 124 // FIXME: Everything from now on should be done on another thread. |
125 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, data
Directory); | 125 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, data
Directory); |
126 if (!backingStore) { | 126 if (!backingStore) { |
127 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); | 127 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); |
128 return; | 128 return; |
129 } | 129 } |
130 | 130 |
131 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre
ate(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdenti
fier); | 131 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre
ate(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdenti
fier); |
132 if (databaseBackend) { | 132 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); |
133 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); | 133 databaseBackend->deleteDatabase(callbacks); |
134 databaseBackend->deleteDatabase(callbacks); | |
135 } else | |
136 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); | |
137 } | 134 } |
138 | 135 |
139 PassRefPtr<IDBBackingStore> IDBFactoryBackendImpl::openBackingStore(PassRefPtr<S
ecurityOrigin> securityOrigin, const String& dataDirectory) | 136 PassRefPtr<IDBBackingStore> IDBFactoryBackendImpl::openBackingStore(PassRefPtr<S
ecurityOrigin> securityOrigin, const String& dataDirectory) |
140 { | 137 { |
141 const String fileIdentifier = computeFileIdentifier(securityOrigin.get()); | 138 const String fileIdentifier = computeFileIdentifier(securityOrigin.get()); |
142 | 139 |
143 RefPtr<IDBBackingStore> backingStore; | 140 RefPtr<IDBBackingStore> backingStore; |
144 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier); | 141 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier); |
145 if (it2 != m_backingStoreMap.end()) | 142 if (it2 != m_backingStoreMap.end()) |
146 backingStore = it2->second; | 143 backingStore = it2->second; |
(...skipping 26 matching lines...) Expand all Loading... |
173 } | 170 } |
174 | 171 |
175 // FIXME: Everything from now on should be done on another thread. | 172 // FIXME: Everything from now on should be done on another thread. |
176 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, data
Directory); | 173 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, data
Directory); |
177 if (!backingStore) { | 174 if (!backingStore) { |
178 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); | 175 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); |
179 return; | 176 return; |
180 } | 177 } |
181 | 178 |
182 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre
ate(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdenti
fier); | 179 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre
ate(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdenti
fier); |
183 if (databaseBackend) { | 180 callbacks->onSuccess(RefPtr<IDBDatabaseBackendInterface>(databaseBackend.get
()).release()); |
184 callbacks->onSuccess(RefPtr<IDBDatabaseBackendInterface>(databaseBackend
.get()).release()); | 181 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); |
185 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); | |
186 } else | |
187 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); | |
188 } | 182 } |
189 | 183 |
190 } // namespace WebCore | 184 } // namespace WebCore |
191 | 185 |
192 #endif // ENABLE(INDEXED_DATABASE) | 186 #endif // ENABLE(INDEXED_DATABASE) |
OLD | NEW |