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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
30 #include "bindings/core/v8/Nullable.h" | 30 #include "bindings/core/v8/Nullable.h" |
31 #include "bindings/core/v8/SerializedScriptValue.h" | 31 #include "bindings/core/v8/SerializedScriptValue.h" |
32 #include "bindings/modules/v8/V8BindingForModules.h" | 32 #include "bindings/modules/v8/V8BindingForModules.h" |
33 #include "core/dom/ExceptionCode.h" | 33 #include "core/dom/ExceptionCode.h" |
34 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
35 #include "core/events/EventQueue.h" | 35 #include "core/events/EventQueue.h" |
36 #include "modules/indexeddb/IDBAny.h" | 36 #include "modules/indexeddb/IDBAny.h" |
| 37 #include "modules/indexeddb/IDBDatabaseProxy.h" |
37 #include "modules/indexeddb/IDBEventDispatcher.h" | 38 #include "modules/indexeddb/IDBEventDispatcher.h" |
38 #include "modules/indexeddb/IDBIndex.h" | 39 #include "modules/indexeddb/IDBIndex.h" |
39 #include "modules/indexeddb/IDBKeyPath.h" | 40 #include "modules/indexeddb/IDBKeyPath.h" |
40 #include "modules/indexeddb/IDBTracing.h" | 41 #include "modules/indexeddb/IDBTracing.h" |
41 #include "modules/indexeddb/IDBVersionChangeEvent.h" | 42 #include "modules/indexeddb/IDBVersionChangeEvent.h" |
42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" | 43 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" |
43 #include "platform/Histogram.h" | 44 #include "platform/Histogram.h" |
44 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" | 45 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" |
45 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 46 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
46 #include "wtf/Atomics.h" | 47 #include "wtf/Atomics.h" |
47 #include <limits> | 48 #include <limits> |
48 #include <memory> | 49 #include <memory> |
49 | 50 |
50 using blink::WebIDBDatabase; | 51 using blink::IDBDatabaseProxy; |
| 52 using indexed_db::mojom::blink::TransactionMode; |
51 | 53 |
52 namespace blink { | 54 namespace blink { |
53 | 55 |
54 const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object st
ore has been deleted."; | 56 const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object st
ore has been deleted."; |
55 const char IDBDatabase::isKeyCursorErrorMessage[] = "The cursor is a key cursor.
"; | 57 const char IDBDatabase::isKeyCursorErrorMessage[] = "The cursor is a key cursor.
"; |
56 const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = "No key or key range spe
cified."; | 58 const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = "No key or key range spe
cified."; |
57 const char IDBDatabase::noSuchIndexErrorMessage[] = "The specified index was not
found."; | 59 const char IDBDatabase::noSuchIndexErrorMessage[] = "The specified index was not
found."; |
58 const char IDBDatabase::noSuchObjectStoreErrorMessage[] = "The specified object
store was not found."; | 60 const char IDBDatabase::noSuchObjectStoreErrorMessage[] = "The specified object
store was not found."; |
59 const char IDBDatabase::noValueErrorMessage[] = "The cursor is being iterated or
has iterated past its end."; | 61 const char IDBDatabase::noValueErrorMessage[] = "The cursor is being iterated or
has iterated past its end."; |
60 const char IDBDatabase::notValidKeyErrorMessage[] = "The parameter is not a vali
d key."; | 62 const char IDBDatabase::notValidKeyErrorMessage[] = "The parameter is not a vali
d key."; |
61 const char IDBDatabase::notVersionChangeTransactionErrorMessage[] = "The databas
e is not running a version change transaction."; | 63 const char IDBDatabase::notVersionChangeTransactionErrorMessage[] = "The databas
e is not running a version change transaction."; |
62 const char IDBDatabase::objectStoreDeletedErrorMessage[] = "The object store has
been deleted."; | 64 const char IDBDatabase::objectStoreDeletedErrorMessage[] = "The object store has
been deleted."; |
63 const char IDBDatabase::requestNotFinishedErrorMessage[] = "The request has not
finished."; | 65 const char IDBDatabase::requestNotFinishedErrorMessage[] = "The request has not
finished."; |
64 const char IDBDatabase::sourceDeletedErrorMessage[] = "The cursor's source or ef
fective object store has been deleted."; | 66 const char IDBDatabase::sourceDeletedErrorMessage[] = "The cursor's source or ef
fective object store has been deleted."; |
65 const char IDBDatabase::transactionInactiveErrorMessage[] = "The transaction is
not active."; | 67 const char IDBDatabase::transactionInactiveErrorMessage[] = "The transaction is
not active."; |
66 const char IDBDatabase::transactionFinishedErrorMessage[] = "The transaction has
finished."; | 68 const char IDBDatabase::transactionFinishedErrorMessage[] = "The transaction has
finished."; |
67 const char IDBDatabase::transactionReadOnlyErrorMessage[] = "The transaction is
read-only."; | 69 const char IDBDatabase::transactionReadOnlyErrorMessage[] = "The transaction is
read-only."; |
68 const char IDBDatabase::databaseClosedErrorMessage[] = "The database connection
is closed."; | 70 const char IDBDatabase::databaseClosedErrorMessage[] = "The database connection
is closed."; |
69 | 71 |
70 IDBDatabase* IDBDatabase::create(ExecutionContext* context, std::unique_ptr<WebI
DBDatabase> database, IDBDatabaseCallbacks* callbacks) | 72 IDBDatabase* IDBDatabase::create(ExecutionContext* context, std::unique_ptr<IDBD
atabaseProxy> database, IDBDatabaseCallbacks* callbacks) |
71 { | 73 { |
72 IDBDatabase* idbDatabase = new IDBDatabase(context, std::move(database), cal
lbacks); | 74 IDBDatabase* idbDatabase = new IDBDatabase(context, std::move(database), cal
lbacks); |
73 idbDatabase->suspendIfNeeded(); | 75 idbDatabase->suspendIfNeeded(); |
74 return idbDatabase; | 76 return idbDatabase; |
75 } | 77 } |
76 | 78 |
77 IDBDatabase::IDBDatabase(ExecutionContext* context, std::unique_ptr<WebIDBDataba
se> backend, IDBDatabaseCallbacks* callbacks) | 79 IDBDatabase::IDBDatabase(ExecutionContext* context, std::unique_ptr<IDBDatabaseP
roxy> backend, IDBDatabaseCallbacks* callbacks) |
78 : ActiveScriptWrappable(this) | 80 : ActiveScriptWrappable(this) |
79 , ActiveDOMObject(context) | 81 , ActiveDOMObject(context) |
80 , m_backend(std::move(backend)) | 82 , m_backend(std::move(backend)) |
81 , m_databaseCallbacks(callbacks) | 83 , m_databaseCallbacks(callbacks) |
82 { | 84 { |
83 m_databaseCallbacks->connect(this); | 85 m_databaseCallbacks->connect(this); |
84 } | 86 } |
85 | 87 |
86 IDBDatabase::~IDBDatabase() | 88 IDBDatabase::~IDBDatabase() |
87 { | 89 { |
88 if (!m_closePending && m_backend) | 90 if (!m_closePending && m_backend) |
89 m_backend->close(); | 91 m_backend->Close(); |
90 } | 92 } |
91 | 93 |
92 DEFINE_TRACE(IDBDatabase) | 94 DEFINE_TRACE(IDBDatabase) |
93 { | 95 { |
94 visitor->trace(m_versionChangeTransaction); | 96 visitor->trace(m_versionChangeTransaction); |
95 visitor->trace(m_transactions); | 97 visitor->trace(m_transactions); |
96 visitor->trace(m_enqueuedEvents); | 98 visitor->trace(m_enqueuedEvents); |
97 visitor->trace(m_databaseCallbacks); | 99 visitor->trace(m_databaseCallbacks); |
98 EventTargetWithInlineData::trace(visitor); | 100 EventTargetWithInlineData::trace(visitor); |
99 ActiveDOMObject::trace(visitor); | 101 ActiveDOMObject::trace(visitor); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); | 204 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); |
203 return nullptr; | 205 return nullptr; |
204 } | 206 } |
205 | 207 |
206 if (!m_backend) { | 208 if (!m_backend) { |
207 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 209 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
208 return nullptr; | 210 return nullptr; |
209 } | 211 } |
210 | 212 |
211 int64_t objectStoreId = m_metadata.maxObjectStoreId + 1; | 213 int64_t objectStoreId = m_metadata.maxObjectStoreId + 1; |
212 m_backend->createObjectStore(m_versionChangeTransaction->id(), objectStoreId
, name, keyPath, autoIncrement); | 214 m_backend->CreateObjectStore(m_versionChangeTransaction->id(), objectStoreId
, name, keyPath, autoIncrement); |
213 | 215 |
214 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement,
WebIDBDatabase::minimumIndexId); | 216 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement,
indexed_db::mojom::blink::Database::minimumIndexId); |
215 IDBObjectStore* objectStore = IDBObjectStore::create(metadata, m_versionChan
geTransaction.get()); | 217 IDBObjectStore* objectStore = IDBObjectStore::create(metadata, m_versionChan
geTransaction.get()); |
216 m_metadata.objectStores.set(metadata.id, metadata); | 218 m_metadata.objectStores.set(metadata.id, metadata); |
217 ++m_metadata.maxObjectStoreId; | 219 ++m_metadata.maxObjectStoreId; |
218 | 220 |
219 m_versionChangeTransaction->objectStoreCreated(name, objectStore); | 221 m_versionChangeTransaction->objectStoreCreated(name, objectStore); |
220 return objectStore; | 222 return objectStore; |
221 } | 223 } |
222 | 224 |
223 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& exceptio
nState) | 225 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& exceptio
nState) |
224 { | 226 { |
(...skipping 16 matching lines...) Expand all Loading... |
241 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 243 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
242 exceptionState.throwDOMException(NotFoundError, "The specified object st
ore was not found."); | 244 exceptionState.throwDOMException(NotFoundError, "The specified object st
ore was not found."); |
243 return; | 245 return; |
244 } | 246 } |
245 | 247 |
246 if (!m_backend) { | 248 if (!m_backend) { |
247 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 249 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
248 return; | 250 return; |
249 } | 251 } |
250 | 252 |
251 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); | 253 m_backend->DeleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); |
252 m_versionChangeTransaction->objectStoreDeleted(name); | 254 m_versionChangeTransaction->objectStoreDeleted(name); |
253 m_metadata.objectStores.remove(objectStoreId); | 255 m_metadata.objectStores.remove(objectStoreId); |
254 } | 256 } |
255 | 257 |
256 IDBTransaction* IDBDatabase::transaction(ScriptState* scriptState, const StringO
rStringSequenceOrDOMStringList& storeNames, const String& modeString, ExceptionS
tate& exceptionState) | 258 IDBTransaction* IDBDatabase::transaction(ScriptState* scriptState, const StringO
rStringSequenceOrDOMStringList& storeNames, const String& modeString, ExceptionS
tate& exceptionState) |
257 { | 259 { |
258 IDB_TRACE("IDBDatabase::transaction"); | 260 IDB_TRACE("IDBDatabase::transaction"); |
259 recordApiCallsHistogram(IDBTransactionCall); | 261 recordApiCallsHistogram(IDBTransactionCall); |
260 | 262 |
261 HashSet<String> scope; | 263 HashSet<String> scope; |
262 if (storeNames.isString()) { | 264 if (storeNames.isString()) { |
263 scope.add(storeNames.getAsString()); | 265 scope.add(storeNames.getAsString()); |
264 } else if (storeNames.isStringSequence()) { | 266 } else if (storeNames.isStringSequence()) { |
265 for (const String& name : storeNames.getAsStringSequence()) | 267 for (const String& name : storeNames.getAsStringSequence()) |
266 scope.add(name); | 268 scope.add(name); |
267 } else if (storeNames.isDOMStringList()) { | 269 } else if (storeNames.isDOMStringList()) { |
268 const Vector<String>& list = *storeNames.getAsDOMStringList(); | 270 const Vector<String>& list = *storeNames.getAsDOMStringList(); |
269 for (const String& name : list) | 271 for (const String& name : list) |
270 scope.add(name); | 272 scope.add(name); |
271 } else { | 273 } else { |
272 ASSERT_NOT_REACHED(); | 274 ASSERT_NOT_REACHED(); |
273 } | 275 } |
274 | 276 |
275 if (scope.isEmpty()) { | 277 if (scope.isEmpty()) { |
276 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); | 278 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); |
277 return nullptr; | 279 return nullptr; |
278 } | 280 } |
279 | 281 |
280 WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString); | 282 TransactionMode mode = IDBTransaction::stringToMode(modeString); |
281 if (mode != WebIDBTransactionModeReadOnly && mode != WebIDBTransactionModeRe
adWrite) { | 283 if (mode != TransactionMode::ReadOnly && mode != TransactionMode::ReadWrite)
{ |
282 exceptionState.throwTypeError("The mode provided ('" + modeString + "')
is not one of 'readonly' or 'readwrite'."); | 284 exceptionState.throwTypeError("The mode provided ('" + modeString + "')
is not one of 'readonly' or 'readwrite'."); |
283 return nullptr; | 285 return nullptr; |
284 } | 286 } |
285 | 287 |
286 if (exceptionState.hadException()) | 288 if (exceptionState.hadException()) |
287 return nullptr; | 289 return nullptr; |
288 | 290 |
289 if (m_versionChangeTransaction) { | 291 if (m_versionChangeTransaction) { |
290 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); | 292 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); |
291 return nullptr; | 293 return nullptr; |
(...skipping 13 matching lines...) Expand all Loading... |
305 } | 307 } |
306 objectStoreIds.append(objectStoreId); | 308 objectStoreIds.append(objectStoreId); |
307 } | 309 } |
308 | 310 |
309 if (!m_backend) { | 311 if (!m_backend) { |
310 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 312 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
311 return nullptr; | 313 return nullptr; |
312 } | 314 } |
313 | 315 |
314 int64_t transactionId = nextTransactionId(); | 316 int64_t transactionId = nextTransactionId(); |
315 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).release(), objectStoreIds, mode); | 317 m_backend->CreateTransaction(transactionId, std::move(objectStoreIds), mode)
; |
316 | 318 |
317 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; | 319 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; |
318 } | 320 } |
319 | 321 |
320 void IDBDatabase::forceClose() | 322 void IDBDatabase::forceClose() |
321 { | 323 { |
322 for (const auto& it : m_transactions) | 324 for (const auto& it : m_transactions) |
323 it.value->abort(IGNORE_EXCEPTION); | 325 it.value->abort(IGNORE_EXCEPTION); |
324 this->close(); | 326 this->close(); |
325 enqueueEvent(Event::create(EventTypeNames::close)); | 327 enqueueEvent(Event::create(EventTypeNames::close)); |
(...skipping 10 matching lines...) Expand all Loading... |
336 if (m_transactions.isEmpty()) | 338 if (m_transactions.isEmpty()) |
337 closeConnection(); | 339 closeConnection(); |
338 } | 340 } |
339 | 341 |
340 void IDBDatabase::closeConnection() | 342 void IDBDatabase::closeConnection() |
341 { | 343 { |
342 ASSERT(m_closePending); | 344 ASSERT(m_closePending); |
343 ASSERT(m_transactions.isEmpty()); | 345 ASSERT(m_transactions.isEmpty()); |
344 | 346 |
345 if (m_backend) { | 347 if (m_backend) { |
346 m_backend->close(); | 348 m_backend->Close(); |
347 m_backend.reset(); | 349 m_backend.reset(); |
348 } | 350 } |
349 | 351 |
350 if (m_contextStopped || !getExecutionContext()) | 352 if (m_contextStopped || !getExecutionContext()) |
351 return; | 353 return; |
352 | 354 |
353 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); | 355 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); |
354 // Remove any pending versionchange events scheduled to fire on this | 356 // Remove any pending versionchange events scheduled to fire on this |
355 // connection. They would have been scheduled by the backend when another | 357 // connection. They would have been scheduled by the backend when another |
356 // connection attempted an upgrade, but the frontend connection is being | 358 // connection attempted an upgrade, but the frontend connection is being |
357 // closed before they could fire. | 359 // closed before they could fire. |
358 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 360 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
359 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); | 361 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); |
360 ASSERT_UNUSED(removed, removed); | 362 ASSERT_UNUSED(removed, removed); |
361 } | 363 } |
362 } | 364 } |
363 | 365 |
364 void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion) | 366 void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion) |
365 { | 367 { |
366 IDB_TRACE("IDBDatabase::onVersionChange"); | 368 IDB_TRACE("IDBDatabase::onVersionChange"); |
367 if (m_contextStopped || !getExecutionContext()) | 369 if (m_contextStopped || !getExecutionContext()) |
368 return; | 370 return; |
369 | 371 |
370 if (m_closePending) { | 372 if (m_closePending) { |
371 // If we're pending, that means there's a busy transaction. We won't | 373 // If we're pending, that means there's a busy transaction. We won't |
372 // fire 'versionchange' but since we're not closing immediately the | 374 // fire 'versionchange' but since we're not closing immediately the |
373 // back-end should still send out 'blocked'. | 375 // back-end should still send out 'blocked'. |
374 m_backend->versionChangeIgnored(); | 376 m_backend->VersionChangeIgnored(); |
375 return; | 377 return; |
376 } | 378 } |
377 | 379 |
378 Nullable<unsigned long long> newVersionNullable = (newVersion == IDBDatabase
Metadata::NoVersion) ? Nullable<unsigned long long>() : Nullable<unsigned long l
ong>(newVersion); | 380 Nullable<unsigned long long> newVersionNullable = (newVersion == IDBDatabase
Metadata::NoVersion) ? Nullable<unsigned long long>() : Nullable<unsigned long l
ong>(newVersion); |
379 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::versionchange, ol
dVersion, newVersionNullable)); | 381 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::versionchange, ol
dVersion, newVersionNullable)); |
380 } | 382 } |
381 | 383 |
382 void IDBDatabase::enqueueEvent(Event* event) | 384 void IDBDatabase::enqueueEvent(Event* event) |
383 { | 385 { |
384 ASSERT(!m_contextStopped); | 386 ASSERT(!m_contextStopped); |
(...skipping 10 matching lines...) Expand all Loading... |
395 if (m_contextStopped || !getExecutionContext()) | 397 if (m_contextStopped || !getExecutionContext()) |
396 return DispatchEventResult::CanceledBeforeDispatch; | 398 return DispatchEventResult::CanceledBeforeDispatch; |
397 ASSERT(event->type() == EventTypeNames::versionchange || event->type() == Ev
entTypeNames::close); | 399 ASSERT(event->type() == EventTypeNames::versionchange || event->type() == Ev
entTypeNames::close); |
398 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 400 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
399 if (m_enqueuedEvents[i].get() == event) | 401 if (m_enqueuedEvents[i].get() == event) |
400 m_enqueuedEvents.remove(i); | 402 m_enqueuedEvents.remove(i); |
401 } | 403 } |
402 | 404 |
403 DispatchEventResult dispatchResult = EventTarget::dispatchEventInternal(even
t); | 405 DispatchEventResult dispatchResult = EventTarget::dispatchEventInternal(even
t); |
404 if (event->type() == EventTypeNames::versionchange && !m_closePending && m_b
ackend) | 406 if (event->type() == EventTypeNames::versionchange && !m_closePending && m_b
ackend) |
405 m_backend->versionChangeIgnored(); | 407 m_backend->VersionChangeIgnored(); |
406 return dispatchResult; | 408 return dispatchResult; |
407 } | 409 } |
408 | 410 |
409 int64_t IDBDatabase::findObjectStoreId(const String& name) const | 411 int64_t IDBDatabase::findObjectStoreId(const String& name) const |
410 { | 412 { |
411 for (const auto& it : m_metadata.objectStores) { | 413 for (const auto& it : m_metadata.objectStores) { |
412 if (it.value.name == name) { | 414 if (it.value.name == name) { |
413 ASSERT(it.key != IDBObjectStoreMetadata::InvalidId); | 415 ASSERT(it.key != IDBObjectStoreMetadata::InvalidId); |
414 return it.key; | 416 return it.key; |
415 } | 417 } |
416 } | 418 } |
417 return IDBObjectStoreMetadata::InvalidId; | 419 return IDBObjectStoreMetadata::InvalidId; |
418 } | 420 } |
419 | 421 |
420 bool IDBDatabase::hasPendingActivity() const | 422 bool IDBDatabase::hasPendingActivity() const |
421 { | 423 { |
422 // The script wrapper must not be collected before the object is closed or | 424 // The script wrapper must not be collected before the object is closed or |
423 // we can't fire a "versionchange" event to let script manually close the co
nnection. | 425 // we can't fire a "versionchange" event to let script manually close the co
nnection. |
424 return !m_closePending && hasEventListeners() && !m_contextStopped; | 426 return !m_closePending && hasEventListeners() && !m_contextStopped; |
425 } | 427 } |
426 | 428 |
427 void IDBDatabase::stop() | 429 void IDBDatabase::stop() |
428 { | 430 { |
429 m_contextStopped = true; | 431 m_contextStopped = true; |
430 | 432 |
431 // Immediately close the connection to the back end. Don't attempt a | 433 // Immediately close the connection to the back end. Don't attempt a |
432 // normal close() since that may wait on transactions which require a | 434 // normal close() since that may wait on transactions which require a |
433 // round trip to the back-end to abort. | 435 // round trip to the back-end to abort. |
434 if (m_backend) { | 436 if (m_backend) { |
435 m_backend->close(); | 437 m_backend->Close(); |
436 m_backend.reset(); | 438 m_backend.reset(); |
437 } | 439 } |
438 } | 440 } |
439 | 441 |
440 const AtomicString& IDBDatabase::interfaceName() const | 442 const AtomicString& IDBDatabase::interfaceName() const |
441 { | 443 { |
442 return EventTargetNames::IDBDatabase; | 444 return EventTargetNames::IDBDatabase; |
443 } | 445 } |
444 | 446 |
445 ExecutionContext* IDBDatabase::getExecutionContext() const | 447 ExecutionContext* IDBDatabase::getExecutionContext() const |
446 { | 448 { |
447 return ActiveDOMObject::getExecutionContext(); | 449 return ActiveDOMObject::getExecutionContext(); |
448 } | 450 } |
449 | 451 |
450 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) | 452 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) |
451 { | 453 { |
452 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); | 454 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); |
453 apiCallsHistogram.count(method); | 455 apiCallsHistogram.count(method); |
454 } | 456 } |
455 | 457 |
456 } // namespace blink | 458 } // namespace blink |
OLD | NEW |