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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); | 194 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); |
195 TrackExceptionState exceptionState; | 195 TrackExceptionState exceptionState; |
196 IDBOpenDBRequest* idbOpenDBRequest = idbFactory->open(scriptState(), databas
eName, exceptionState); | 196 IDBOpenDBRequest* idbOpenDBRequest = idbFactory->open(scriptState(), databas
eName, exceptionState); |
197 if (exceptionState.hadException()) { | 197 if (exceptionState.hadException()) { |
198 requestCallback()->sendFailure("Could not open database."); | 198 requestCallback()->sendFailure("Could not open database."); |
199 return; | 199 return; |
200 } | 200 } |
201 idbOpenDBRequest->addEventListener(EventTypeNames::success, callback, false)
; | 201 idbOpenDBRequest->addEventListener(EventTypeNames::success, callback, false)
; |
202 } | 202 } |
203 | 203 |
204 static IDBTransaction* transactionForDatabase(ExecutionContext* executionContext
, IDBDatabase* idbDatabase, const String& objectStoreName, const String& mode =
IndexedDBNames::readonly) | 204 static IDBTransaction* transactionForDatabase(ScriptState* scriptState, IDBDatab
ase* idbDatabase, const String& objectStoreName, const String& mode = IndexedDBN
ames::readonly) |
205 { | 205 { |
206 TrackExceptionState exceptionState; | 206 TrackExceptionState exceptionState; |
207 IDBTransaction* idbTransaction = idbDatabase->transaction(executionContext,
objectStoreName, mode, exceptionState); | 207 IDBTransaction* idbTransaction = idbDatabase->transaction(scriptState, objec
tStoreName, mode, exceptionState); |
208 if (exceptionState.hadException()) | 208 if (exceptionState.hadException()) |
209 return 0; | 209 return 0; |
210 return idbTransaction; | 210 return idbTransaction; |
211 } | 211 } |
212 | 212 |
213 static IDBObjectStore* objectStoreForTransaction(IDBTransaction* idbTransaction,
const String& objectStoreName) | 213 static IDBObjectStore* objectStoreForTransaction(IDBTransaction* idbTransaction,
const String& objectStoreName) |
214 { | 214 { |
215 TrackExceptionState exceptionState; | 215 TrackExceptionState exceptionState; |
216 IDBObjectStore* idbObjectStore = idbTransaction->objectStore(objectStoreName
, exceptionState); | 216 IDBObjectStore* idbObjectStore = idbTransaction->objectStore(objectStoreName
, exceptionState); |
217 if (exceptionState.hadException()) | 217 if (exceptionState.hadException()) |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 { | 484 { |
485 return adoptRef(new DataLoader(scriptState, requestCallback, objectStore
Name, indexName, idbKeyRange, skipCount, pageSize)); | 485 return adoptRef(new DataLoader(scriptState, requestCallback, objectStore
Name, indexName, idbKeyRange, skipCount, pageSize)); |
486 } | 486 } |
487 | 487 |
488 virtual ~DataLoader() { } | 488 virtual ~DataLoader() { } |
489 | 489 |
490 virtual void execute(IDBDatabase* idbDatabase) OVERRIDE | 490 virtual void execute(IDBDatabase* idbDatabase) OVERRIDE |
491 { | 491 { |
492 if (!requestCallback()->isActive()) | 492 if (!requestCallback()->isActive()) |
493 return; | 493 return; |
494 IDBTransaction* idbTransaction = transactionForDatabase(context(), idbDa
tabase, m_objectStoreName); | 494 IDBTransaction* idbTransaction = transactionForDatabase(scriptState(), i
dbDatabase, m_objectStoreName); |
495 if (!idbTransaction) { | 495 if (!idbTransaction) { |
496 m_requestCallback->sendFailure("Could not get transaction"); | 496 m_requestCallback->sendFailure("Could not get transaction"); |
497 return; | 497 return; |
498 } | 498 } |
499 IDBObjectStore* idbObjectStore = objectStoreForTransaction(idbTransactio
n, m_objectStoreName); | 499 IDBObjectStore* idbObjectStore = objectStoreForTransaction(idbTransactio
n, m_objectStoreName); |
500 if (!idbObjectStore) { | 500 if (!idbObjectStore) { |
501 m_requestCallback->sendFailure("Could not get object store"); | 501 m_requestCallback->sendFailure("Could not get object store"); |
502 return; | 502 return; |
503 } | 503 } |
504 | 504 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 : ExecutableWithDatabase(scriptState) | 724 : ExecutableWithDatabase(scriptState) |
725 , m_objectStoreName(objectStoreName) | 725 , m_objectStoreName(objectStoreName) |
726 , m_requestCallback(requestCallback) | 726 , m_requestCallback(requestCallback) |
727 { | 727 { |
728 } | 728 } |
729 | 729 |
730 virtual void execute(IDBDatabase* idbDatabase) OVERRIDE | 730 virtual void execute(IDBDatabase* idbDatabase) OVERRIDE |
731 { | 731 { |
732 if (!requestCallback()->isActive()) | 732 if (!requestCallback()->isActive()) |
733 return; | 733 return; |
734 IDBTransaction* idbTransaction = transactionForDatabase(context(), idbDa
tabase, m_objectStoreName, IndexedDBNames::readwrite); | 734 IDBTransaction* idbTransaction = transactionForDatabase(scriptState(), i
dbDatabase, m_objectStoreName, IndexedDBNames::readwrite); |
735 if (!idbTransaction) { | 735 if (!idbTransaction) { |
736 m_requestCallback->sendFailure("Could not get transaction"); | 736 m_requestCallback->sendFailure("Could not get transaction"); |
737 return; | 737 return; |
738 } | 738 } |
739 IDBObjectStore* idbObjectStore = objectStoreForTransaction(idbTransactio
n, m_objectStoreName); | 739 IDBObjectStore* idbObjectStore = objectStoreForTransaction(idbTransactio
n, m_objectStoreName); |
740 if (!idbObjectStore) { | 740 if (!idbObjectStore) { |
741 m_requestCallback->sendFailure("Could not get object store"); | 741 m_requestCallback->sendFailure("Could not get object store"); |
742 return; | 742 return; |
743 } | 743 } |
744 | 744 |
(...skipping 30 matching lines...) Expand all Loading... |
775 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); | 775 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); |
776 } | 776 } |
777 | 777 |
778 void InspectorIndexedDBAgent::trace(Visitor* visitor) | 778 void InspectorIndexedDBAgent::trace(Visitor* visitor) |
779 { | 779 { |
780 visitor->trace(m_page); | 780 visitor->trace(m_page); |
781 InspectorBaseAgent::trace(visitor); | 781 InspectorBaseAgent::trace(visitor); |
782 } | 782 } |
783 | 783 |
784 } // namespace blink | 784 } // namespace blink |
OLD | NEW |