OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase) | 185 OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase) |
186 : EventListener(EventListener::CPPEventListenerType) | 186 : EventListener(EventListener::CPPEventListenerType) |
187 , m_executableWithDatabase(executableWithDatabase) { } | 187 , m_executableWithDatabase(executableWithDatabase) { } |
188 RefPtr<ExecutableWithDatabase> m_executableWithDatabase; | 188 RefPtr<ExecutableWithDatabase> m_executableWithDatabase; |
189 }; | 189 }; |
190 | 190 |
191 void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons
t String& databaseName) | 191 void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons
t String& databaseName) |
192 { | 192 { |
193 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); | 193 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); |
194 TrackExceptionState exceptionState; | 194 TrackExceptionState exceptionState; |
195 RefPtrWillBeRawPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(con
text(), databaseName, exceptionState); | 195 RefPtrWillBeRawPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(scr
iptState(), databaseName, exceptionState); |
196 if (exceptionState.hadException()) { | 196 if (exceptionState.hadException()) { |
197 requestCallback()->sendFailure("Could not open database."); | 197 requestCallback()->sendFailure("Could not open database."); |
198 return; | 198 return; |
199 } | 199 } |
200 idbOpenDBRequest->addEventListener(EventTypeNames::success, callback, false)
; | 200 idbOpenDBRequest->addEventListener(EventTypeNames::success, callback, false)
; |
201 } | 201 } |
202 | 202 |
203 static PassRefPtrWillBeRawPtr<IDBTransaction> transactionForDatabase(ExecutionCo
ntext* executionContext, IDBDatabase* idbDatabase, const String& objectStoreName
, const String& mode = IDBTransaction::modeReadOnly()) | 203 static PassRefPtrWillBeRawPtr<IDBTransaction> transactionForDatabase(ExecutionCo
ntext* executionContext, IDBDatabase* idbDatabase, const String& objectStoreName
, const String& mode = IDBTransaction::modeReadOnly()) |
204 { | 204 { |
205 TrackExceptionState exceptionState; | 205 TrackExceptionState exceptionState; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea
te(scriptState(), m_requestCallback, m_skipCount, m_pageSize); | 506 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea
te(scriptState(), m_requestCallback, m_skipCount, m_pageSize); |
507 | 507 |
508 RefPtrWillBeRawPtr<IDBRequest> idbRequest; | 508 RefPtrWillBeRawPtr<IDBRequest> idbRequest; |
509 if (!m_indexName.isEmpty()) { | 509 if (!m_indexName.isEmpty()) { |
510 RefPtrWillBeRawPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjec
tStore.get(), m_indexName); | 510 RefPtrWillBeRawPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjec
tStore.get(), m_indexName); |
511 if (!idbIndex) { | 511 if (!idbIndex) { |
512 m_requestCallback->sendFailure("Could not get index"); | 512 m_requestCallback->sendFailure("Could not get index"); |
513 return; | 513 return; |
514 } | 514 } |
515 | 515 |
516 idbRequest = idbIndex->openCursor(context(), m_idbKeyRange.get(), bl
ink::WebIDBCursor::Next); | 516 idbRequest = idbIndex->openCursor(scriptState(), m_idbKeyRange.get()
, blink::WebIDBCursor::Next); |
517 } else { | 517 } else { |
518 idbRequest = idbObjectStore->openCursor(context(), m_idbKeyRange.get
(), blink::WebIDBCursor::Next); | 518 idbRequest = idbObjectStore->openCursor(scriptState(), m_idbKeyRange
.get(), blink::WebIDBCursor::Next); |
519 } | 519 } |
520 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); | 520 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); |
521 } | 521 } |
522 | 522 |
523 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } | 523 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } |
524 DataLoader(ScriptState* scriptState, PassRefPtr<RequestDataCallback> request
Callback, const String& objectStoreName, const String& indexName, PassRefPtrWill
BeRawPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) | 524 DataLoader(ScriptState* scriptState, PassRefPtr<RequestDataCallback> request
Callback, const String& objectStoreName, const String& indexName, PassRefPtrWill
BeRawPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) |
525 : ExecutableWithDatabase(scriptState) | 525 : ExecutableWithDatabase(scriptState) |
526 , m_requestCallback(requestCallback) | 526 , m_requestCallback(requestCallback) |
527 , m_objectStoreName(objectStoreName) | 527 , m_objectStoreName(objectStoreName) |
528 , m_indexName(indexName) | 528 , m_indexName(indexName) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 void InspectorIndexedDBAgent::requestDatabaseNames(ErrorString* errorString, con
st String& securityOrigin, PassRefPtr<RequestDatabaseNamesCallback> requestCallb
ack) | 619 void InspectorIndexedDBAgent::requestDatabaseNames(ErrorString* errorString, con
st String& securityOrigin, PassRefPtr<RequestDatabaseNamesCallback> requestCallb
ack) |
620 { | 620 { |
621 LocalFrame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); | 621 LocalFrame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
622 Document* document = assertDocument(errorString, frame); | 622 Document* document = assertDocument(errorString, frame); |
623 if (!document) | 623 if (!document) |
624 return; | 624 return; |
625 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 625 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
626 if (!idbFactory) | 626 if (!idbFactory) |
627 return; | 627 return; |
628 | 628 |
629 ScriptState::Scope scope(ScriptState::forMainWorld(frame)); | 629 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 630 ScriptState::Scope scope(scriptState); |
630 TrackExceptionState exceptionState; | 631 TrackExceptionState exceptionState; |
631 RefPtrWillBeRawPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(doc
ument, exceptionState); | 632 RefPtrWillBeRawPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(scr
iptState, exceptionState); |
632 if (exceptionState.hadException()) { | 633 if (exceptionState.hadException()) { |
633 requestCallback->sendFailure("Could not obtain database names."); | 634 requestCallback->sendFailure("Could not obtain database names."); |
634 return; | 635 return; |
635 } | 636 } |
636 idbRequest->addEventListener(EventTypeNames::success, GetDatabaseNamesCallba
ck::create(requestCallback, document->securityOrigin()->toRawString()), false); | 637 idbRequest->addEventListener(EventTypeNames::success, GetDatabaseNamesCallba
ck::create(requestCallback, document->securityOrigin()->toRawString()), false); |
637 } | 638 } |
638 | 639 |
639 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St
ring& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCall
back> requestCallback) | 640 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St
ring& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCall
back> requestCallback) |
640 { | 641 { |
641 LocalFrame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); | 642 LocalFrame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return; | 737 return; |
737 } | 738 } |
738 RefPtrWillBeRawPtr<IDBObjectStore> idbObjectStore = objectStoreForTransa
ction(idbTransaction.get(), m_objectStoreName); | 739 RefPtrWillBeRawPtr<IDBObjectStore> idbObjectStore = objectStoreForTransa
ction(idbTransaction.get(), m_objectStoreName); |
739 if (!idbObjectStore) { | 740 if (!idbObjectStore) { |
740 m_requestCallback->sendFailure("Could not get object store"); | 741 m_requestCallback->sendFailure("Could not get object store"); |
741 return; | 742 return; |
742 } | 743 } |
743 | 744 |
744 TrackExceptionState exceptionState; | 745 TrackExceptionState exceptionState; |
745 // FXIME: Can we remove the local variable idbRequest? | 746 // FXIME: Can we remove the local variable idbRequest? |
746 RefPtrWillBeRawPtr<IDBRequest> idbRequest = idbObjectStore->clear(contex
t(), exceptionState); | 747 RefPtrWillBeRawPtr<IDBRequest> idbRequest = idbObjectStore->clear(script
State(), exceptionState); |
747 ASSERT(!exceptionState.hadException()); | 748 ASSERT(!exceptionState.hadException()); |
748 if (exceptionState.hadException()) { | 749 if (exceptionState.hadException()) { |
749 ExceptionCode ec = exceptionState.code(); | 750 ExceptionCode ec = exceptionState.code(); |
750 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); | 751 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); |
751 return; | 752 return; |
752 } | 753 } |
753 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(m_requestCallback), false); | 754 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(m_requestCallback), false); |
754 idbRequest.clear(); | 755 idbRequest.clear(); |
755 } | 756 } |
756 | 757 |
(...skipping 13 matching lines...) Expand all Loading... |
770 if (!idbFactory) | 771 if (!idbFactory) |
771 return; | 772 return; |
772 | 773 |
773 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 774 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
774 ScriptState::Scope scope(scriptState); | 775 ScriptState::Scope scope(scriptState); |
775 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(scriptS
tate, objectStoreName, requestCallback); | 776 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(scriptS
tate, objectStoreName, requestCallback); |
776 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); | 777 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); |
777 } | 778 } |
778 | 779 |
779 } // namespace WebCore | 780 } // namespace WebCore |
OLD | NEW |