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

Side by Side Diff: Source/WebCore/storage/IDBCursorBackendImpl.cpp

Issue 9121008: Merge 104252 - Source/WebCore: IndexedDB: fix cursor prefetch crash (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 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
« no previous file with comments | « Source/WebCore/storage/IDBCursorBackendImpl.h ('k') | no next file » | 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 29 matching lines...) Expand all
40 #include "SerializedScriptValue.h" 40 #include "SerializedScriptValue.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 IDBCursorBackendImpl::IDBCursorBackendImpl(PassRefPtr<IDBBackingStore::Cursor> c ursor, IDBCursor::Direction direction, CursorType cursorType, IDBTransactionBack endInterface* transaction, IDBObjectStoreBackendInterface* objectStore) 44 IDBCursorBackendImpl::IDBCursorBackendImpl(PassRefPtr<IDBBackingStore::Cursor> c ursor, IDBCursor::Direction direction, CursorType cursorType, IDBTransactionBack endInterface* transaction, IDBObjectStoreBackendInterface* objectStore)
45 : m_cursor(cursor) 45 : m_cursor(cursor)
46 , m_direction(direction) 46 , m_direction(direction)
47 , m_cursorType(cursorType) 47 , m_cursorType(cursorType)
48 , m_transaction(transaction) 48 , m_transaction(transaction)
49 , m_objectStore(objectStore) 49 , m_objectStore(objectStore)
50 , m_closed(false)
50 { 51 {
51 m_transaction->registerOpenCursor(this); 52 m_transaction->registerOpenCursor(this);
52 } 53 }
53 54
54 IDBCursorBackendImpl::~IDBCursorBackendImpl() 55 IDBCursorBackendImpl::~IDBCursorBackendImpl()
55 { 56 {
56 m_transaction->unregisterOpenCursor(this); 57 m_transaction->unregisterOpenCursor(this);
58 // Order is important, the cursors have to be destructed before the objectSt ore.
59 m_cursor.clear();
60 m_savedCursor.clear();
61
62 m_objectStore.clear();
57 } 63 }
58 64
59 unsigned short IDBCursorBackendImpl::direction() const 65 unsigned short IDBCursorBackendImpl::direction() const
60 { 66 {
61 return m_direction; 67 return m_direction;
62 } 68 }
63 69
64 PassRefPtr<IDBKey> IDBCursorBackendImpl::key() const 70 PassRefPtr<IDBKey> IDBCursorBackendImpl::key() const
65 { 71 {
66 return m_cursor->key(); 72 return m_cursor->key();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 cursor->m_transaction->addPendingEvents(foundKeys.size() - 1); 173 cursor->m_transaction->addPendingEvents(foundKeys.size() - 1);
168 callbacks->onSuccessWithPrefetch(foundKeys, foundPrimaryKeys, foundValues); 174 callbacks->onSuccessWithPrefetch(foundKeys, foundPrimaryKeys, foundValues);
169 } 175 }
170 176
171 void IDBCursorBackendImpl::prefetchReset(int usedPrefetches, int unusedPrefetche s) 177 void IDBCursorBackendImpl::prefetchReset(int usedPrefetches, int unusedPrefetche s)
172 { 178 {
173 m_transaction->addPendingEvents(-unusedPrefetches); 179 m_transaction->addPendingEvents(-unusedPrefetches);
174 m_cursor = m_savedCursor; 180 m_cursor = m_savedCursor;
175 m_savedCursor = 0; 181 m_savedCursor = 0;
176 182
183 if (m_closed)
184 return;
177 if (m_cursor) { 185 if (m_cursor) {
178 for (int i = 0; i < usedPrefetches; ++i) { 186 for (int i = 0; i < usedPrefetches; ++i) {
179 bool ok = m_cursor->continueFunction(); 187 bool ok = m_cursor->continueFunction();
180 ASSERT_UNUSED(ok, ok); 188 ASSERT_UNUSED(ok, ok);
181 } 189 }
182 } 190 }
183 } 191 }
184 192
185 void IDBCursorBackendImpl::close() 193 void IDBCursorBackendImpl::close()
186 { 194 {
195 m_closed = true;
187 if (m_cursor) 196 if (m_cursor)
188 m_cursor->close(); 197 m_cursor->close();
189 } 198 }
190 199
191 } // namespace WebCore 200 } // namespace WebCore
192 201
193 #endif // ENABLE(INDEXED_DATABASE) 202 #endif // ENABLE(INDEXED_DATABASE)
OLDNEW
« no previous file with comments | « Source/WebCore/storage/IDBCursorBackendImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698