Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: Source/modules/indexeddb/IDBDatabase.cpp

Issue 138473004: IndexedDB: Prevent terminated worker from hanging connections (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reword comment Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBTransaction.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // Immediately close the connection to the back end. Don't attempt a
410 // normal close() since that may wait on transactions which require a
411 // round trip to the back-end to abort.
412 if (m_backend) {
413 m_backend->close();
414 m_backend.clear();
415 }
409 } 416 }
410 417
411 const AtomicString& IDBDatabase::interfaceName() const 418 const AtomicString& IDBDatabase::interfaceName() const
412 { 419 {
413 return EventTargetNames::IDBDatabase; 420 return EventTargetNames::IDBDatabase;
414 } 421 }
415 422
416 ExecutionContext* IDBDatabase::executionContext() const 423 ExecutionContext* IDBDatabase::executionContext() const
417 { 424 {
418 return ActiveDOMObject::executionContext(); 425 return ActiveDOMObject::executionContext();
419 } 426 }
420 427
421 } // namespace WebCore 428 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBTransaction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698