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

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

Issue 138473004: IndexedDB: Prevent terminated worker from hanging connections (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test expectation 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
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 void IDBTransaction::abort(ExceptionState& exceptionState) 190 void IDBTransaction::abort(ExceptionState& exceptionState)
191 { 191 {
192 if (m_state == Finishing || m_state == Finished) { 192 if (m_state == Finishing || m_state == Finished) {
193 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac tionFinishedErrorMessage); 193 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac tionFinishedErrorMessage);
194 return; 194 return;
195 } 195 }
196 196
197 m_state = Finishing; 197 m_state = Finishing;
198 198
199 if (!m_contextStopped) { 199 if (m_contextStopped)
200 while (!m_requestList.isEmpty()) { 200 return;
201 RefPtr<IDBRequest> request = *m_requestList.begin(); 201
202 m_requestList.remove(request); 202 while (!m_requestList.isEmpty()) {
203 request->abort(); 203 RefPtr<IDBRequest> request = *m_requestList.begin();
204 } 204 m_requestList.remove(request);
205 request->abort();
205 } 206 }
206 207
207 RefPtr<IDBTransaction> selfRef = this; 208 RefPtr<IDBTransaction> selfRef = this;
208 backendDB()->abort(m_id); 209 backendDB()->abort(m_id);
209 } 210 }
210 211
211 void IDBTransaction::registerRequest(IDBRequest* request) 212 void IDBTransaction::registerRequest(IDBRequest* request)
212 { 213 {
213 ASSERT(request); 214 ASSERT(request);
214 ASSERT(m_state == Active); 215 ASSERT(m_state == Active);
215 m_requestList.add(request); 216 m_requestList.add(request);
216 } 217 }
217 218
218 void IDBTransaction::unregisterRequest(IDBRequest* request) 219 void IDBTransaction::unregisterRequest(IDBRequest* request)
219 { 220 {
220 ASSERT(request); 221 ASSERT(request);
221 // If we aborted the request, it will already have been removed. 222 // If we aborted the request, it will already have been removed.
222 m_requestList.remove(request); 223 m_requestList.remove(request);
223 } 224 }
224 225
225 void IDBTransaction::onAbort(PassRefPtr<DOMError> prpError) 226 void IDBTransaction::onAbort(PassRefPtr<DOMError> prpError)
226 { 227 {
227 IDB_TRACE("IDBTransaction::onAbort"); 228 IDB_TRACE("IDBTransaction::onAbort");
229 if (m_contextStopped) {
230 RefPtr<IDBTransaction> protect(this);
231 m_database->transactionFinished(this);
232 return;
233 }
234
228 RefPtr<DOMError> error = prpError; 235 RefPtr<DOMError> error = prpError;
229 ASSERT(m_state != Finished); 236 ASSERT(m_state != Finished);
230 237
231 if (m_state != Finishing) { 238 if (m_state != Finishing) {
232 ASSERT(error.get()); 239 ASSERT(error.get());
233 setError(error.release()); 240 setError(error.release());
234 241
235 // Abort was not triggered by front-end, so outstanding requests must 242 // Abort was not triggered by front-end, so outstanding requests must
236 // be aborted now. 243 // be aborted now.
237 while (!m_requestList.isEmpty()) { 244 while (!m_requestList.isEmpty()) {
(...skipping 16 matching lines...) Expand all
254 enqueueEvent(Event::createBubble(EventTypeNames::abort)); 261 enqueueEvent(Event::createBubble(EventTypeNames::abort));
255 262
256 // If script has stopped and GC has completed, database may have last refere nce to this object. 263 // If script has stopped and GC has completed, database may have last refere nce to this object.
257 RefPtr<IDBTransaction> protect(this); 264 RefPtr<IDBTransaction> protect(this);
258 m_database->transactionFinished(this); 265 m_database->transactionFinished(this);
259 } 266 }
260 267
261 void IDBTransaction::onComplete() 268 void IDBTransaction::onComplete()
262 { 269 {
263 IDB_TRACE("IDBTransaction::onComplete"); 270 IDB_TRACE("IDBTransaction::onComplete");
271 if (m_contextStopped) {
272 RefPtr<IDBTransaction> protect(this);
273 m_database->transactionFinished(this);
274 return;
275 }
276
264 ASSERT(m_state != Finished); 277 ASSERT(m_state != Finished);
265 m_state = Finishing; 278 m_state = Finishing;
266 m_objectStoreCleanupMap.clear(); 279 m_objectStoreCleanupMap.clear();
267 280
268 // Enqueue events before notifying database, as database may close which enq ueues more events and order matters. 281 // Enqueue events before notifying database, as database may close which enq ueues more events and order matters.
269 enqueueEvent(Event::create(EventTypeNames::complete)); 282 enqueueEvent(Event::create(EventTypeNames::complete));
270 283
271 // If script has stopped and GC has completed, database may have last refere nce to this object. 284 // If script has stopped and GC has completed, database may have last refere nce to this object.
272 RefPtr<IDBTransaction> protect(this); 285 RefPtr<IDBTransaction> protect(this);
273 m_database->transactionFinished(this); 286 m_database->transactionFinished(this);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 event->setTarget(this); 390 event->setTarget(this);
378 eventQueue->enqueueEvent(event); 391 eventQueue->enqueueEvent(event);
379 } 392 }
380 393
381 blink::WebIDBDatabase* IDBTransaction::backendDB() const 394 blink::WebIDBDatabase* IDBTransaction::backendDB() const
382 { 395 {
383 return m_database->backend(); 396 return m_database->backend();
384 } 397 }
385 398
386 } // namespace WebCore 399 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698