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 21 matching lines...) Expand all Loading... | |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/dom/ExecutionContext.h" | 33 #include "core/dom/ExecutionContext.h" |
| 34 #include "core/inspector/ScriptCallStack.h" | 34 #include "core/inspector/ScriptCallStack.h" |
| 35 #include "modules/indexeddb/IDBAny.h" | 35 #include "modules/indexeddb/IDBAny.h" |
| 36 #include "modules/indexeddb/IDBDatabase.h" | 36 #include "modules/indexeddb/IDBDatabase.h" |
| 37 #include "modules/indexeddb/IDBKey.h" | 37 #include "modules/indexeddb/IDBKey.h" |
| 38 #include "modules/indexeddb/IDBObjectStore.h" | 38 #include "modules/indexeddb/IDBObjectStore.h" |
| 39 #include "modules/indexeddb/IDBRequest.h" | 39 #include "modules/indexeddb/IDBRequest.h" |
| 40 #include "modules/indexeddb/IDBTracing.h" | 40 #include "modules/indexeddb/IDBTracing.h" |
| 41 #include "modules/indexeddb/IDBTransaction.h" | 41 #include "modules/indexeddb/IDBTransaction.h" |
| 42 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | |
| 42 #include "platform/SharedBuffer.h" | 43 #include "platform/SharedBuffer.h" |
| 43 #include "platform/SharedBuffer.h" | 44 #include "platform/SharedBuffer.h" |
| 44 #include "public/platform/WebIDBCallbacks.h" | |
| 45 #include "public/platform/WebIDBCursor.h" | 45 #include "public/platform/WebIDBCursor.h" |
| 46 #include "public/platform/WebIDBDatabase.h" | 46 #include "public/platform/WebIDBDatabase.h" |
| 47 #include "public/platform/WebIDBKeyRange.h" | 47 #include "public/platform/WebIDBKeyRange.h" |
| 48 #include <limits> | 48 #include <limits> |
| 49 | 49 |
| 50 using blink::WebIDBDatabase; | 50 using blink::WebIDBDatabase; |
| 51 | 51 |
| 52 namespace WebCore { | 52 namespace WebCore { |
| 53 | 53 |
| 54 PassRefPtr<IDBCursor> IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, IndexedDB::CursorDirection direction, IDBRequest* request, IDBAny* source, IDBT ransaction* transaction) | 54 PassRefPtr<IDBCursor> IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, IndexedDB::CursorDirection direction, IDBRequest* request, IDBAny* source, IDBT ransaction* transaction) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 return; | 167 return; |
| 168 } | 168 } |
| 169 | 169 |
| 170 if (!count) { | 170 if (!count) { |
| 171 exceptionState.throwUninformativeAndGenericTypeError(); | 171 exceptionState.throwUninformativeAndGenericTypeError(); |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| 175 m_request->setPendingCursor(this); | 175 m_request->setPendingCursor(this); |
| 176 m_gotValue = false; | 176 m_gotValue = false; |
| 177 m_backend->advance(count, new blink::WebIDBCallbacks(m_request)); | 177 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k eyValue, ExceptionState& exceptionState) | 180 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k eyValue, ExceptionState& exceptionState) |
| 181 { | 181 { |
| 182 DOMRequestState requestState(context); | 182 DOMRequestState requestState(context); |
| 183 RefPtr<IDBKey> key = keyValue.isUndefined() ? 0 : scriptValueToIDBKey(&reque stState, keyValue); | 183 RefPtr<IDBKey> key = keyValue.isUndefined() ? 0 : scriptValueToIDBKey(&reque stState, keyValue); |
| 184 continueFunction(key.release(), exceptionState); | 184 continueFunction(key.release(), exceptionState); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& excepti onState) | 187 void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& excepti onState) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 exceptionState.throwDOMException(DataError, ExceptionMessages::f ailedToExecute("continue", "IDBCursor", "The parameter is greater than or equal to this cursor's position.")); | 223 exceptionState.throwDOMException(DataError, ExceptionMessages::f ailedToExecute("continue", "IDBCursor", "The parameter is greater than or equal to this cursor's position.")); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 // FIXME: We're not using the context from when continue was called, which m eans the callback | 229 // FIXME: We're not using the context from when continue was called, which m eans the callback |
| 230 // will be on the original context openCursor was called on. Is this right? | 230 // will be on the original context openCursor was called on. Is this right? |
| 231 m_request->setPendingCursor(this); | 231 m_request->setPendingCursor(this); |
| 232 m_gotValue = false; | 232 m_gotValue = false; |
| 233 m_backend->continueFunction(key, new blink::WebIDBCallbacks(m_request)); | 233 m_backend->continueFunction(key, WebIDBCallbacksImpl::create(m_request).leak Ptr()); |
|
alecflett
2013/11/22 18:19:05
ah now I see what you mean in the other patch abou
| |
| 234 } | 234 } |
| 235 | 235 |
| 236 PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* context, Exce ptionState& exceptionState) | 236 PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* context, Exce ptionState& exceptionState) |
| 237 { | 237 { |
| 238 IDB_TRACE("IDBCursor::delete"); | 238 IDB_TRACE("IDBCursor::delete"); |
| 239 if (m_transaction->isFinished()) { | 239 if (m_transaction->isFinished()) { |
| 240 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("delete", "IDBCursor", IDBDatabase::transactionFinishedErr orMessage)); | 240 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("delete", "IDBCursor", IDBDatabase::transactionFinishedErr orMessage)); |
| 241 return 0; | 241 return 0; |
| 242 } | 242 } |
| 243 if (!m_transaction->isActive()) { | 243 if (!m_transaction->isActive()) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 259 } | 259 } |
| 260 if (isDeleted()) { | 260 if (isDeleted()) { |
| 261 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("delete", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)); | 261 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("delete", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)); |
| 262 return 0; | 262 return 0; |
| 263 } | 263 } |
| 264 | 264 |
| 265 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, exceptionStat e); | 265 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, exceptionStat e); |
| 266 ASSERT(!exceptionState.hadException()); | 266 ASSERT(!exceptionState.hadException()); |
| 267 | 267 |
| 268 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); | 268 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); |
| 269 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange.release(), new blink::WebIDBCallbacks(request)); | 269 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr( )); |
| 270 return request.release(); | 270 return request.release(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void IDBCursor::postSuccessHandlerCallback() | 273 void IDBCursor::postSuccessHandlerCallback() |
| 274 { | 274 { |
| 275 if (m_backend) | 275 if (m_backend) |
| 276 m_backend->postSuccessHandlerCallback(); | 276 m_backend->postSuccessHandlerCallback(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void IDBCursor::close() | 279 void IDBCursor::close() |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 case IndexedDB::CursorPrevNoDuplicate: | 393 case IndexedDB::CursorPrevNoDuplicate: |
| 394 return IDBCursor::directionPrevUnique(); | 394 return IDBCursor::directionPrevUnique(); |
| 395 | 395 |
| 396 default: | 396 default: |
| 397 ASSERT_NOT_REACHED(); | 397 ASSERT_NOT_REACHED(); |
| 398 return IDBCursor::directionNext(); | 398 return IDBCursor::directionNext(); |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 | 401 |
| 402 } // namespace WebCore | 402 } // namespace WebCore |
| OLD | NEW |