OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 options.get("autoIncrement", autoIncrement); | 180 options.get("autoIncrement", autoIncrement); |
181 } | 181 } |
182 | 182 |
183 return createObjectStore(name, keyPath, autoIncrement, es); | 183 return createObjectStore(name, keyPath, autoIncrement, es); |
184 } | 184 } |
185 | 185 |
186 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
nst IDBKeyPath& keyPath, bool autoIncrement, ExceptionState& es) | 186 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
nst IDBKeyPath& keyPath, bool autoIncrement, ExceptionState& es) |
187 { | 187 { |
188 IDB_TRACE("IDBDatabase::createObjectStore"); | 188 IDB_TRACE("IDBDatabase::createObjectStore"); |
189 WebKit::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEn
dAPICalls", IDBCreateObjectStoreCall, IDBMethodsMax); | 189 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBCreateObjectStoreCall, IDBMethodsMax); |
190 if (!m_versionChangeTransaction) { | 190 if (!m_versionChangeTransaction) { |
191 es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTra
nsactionErrorMessage); | 191 es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTra
nsactionErrorMessage); |
192 return 0; | 192 return 0; |
193 } | 193 } |
194 if (m_versionChangeTransaction->isFinished()) { | 194 if (m_versionChangeTransaction->isFinished()) { |
195 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 195 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); |
196 return 0; | 196 return 0; |
197 } | 197 } |
198 if (!m_versionChangeTransaction->isActive()) { | 198 if (!m_versionChangeTransaction->isActive()) { |
199 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 199 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); |
(...skipping 23 matching lines...) Expand all Loading... |
223 m_metadata.objectStores.set(metadata.id, metadata); | 223 m_metadata.objectStores.set(metadata.id, metadata); |
224 ++m_metadata.maxObjectStoreId; | 224 ++m_metadata.maxObjectStoreId; |
225 | 225 |
226 m_versionChangeTransaction->objectStoreCreated(name, objectStore); | 226 m_versionChangeTransaction->objectStoreCreated(name, objectStore); |
227 return objectStore.release(); | 227 return objectStore.release(); |
228 } | 228 } |
229 | 229 |
230 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es) | 230 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es) |
231 { | 231 { |
232 IDB_TRACE("IDBDatabase::deleteObjectStore"); | 232 IDB_TRACE("IDBDatabase::deleteObjectStore"); |
233 WebKit::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEn
dAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax); | 233 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBDeleteObjectStoreCall, IDBMethodsMax); |
234 if (!m_versionChangeTransaction) { | 234 if (!m_versionChangeTransaction) { |
235 es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTra
nsactionErrorMessage); | 235 es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTra
nsactionErrorMessage); |
236 return; | 236 return; |
237 } | 237 } |
238 if (m_versionChangeTransaction->isFinished()) { | 238 if (m_versionChangeTransaction->isFinished()) { |
239 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 239 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); |
240 return; | 240 return; |
241 } | 241 } |
242 if (!m_versionChangeTransaction->isActive()) { | 242 if (!m_versionChangeTransaction->isActive()) { |
243 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 243 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); |
244 return; | 244 return; |
245 } | 245 } |
246 | 246 |
247 int64_t objectStoreId = findObjectStoreId(name); | 247 int64_t objectStoreId = findObjectStoreId(name); |
248 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 248 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
249 es.throwDOMException(NotFoundError, "The specified object store was not
found."); | 249 es.throwDOMException(NotFoundError, "The specified object store was not
found."); |
250 return; | 250 return; |
251 } | 251 } |
252 | 252 |
253 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); | 253 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); |
254 m_versionChangeTransaction->objectStoreDeleted(name); | 254 m_versionChangeTransaction->objectStoreDeleted(name); |
255 m_metadata.objectStores.remove(objectStoreId); | 255 m_metadata.objectStores.remove(objectStoreId); |
256 } | 256 } |
257 | 257 |
258 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ExecutionContext* context, c
onst Vector<String>& scope, const String& modeString, ExceptionState& es) | 258 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ExecutionContext* context, c
onst Vector<String>& scope, const String& modeString, ExceptionState& es) |
259 { | 259 { |
260 IDB_TRACE("IDBDatabase::transaction"); | 260 IDB_TRACE("IDBDatabase::transaction"); |
261 WebKit::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEn
dAPICalls", IDBTransactionCall, IDBMethodsMax); | 261 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBTransactionCall, IDBMethodsMax); |
262 if (!scope.size()) { | 262 if (!scope.size()) { |
263 es.throwDOMException(InvalidAccessError, "The storeNames parameter was e
mpty."); | 263 es.throwDOMException(InvalidAccessError, "The storeNames parameter was e
mpty."); |
264 return 0; | 264 return 0; |
265 } | 265 } |
266 | 266 |
267 IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, e
s); | 267 IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, e
s); |
268 if (es.hadException()) | 268 if (es.hadException()) |
269 return 0; | 269 return 0; |
270 | 270 |
271 if (m_versionChangeTransaction) { | 271 if (m_versionChangeTransaction) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 { | 408 { |
409 return EventTargetNames::IDBDatabase; | 409 return EventTargetNames::IDBDatabase; |
410 } | 410 } |
411 | 411 |
412 ExecutionContext* IDBDatabase::executionContext() const | 412 ExecutionContext* IDBDatabase::executionContext() const |
413 { | 413 { |
414 return ActiveDOMObject::executionContext(); | 414 return ActiveDOMObject::executionContext(); |
415 } | 415 } |
416 | 416 |
417 } // namespace WebCore | 417 } // namespace WebCore |
OLD | NEW |