Chromium Code Reviews| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 | 324 |
| 325 if (m_transactions.isEmpty()) | 325 if (m_transactions.isEmpty()) |
| 326 closeConnection(); | 326 closeConnection(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void IDBDatabase::closeConnection() | 329 void IDBDatabase::closeConnection() |
| 330 { | 330 { |
| 331 ASSERT(m_closePending); | 331 ASSERT(m_closePending); |
| 332 ASSERT(m_transactions.isEmpty()); | 332 ASSERT(m_transactions.isEmpty()); |
| 333 | 333 |
| 334 m_backend->close(); | 334 if (m_backend) { |
| 335 m_backend.clear(); | 335 m_backend->close(); |
| 336 m_backend.clear(); | |
| 337 } | |
| 336 | 338 |
| 337 if (m_contextStopped || !executionContext()) | 339 if (m_contextStopped || !executionContext()) |
| 338 return; | 340 return; |
| 339 | 341 |
| 340 EventQueue* eventQueue = executionContext()->eventQueue(); | 342 EventQueue* eventQueue = executionContext()->eventQueue(); |
| 341 // Remove any pending versionchange events scheduled to fire on this | 343 // Remove any pending versionchange events scheduled to fire on this |
| 342 // connection. They would have been scheduled by the backend when another | 344 // connection. They would have been scheduled by the backend when another |
| 343 // connection called setVersion, but the frontend connection is being | 345 // connection called setVersion, but the frontend connection is being |
| 344 // closed before they could fire. | 346 // closed before they could fire. |
| 345 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 347 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 | 397 |
| 396 bool IDBDatabase::hasPendingActivity() const | 398 bool IDBDatabase::hasPendingActivity() const |
| 397 { | 399 { |
| 398 // The script wrapper must not be collected before the object is closed or | 400 // The script wrapper must not be collected before the object is closed or |
| 399 // we can't fire a "versionchange" event to let script manually close the co nnection. | 401 // we can't fire a "versionchange" event to let script manually close the co nnection. |
| 400 return !m_closePending && hasEventListeners() && !m_contextStopped; | 402 return !m_closePending && hasEventListeners() && !m_contextStopped; |
| 401 } | 403 } |
| 402 | 404 |
| 403 void IDBDatabase::stop() | 405 void IDBDatabase::stop() |
| 404 { | 406 { |
| 405 // Stop fires at a deterministic time, so we need to call close in it. | 407 m_contextStopped = true; |
| 406 close(); | |
| 407 | 408 |
| 408 m_contextStopped = true; | 409 // Normally, connections are not closed until all transactions are |
| 410 // finished, which requires a round-trip to the back end. In a worker | |
| 411 // context, no more messages will be received once the context is torn | |
| 412 // down. So in the case of context stop, just close immediately. | |
|
alecflett
2014/01/15 23:40:23
The comment could be generalized here - I think so
jsbell
2014/01/15 23:56:56
By "Normally" I meant "on explicit close() or GC",
| |
| 413 if (m_backend) { | |
| 414 m_backend->close(); | |
| 415 m_backend.clear(); | |
| 416 } | |
| 409 } | 417 } |
| 410 | 418 |
| 411 const AtomicString& IDBDatabase::interfaceName() const | 419 const AtomicString& IDBDatabase::interfaceName() const |
| 412 { | 420 { |
| 413 return EventTargetNames::IDBDatabase; | 421 return EventTargetNames::IDBDatabase; |
| 414 } | 422 } |
| 415 | 423 |
| 416 ExecutionContext* IDBDatabase::executionContext() const | 424 ExecutionContext* IDBDatabase::executionContext() const |
| 417 { | 425 { |
| 418 return ActiveDOMObject::executionContext(); | 426 return ActiveDOMObject::executionContext(); |
| 419 } | 427 } |
| 420 | 428 |
| 421 } // namespace WebCore | 429 } // namespace WebCore |
| OLD | NEW |