| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 void IDBDatabase::closeConnection() | 338 void IDBDatabase::closeConnection() |
| 339 { | 339 { |
| 340 ASSERT(m_closePending); | 340 ASSERT(m_closePending); |
| 341 ASSERT(m_transactions.isEmpty()); | 341 ASSERT(m_transactions.isEmpty()); |
| 342 | 342 |
| 343 if (m_backend) { | 343 if (m_backend) { |
| 344 m_backend->close(); | 344 m_backend->close(); |
| 345 m_backend.clear(); | 345 m_backend.clear(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 if (m_contextStopped || !executionContext()) | 348 if (m_contextStopped || !getExecutionContext()) |
| 349 return; | 349 return; |
| 350 | 350 |
| 351 EventQueue* eventQueue = executionContext()->eventQueue(); | 351 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); |
| 352 // Remove any pending versionchange events scheduled to fire on this | 352 // Remove any pending versionchange events scheduled to fire on this |
| 353 // connection. They would have been scheduled by the backend when another | 353 // connection. They would have been scheduled by the backend when another |
| 354 // connection attempted an upgrade, but the frontend connection is being | 354 // connection attempted an upgrade, but the frontend connection is being |
| 355 // closed before they could fire. | 355 // closed before they could fire. |
| 356 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 356 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 357 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); | 357 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); |
| 358 ASSERT_UNUSED(removed, removed); | 358 ASSERT_UNUSED(removed, removed); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion) | 362 void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion) |
| 363 { | 363 { |
| 364 IDB_TRACE("IDBDatabase::onVersionChange"); | 364 IDB_TRACE("IDBDatabase::onVersionChange"); |
| 365 if (m_contextStopped || !executionContext()) | 365 if (m_contextStopped || !getExecutionContext()) |
| 366 return; | 366 return; |
| 367 | 367 |
| 368 if (m_closePending) { | 368 if (m_closePending) { |
| 369 // If we're pending, that means there's a busy transaction. We won't | 369 // If we're pending, that means there's a busy transaction. We won't |
| 370 // fire 'versionchange' but since we're not closing immediately the | 370 // fire 'versionchange' but since we're not closing immediately the |
| 371 // back-end should still send out 'blocked'. | 371 // back-end should still send out 'blocked'. |
| 372 m_backend->versionChangeIgnored(); | 372 m_backend->versionChangeIgnored(); |
| 373 return; | 373 return; |
| 374 } | 374 } |
| 375 | 375 |
| 376 Nullable<unsigned long long> newVersionNullable = (newVersion == IDBDatabase
Metadata::NoVersion) ? Nullable<unsigned long long>() : Nullable<unsigned long l
ong>(newVersion); | 376 Nullable<unsigned long long> newVersionNullable = (newVersion == IDBDatabase
Metadata::NoVersion) ? Nullable<unsigned long long>() : Nullable<unsigned long l
ong>(newVersion); |
| 377 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::versionchange, ol
dVersion, newVersionNullable)); | 377 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::versionchange, ol
dVersion, newVersionNullable)); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void IDBDatabase::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) | 380 void IDBDatabase::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) |
| 381 { | 381 { |
| 382 ASSERT(!m_contextStopped); | 382 ASSERT(!m_contextStopped); |
| 383 ASSERT(executionContext()); | 383 ASSERT(getExecutionContext()); |
| 384 EventQueue* eventQueue = executionContext()->eventQueue(); | 384 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); |
| 385 event->setTarget(this); | 385 event->setTarget(this); |
| 386 eventQueue->enqueueEvent(event.get()); | 386 eventQueue->enqueueEvent(event.get()); |
| 387 m_enqueuedEvents.append(event); | 387 m_enqueuedEvents.append(event); |
| 388 } | 388 } |
| 389 | 389 |
| 390 DispatchEventResult IDBDatabase::dispatchEventInternal(PassRefPtrWillBeRawPtr<Ev
ent> event) | 390 DispatchEventResult IDBDatabase::dispatchEventInternal(PassRefPtrWillBeRawPtr<Ev
ent> event) |
| 391 { | 391 { |
| 392 IDB_TRACE("IDBDatabase::dispatchEvent"); | 392 IDB_TRACE("IDBDatabase::dispatchEvent"); |
| 393 if (m_contextStopped || !executionContext()) | 393 if (m_contextStopped || !getExecutionContext()) |
| 394 return DispatchEventResult::CanceledBeforeDispatch; | 394 return DispatchEventResult::CanceledBeforeDispatch; |
| 395 ASSERT(event->type() == EventTypeNames::versionchange || event->type() == Ev
entTypeNames::close); | 395 ASSERT(event->type() == EventTypeNames::versionchange || event->type() == Ev
entTypeNames::close); |
| 396 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 396 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 397 if (m_enqueuedEvents[i].get() == event.get()) | 397 if (m_enqueuedEvents[i].get() == event.get()) |
| 398 m_enqueuedEvents.remove(i); | 398 m_enqueuedEvents.remove(i); |
| 399 } | 399 } |
| 400 | 400 |
| 401 DispatchEventResult dispatchResult = EventTarget::dispatchEventInternal(even
t.get()); | 401 DispatchEventResult dispatchResult = EventTarget::dispatchEventInternal(even
t.get()); |
| 402 if (event->type() == EventTypeNames::versionchange && !m_closePending && m_b
ackend) | 402 if (event->type() == EventTypeNames::versionchange && !m_closePending && m_b
ackend) |
| 403 m_backend->versionChangeIgnored(); | 403 m_backend->versionChangeIgnored(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 433 m_backend->close(); | 433 m_backend->close(); |
| 434 m_backend.clear(); | 434 m_backend.clear(); |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| 438 const AtomicString& IDBDatabase::interfaceName() const | 438 const AtomicString& IDBDatabase::interfaceName() const |
| 439 { | 439 { |
| 440 return EventTargetNames::IDBDatabase; | 440 return EventTargetNames::IDBDatabase; |
| 441 } | 441 } |
| 442 | 442 |
| 443 ExecutionContext* IDBDatabase::executionContext() const | 443 ExecutionContext* IDBDatabase::getExecutionContext() const |
| 444 { | 444 { |
| 445 return ActiveDOMObject::executionContext(); | 445 return ActiveDOMObject::getExecutionContext(); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) | 448 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) |
| 449 { | 449 { |
| 450 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); | 450 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); |
| 451 apiCallsHistogram.count(method); | 451 apiCallsHistogram.count(method); |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |