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 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); | 132 if (databaseBackend) { |
133 databaseBackend->deleteDatabase(callbacks); | 133 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); |
| 134 databaseBackend->deleteDatabase(callbacks); |
| 135 } else |
| 136 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); |
134 } | 137 } |
135 | 138 |
136 PassRefPtr<IDBBackingStore> IDBFactoryBackendImpl::openBackingStore(PassRefPtr<S
ecurityOrigin> securityOrigin, const String& dataDirectory) | 139 PassRefPtr<IDBBackingStore> IDBFactoryBackendImpl::openBackingStore(PassRefPtr<S
ecurityOrigin> securityOrigin, const String& dataDirectory) |
137 { | 140 { |
138 const String fileIdentifier = computeFileIdentifier(securityOrigin.get()); | 141 const String fileIdentifier = computeFileIdentifier(securityOrigin.get()); |
139 | 142 |
140 RefPtr<IDBBackingStore> backingStore; | 143 RefPtr<IDBBackingStore> backingStore; |
141 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier); | 144 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier); |
142 if (it2 != m_backingStoreMap.end()) | 145 if (it2 != m_backingStoreMap.end()) |
143 backingStore = it2->second; | 146 backingStore = it2->second; |
(...skipping 26 matching lines...) Expand all Loading... |
170 } | 173 } |
171 | 174 |
172 // FIXME: Everything from now on should be done on another thread. | 175 // FIXME: Everything from now on should be done on another thread. |
173 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, data
Directory); | 176 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, data
Directory); |
174 if (!backingStore) { | 177 if (!backingStore) { |
175 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); | 178 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); |
176 return; | 179 return; |
177 } | 180 } |
178 | 181 |
179 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre
ate(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdenti
fier); | 182 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre
ate(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdenti
fier); |
180 callbacks->onSuccess(RefPtr<IDBDatabaseBackendInterface>(databaseBackend.get
()).release()); | 183 if (databaseBackend) { |
181 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); | 184 callbacks->onSuccess(RefPtr<IDBDatabaseBackendInterface>(databaseBackend
.get()).release()); |
| 185 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); |
| 186 } else |
| 187 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOW
N_ERR, "Internal error.")); |
182 } | 188 } |
183 | 189 |
184 } // namespace WebCore | 190 } // namespace WebCore |
185 | 191 |
186 #endif // ENABLE(INDEXED_DATABASE) | 192 #endif // ENABLE(INDEXED_DATABASE) |
OLD | NEW |