| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 GetDatabaseNamesCallback(PassRefPtr<RequestDatabaseNamesCallback> requestCal
lback, const String& securityOrigin) | 128 GetDatabaseNamesCallback(PassRefPtr<RequestDatabaseNamesCallback> requestCal
lback, const String& securityOrigin) |
| 129 : EventListener(EventListener::CPPEventListenerType) | 129 : EventListener(EventListener::CPPEventListenerType) |
| 130 , m_requestCallback(requestCallback) | 130 , m_requestCallback(requestCallback) |
| 131 , m_securityOrigin(securityOrigin) { } | 131 , m_securityOrigin(securityOrigin) { } |
| 132 RefPtr<RequestDatabaseNamesCallback> m_requestCallback; | 132 RefPtr<RequestDatabaseNamesCallback> m_requestCallback; |
| 133 String m_securityOrigin; | 133 String m_securityOrigin; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 class ExecutableWithDatabase : public RefCounted<ExecutableWithDatabase> { | 136 class ExecutableWithDatabase : public RefCounted<ExecutableWithDatabase> { |
| 137 public: | 137 public: |
| 138 ExecutableWithDatabase(ExecutionContext* context) | 138 ExecutableWithDatabase(NewScriptState* scriptState) |
| 139 : m_context(context) { } | 139 : m_scriptState(scriptState) { } |
| 140 virtual ~ExecutableWithDatabase() { }; | 140 virtual ~ExecutableWithDatabase() { }; |
| 141 void start(IDBFactory*, SecurityOrigin*, const String& databaseName); | 141 void start(IDBFactory*, SecurityOrigin*, const String& databaseName); |
| 142 virtual void execute(PassRefPtr<IDBDatabase>) = 0; | 142 virtual void execute(PassRefPtr<IDBDatabase>) = 0; |
| 143 virtual RequestCallback* requestCallback() = 0; | 143 virtual RequestCallback* requestCallback() = 0; |
| 144 ExecutionContext* context() { return m_context; }; | 144 ExecutionContext* context() const { return m_scriptState->executionContext()
; } |
| 145 NewScriptState* scriptState() const { return m_scriptState.get(); } |
| 145 private: | 146 private: |
| 146 ExecutionContext* m_context; | 147 RefPtr<NewScriptState> m_scriptState; |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 class OpenDatabaseCallback FINAL : public EventListener { | 150 class OpenDatabaseCallback FINAL : public EventListener { |
| 150 public: | 151 public: |
| 151 static PassRefPtr<OpenDatabaseCallback> create(ExecutableWithDatabase* execu
tableWithDatabase) | 152 static PassRefPtr<OpenDatabaseCallback> create(ExecutableWithDatabase* execu
tableWithDatabase) |
| 152 { | 153 { |
| 153 return adoptRef(new OpenDatabaseCallback(executableWithDatabase)); | 154 return adoptRef(new OpenDatabaseCallback(executableWithDatabase)); |
| 154 } | 155 } |
| 155 | 156 |
| 156 virtual ~OpenDatabaseCallback() { } | 157 virtual ~OpenDatabaseCallback() { } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 249 } |
| 249 default: | 250 default: |
| 250 ASSERT_NOT_REACHED(); | 251 ASSERT_NOT_REACHED(); |
| 251 } | 252 } |
| 252 | 253 |
| 253 return keyPath.release(); | 254 return keyPath.release(); |
| 254 } | 255 } |
| 255 | 256 |
| 256 class DatabaseLoader FINAL : public ExecutableWithDatabase { | 257 class DatabaseLoader FINAL : public ExecutableWithDatabase { |
| 257 public: | 258 public: |
| 258 static PassRefPtr<DatabaseLoader> create(ExecutionContext* context, PassRefP
tr<RequestDatabaseCallback> requestCallback) | 259 static PassRefPtr<DatabaseLoader> create(NewScriptState* scriptState, PassRe
fPtr<RequestDatabaseCallback> requestCallback) |
| 259 { | 260 { |
| 260 return adoptRef(new DatabaseLoader(context, requestCallback)); | 261 return adoptRef(new DatabaseLoader(scriptState, requestCallback)); |
| 261 } | 262 } |
| 262 | 263 |
| 263 virtual ~DatabaseLoader() { } | 264 virtual ~DatabaseLoader() { } |
| 264 | 265 |
| 265 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE | 266 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
| 266 { | 267 { |
| 267 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 268 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
| 268 if (!requestCallback()->isActive()) | 269 if (!requestCallback()->isActive()) |
| 269 return; | 270 return; |
| 270 | 271 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 299 .setName(databaseMetadata.name) | 300 .setName(databaseMetadata.name) |
| 300 .setIntVersion(databaseMetadata.intVersion) | 301 .setIntVersion(databaseMetadata.intVersion) |
| 301 .setVersion(databaseMetadata.version) | 302 .setVersion(databaseMetadata.version) |
| 302 .setObjectStores(objectStores); | 303 .setObjectStores(objectStores); |
| 303 | 304 |
| 304 m_requestCallback->sendSuccess(result); | 305 m_requestCallback->sendSuccess(result); |
| 305 } | 306 } |
| 306 | 307 |
| 307 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } | 308 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } |
| 308 private: | 309 private: |
| 309 DatabaseLoader(ExecutionContext* context, PassRefPtr<RequestDatabaseCallback
> requestCallback) | 310 DatabaseLoader(NewScriptState* scriptState, PassRefPtr<RequestDatabaseCallba
ck> requestCallback) |
| 310 : ExecutableWithDatabase(context) | 311 : ExecutableWithDatabase(scriptState) |
| 311 , m_requestCallback(requestCallback) { } | 312 , m_requestCallback(requestCallback) { } |
| 312 RefPtr<RequestDatabaseCallback> m_requestCallback; | 313 RefPtr<RequestDatabaseCallback> m_requestCallback; |
| 313 }; | 314 }; |
| 314 | 315 |
| 315 static PassRefPtr<IDBKey> idbKeyFromInspectorObject(JSONObject* key) | 316 static PassRefPtr<IDBKey> idbKeyFromInspectorObject(JSONObject* key) |
| 316 { | 317 { |
| 317 RefPtr<IDBKey> idbKey; | 318 RefPtr<IDBKey> idbKey; |
| 318 | 319 |
| 319 String type; | 320 String type; |
| 320 if (!key->getString("type", &type)) | 321 if (!key->getString("type", &type)) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperB
oundOpen : IDBKeyRange::UpperBoundClosed; | 382 IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperB
oundOpen : IDBKeyRange::UpperBoundClosed; |
| 382 | 383 |
| 383 RefPtr<IDBKeyRange> idbKeyRange = IDBKeyRange::create(idbLower, idbUpper, lo
werBoundType, upperBoundType); | 384 RefPtr<IDBKeyRange> idbKeyRange = IDBKeyRange::create(idbLower, idbUpper, lo
werBoundType, upperBoundType); |
| 384 return idbKeyRange.release(); | 385 return idbKeyRange.release(); |
| 385 } | 386 } |
| 386 | 387 |
| 387 class DataLoader; | 388 class DataLoader; |
| 388 | 389 |
| 389 class OpenCursorCallback FINAL : public EventListener { | 390 class OpenCursorCallback FINAL : public EventListener { |
| 390 public: | 391 public: |
| 391 static PassRefPtr<OpenCursorCallback> create(PassRefPtr<RequestDataCallback>
requestCallback, int skipCount, unsigned pageSize) | 392 static PassRefPtr<OpenCursorCallback> create(NewScriptState* scriptState, Pa
ssRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize) |
| 392 { | 393 { |
| 393 return adoptRef(new OpenCursorCallback(requestCallback, skipCount, pageS
ize)); | 394 return adoptRef(new OpenCursorCallback(scriptState, requestCallback, ski
pCount, pageSize)); |
| 394 } | 395 } |
| 395 | 396 |
| 396 virtual ~OpenCursorCallback() { } | 397 virtual ~OpenCursorCallback() { } |
| 397 | 398 |
| 398 virtual bool operator==(const EventListener& other) OVERRIDE | 399 virtual bool operator==(const EventListener& other) OVERRIDE |
| 399 { | 400 { |
| 400 return this == &other; | 401 return this == &other; |
| 401 } | 402 } |
| 402 | 403 |
| 403 virtual void handleEvent(ExecutionContext* context, Event* event) OVERRIDE | 404 virtual void handleEvent(ExecutionContext*, Event* event) OVERRIDE |
| 404 { | 405 { |
| 405 if (event->type() != EventTypeNames::success) { | 406 if (event->type() != EventTypeNames::success) { |
| 406 m_requestCallback->sendFailure("Unexpected event type."); | 407 m_requestCallback->sendFailure("Unexpected event type."); |
| 407 return; | 408 return; |
| 408 } | 409 } |
| 409 | 410 |
| 410 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); | 411 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); |
| 411 RefPtr<IDBAny> requestResult = idbRequest->resultAsAny(); | 412 RefPtr<IDBAny> requestResult = idbRequest->resultAsAny(); |
| 412 if (requestResult->type() == IDBAny::BufferType) { | 413 if (requestResult->type() == IDBAny::BufferType) { |
| 413 end(false); | 414 end(false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 435 } | 436 } |
| 436 | 437 |
| 437 // Continue cursor before making injected script calls, otherwise transa
ction might be finished. | 438 // Continue cursor before making injected script calls, otherwise transa
ction might be finished. |
| 438 TrackExceptionState exceptionState; | 439 TrackExceptionState exceptionState; |
| 439 idbCursor->continueFunction(nullptr, nullptr, exceptionState); | 440 idbCursor->continueFunction(nullptr, nullptr, exceptionState); |
| 440 if (exceptionState.hadException()) { | 441 if (exceptionState.hadException()) { |
| 441 m_requestCallback->sendFailure("Could not continue cursor."); | 442 m_requestCallback->sendFailure("Could not continue cursor."); |
| 442 return; | 443 return; |
| 443 } | 444 } |
| 444 | 445 |
| 445 Document* document = toDocument(context); | 446 Document* document = toDocument(m_scriptState->executionContext()); |
| 446 if (!document) | 447 if (!document) |
| 447 return; | 448 return; |
| 448 ScriptState* scriptState = mainWorldScriptState(document->frame()); | 449 ScriptState* scriptState = mainWorldScriptState(document->frame()); |
| 449 | 450 |
| 450 RefPtr<DataEntry> dataEntry = DataEntry::create() | 451 RefPtr<DataEntry> dataEntry = DataEntry::create() |
| 451 .setKey(idbCursor->key(context).toJSONValue(scriptState)->toJSONStri
ng()) | 452 .setKey(idbCursor->key(m_scriptState.get()).toJSONValue(scriptState)
->toJSONString()) |
| 452 .setPrimaryKey(idbCursor->primaryKey(context).toJSONValue(scriptStat
e)->toJSONString()) | 453 .setPrimaryKey(idbCursor->primaryKey(m_scriptState.get()).toJSONValu
e(scriptState)->toJSONString()) |
| 453 .setValue(idbCursor->value(context).toJSONValue(scriptState)->toJSON
String()); | 454 .setValue(idbCursor->value(m_scriptState.get()).toJSONValue(scriptSt
ate)->toJSONString()); |
| 454 m_result->addItem(dataEntry); | 455 m_result->addItem(dataEntry); |
| 455 | 456 |
| 456 } | 457 } |
| 457 | 458 |
| 458 void end(bool hasMore) | 459 void end(bool hasMore) |
| 459 { | 460 { |
| 460 if (!m_requestCallback->isActive()) | 461 if (!m_requestCallback->isActive()) |
| 461 return; | 462 return; |
| 462 m_requestCallback->sendSuccess(m_result.release(), hasMore); | 463 m_requestCallback->sendSuccess(m_result.release(), hasMore); |
| 463 } | 464 } |
| 464 | 465 |
| 465 private: | 466 private: |
| 466 OpenCursorCallback(PassRefPtr<RequestDataCallback> requestCallback, int skip
Count, unsigned pageSize) | 467 OpenCursorCallback(NewScriptState* scriptState, PassRefPtr<RequestDataCallba
ck> requestCallback, int skipCount, unsigned pageSize) |
| 467 : EventListener(EventListener::CPPEventListenerType) | 468 : EventListener(EventListener::CPPEventListenerType) |
| 469 , m_scriptState(scriptState) |
| 468 , m_requestCallback(requestCallback) | 470 , m_requestCallback(requestCallback) |
| 469 , m_skipCount(skipCount) | 471 , m_skipCount(skipCount) |
| 470 , m_pageSize(pageSize) | 472 , m_pageSize(pageSize) |
| 471 { | 473 { |
| 472 m_result = Array<DataEntry>::create(); | 474 m_result = Array<DataEntry>::create(); |
| 473 } | 475 } |
| 476 |
| 477 RefPtr<NewScriptState> m_scriptState; |
| 474 RefPtr<RequestDataCallback> m_requestCallback; | 478 RefPtr<RequestDataCallback> m_requestCallback; |
| 475 int m_skipCount; | 479 int m_skipCount; |
| 476 unsigned m_pageSize; | 480 unsigned m_pageSize; |
| 477 RefPtr<Array<DataEntry> > m_result; | 481 RefPtr<Array<DataEntry> > m_result; |
| 478 }; | 482 }; |
| 479 | 483 |
| 480 class DataLoader FINAL : public ExecutableWithDatabase { | 484 class DataLoader FINAL : public ExecutableWithDatabase { |
| 481 public: | 485 public: |
| 482 static PassRefPtr<DataLoader> create(ExecutionContext* context, PassRefPtr<R
equestDataCallback> requestCallback, const String& objectStoreName, const String
& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSi
ze) | 486 static PassRefPtr<DataLoader> create(NewScriptState* scriptState, PassRefPtr
<RequestDataCallback> requestCallback, const String& objectStoreName, const Stri
ng& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned page
Size) |
| 483 { | 487 { |
| 484 return adoptRef(new DataLoader(context, requestCallback, objectStoreName
, indexName, idbKeyRange, skipCount, pageSize)); | 488 return adoptRef(new DataLoader(scriptState, requestCallback, objectStore
Name, indexName, idbKeyRange, skipCount, pageSize)); |
| 485 } | 489 } |
| 486 | 490 |
| 487 virtual ~DataLoader() { } | 491 virtual ~DataLoader() { } |
| 488 | 492 |
| 489 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE | 493 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
| 490 { | 494 { |
| 491 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 495 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
| 492 if (!requestCallback()->isActive()) | 496 if (!requestCallback()->isActive()) |
| 493 return; | 497 return; |
| 494 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context()
, idbDatabase.get(), m_objectStoreName); | 498 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context()
, idbDatabase.get(), m_objectStoreName); |
| 495 if (!idbTransaction) { | 499 if (!idbTransaction) { |
| 496 m_requestCallback->sendFailure("Could not get transaction"); | 500 m_requestCallback->sendFailure("Could not get transaction"); |
| 497 return; | 501 return; |
| 498 } | 502 } |
| 499 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); | 503 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); |
| 500 if (!idbObjectStore) { | 504 if (!idbObjectStore) { |
| 501 m_requestCallback->sendFailure("Could not get object store"); | 505 m_requestCallback->sendFailure("Could not get object store"); |
| 502 return; | 506 return; |
| 503 } | 507 } |
| 504 | 508 |
| 505 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea
te(m_requestCallback, m_skipCount, m_pageSize); | 509 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea
te(scriptState(), m_requestCallback, m_skipCount, m_pageSize); |
| 506 | 510 |
| 507 RefPtr<IDBRequest> idbRequest; | 511 RefPtr<IDBRequest> idbRequest; |
| 508 if (!m_indexName.isEmpty()) { | 512 if (!m_indexName.isEmpty()) { |
| 509 RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get()
, m_indexName); | 513 RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get()
, m_indexName); |
| 510 if (!idbIndex) { | 514 if (!idbIndex) { |
| 511 m_requestCallback->sendFailure("Could not get index"); | 515 m_requestCallback->sendFailure("Could not get index"); |
| 512 return; | 516 return; |
| 513 } | 517 } |
| 514 | 518 |
| 515 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>
(m_idbKeyRange), blink::WebIDBCursor::Next); | 519 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>
(m_idbKeyRange), blink::WebIDBCursor::Next); |
| 516 } else { | 520 } else { |
| 517 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey
Range>(m_idbKeyRange), blink::WebIDBCursor::Next); | 521 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey
Range>(m_idbKeyRange), blink::WebIDBCursor::Next); |
| 518 } | 522 } |
| 519 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); | 523 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); |
| 520 } | 524 } |
| 521 | 525 |
| 522 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } | 526 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } |
| 523 DataLoader(ExecutionContext* executionContext, PassRefPtr<RequestDataCallbac
k> requestCallback, const String& objectStoreName, const String& indexName, Pass
RefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) | 527 DataLoader(NewScriptState* scriptState, PassRefPtr<RequestDataCallback> requ
estCallback, const String& objectStoreName, const String& indexName, PassRefPtr<
IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) |
| 524 : ExecutableWithDatabase(executionContext) | 528 : ExecutableWithDatabase(scriptState) |
| 525 , m_requestCallback(requestCallback) | 529 , m_requestCallback(requestCallback) |
| 526 , m_objectStoreName(objectStoreName) | 530 , m_objectStoreName(objectStoreName) |
| 527 , m_indexName(indexName) | 531 , m_indexName(indexName) |
| 528 , m_idbKeyRange(idbKeyRange) | 532 , m_idbKeyRange(idbKeyRange) |
| 529 , m_skipCount(skipCount) | 533 , m_skipCount(skipCount) |
| 530 , m_pageSize(pageSize) { } | 534 , m_pageSize(pageSize) |
| 535 { |
| 536 } |
| 537 |
| 531 RefPtr<RequestDataCallback> m_requestCallback; | 538 RefPtr<RequestDataCallback> m_requestCallback; |
| 532 String m_objectStoreName; | 539 String m_objectStoreName; |
| 533 String m_indexName; | 540 String m_indexName; |
| 534 RefPtr<IDBKeyRange> m_idbKeyRange; | 541 RefPtr<IDBKeyRange> m_idbKeyRange; |
| 535 int m_skipCount; | 542 int m_skipCount; |
| 536 unsigned m_pageSize; | 543 unsigned m_pageSize; |
| 537 }; | 544 }; |
| 538 | 545 |
| 539 LocalFrame* findFrameWithSecurityOrigin(Page* page, const String& securityOrigin
) | 546 LocalFrame* findFrameWithSecurityOrigin(Page* page, const String& securityOrigin
) |
| 540 { | 547 { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 if (!idbFactory) | 655 if (!idbFactory) |
| 649 return; | 656 return; |
| 650 | 657 |
| 651 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 658 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 652 v8::Isolate* isolate = toIsolate(frame); | 659 v8::Isolate* isolate = toIsolate(frame); |
| 653 v8::HandleScope handleScope(isolate); | 660 v8::HandleScope handleScope(isolate); |
| 654 v8::Handle<v8::Context> context = toV8Context(isolate, document->frame(), DO
MWrapperWorld::mainWorld()); | 661 v8::Handle<v8::Context> context = toV8Context(isolate, document->frame(), DO
MWrapperWorld::mainWorld()); |
| 655 ASSERT(!context.IsEmpty()); | 662 ASSERT(!context.IsEmpty()); |
| 656 v8::Context::Scope contextScope(context); | 663 v8::Context::Scope contextScope(context); |
| 657 | 664 |
| 658 RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(document, req
uestCallback); | 665 RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(NewScriptStat
e::current(isolate), requestCallback); |
| 659 databaseLoader->start(idbFactory, document->securityOrigin(), databaseName); | 666 databaseLoader->start(idbFactory, document->securityOrigin(), databaseName); |
| 660 } | 667 } |
| 661 | 668 |
| 662 void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String
& securityOrigin, const String& databaseName, const String& objectStoreName, con
st String& indexName, int skipCount, int pageSize, const RefPtr<JSONObject>* key
Range, PassRefPtr<RequestDataCallback> requestCallback) | 669 void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String
& securityOrigin, const String& databaseName, const String& objectStoreName, con
st String& indexName, int skipCount, int pageSize, const RefPtr<JSONObject>* key
Range, PassRefPtr<RequestDataCallback> requestCallback) |
| 663 { | 670 { |
| 664 LocalFrame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); | 671 LocalFrame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
| 665 Document* document = assertDocument(errorString, frame); | 672 Document* document = assertDocument(errorString, frame); |
| 666 if (!document) | 673 if (!document) |
| 667 return; | 674 return; |
| 668 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 675 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
| 669 if (!idbFactory) | 676 if (!idbFactory) |
| 670 return; | 677 return; |
| 671 | 678 |
| 672 RefPtr<IDBKeyRange> idbKeyRange = keyRange ? idbKeyRangeFromKeyRange(keyRang
e->get()) : nullptr; | 679 RefPtr<IDBKeyRange> idbKeyRange = keyRange ? idbKeyRangeFromKeyRange(keyRang
e->get()) : nullptr; |
| 673 if (keyRange && !idbKeyRange) { | 680 if (keyRange && !idbKeyRange) { |
| 674 *errorString = "Can not parse key range."; | 681 *errorString = "Can not parse key range."; |
| 675 return; | 682 return; |
| 676 } | 683 } |
| 677 | 684 |
| 678 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 685 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 679 v8::Isolate* isolate = toIsolate(frame); | 686 v8::Isolate* isolate = toIsolate(frame); |
| 680 v8::HandleScope handleScope(isolate); | 687 v8::HandleScope handleScope(isolate); |
| 681 v8::Handle<v8::Context> context = toV8Context(isolate, document->frame(), DO
MWrapperWorld::mainWorld()); | 688 v8::Handle<v8::Context> context = toV8Context(isolate, document->frame(), DO
MWrapperWorld::mainWorld()); |
| 682 ASSERT(!context.IsEmpty()); | 689 ASSERT(!context.IsEmpty()); |
| 683 v8::Context::Scope contextScope(context); | 690 v8::Context::Scope contextScope(context); |
| 684 | 691 |
| 685 RefPtr<DataLoader> dataLoader = DataLoader::create(document, requestCallback
, objectStoreName, indexName, idbKeyRange, skipCount, pageSize); | 692 RefPtr<DataLoader> dataLoader = DataLoader::create(NewScriptState::current(i
solate), requestCallback, objectStoreName, indexName, idbKeyRange, skipCount, pa
geSize); |
| 686 dataLoader->start(idbFactory, document->securityOrigin(), databaseName); | 693 dataLoader->start(idbFactory, document->securityOrigin(), databaseName); |
| 687 } | 694 } |
| 688 | 695 |
| 689 class ClearObjectStoreListener FINAL : public EventListener { | 696 class ClearObjectStoreListener FINAL : public EventListener { |
| 690 WTF_MAKE_NONCOPYABLE(ClearObjectStoreListener); | 697 WTF_MAKE_NONCOPYABLE(ClearObjectStoreListener); |
| 691 public: | 698 public: |
| 692 static PassRefPtr<ClearObjectStoreListener> create(PassRefPtr<ClearObjectSto
reCallback> requestCallback) | 699 static PassRefPtr<ClearObjectStoreListener> create(PassRefPtr<ClearObjectSto
reCallback> requestCallback) |
| 693 { | 700 { |
| 694 return adoptRef(new ClearObjectStoreListener(requestCallback)); | 701 return adoptRef(new ClearObjectStoreListener(requestCallback)); |
| 695 } | 702 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 718 , m_requestCallback(requestCallback) | 725 , m_requestCallback(requestCallback) |
| 719 { | 726 { |
| 720 } | 727 } |
| 721 | 728 |
| 722 RefPtr<ClearObjectStoreCallback> m_requestCallback; | 729 RefPtr<ClearObjectStoreCallback> m_requestCallback; |
| 723 }; | 730 }; |
| 724 | 731 |
| 725 | 732 |
| 726 class ClearObjectStore FINAL : public ExecutableWithDatabase { | 733 class ClearObjectStore FINAL : public ExecutableWithDatabase { |
| 727 public: | 734 public: |
| 728 static PassRefPtr<ClearObjectStore> create(ExecutionContext* context, const
String& objectStoreName, PassRefPtr<ClearObjectStoreCallback> requestCallback) | 735 static PassRefPtr<ClearObjectStore> create(NewScriptState* scriptState, cons
t String& objectStoreName, PassRefPtr<ClearObjectStoreCallback> requestCallback) |
| 729 { | 736 { |
| 730 return adoptRef(new ClearObjectStore(context, objectStoreName, requestCa
llback)); | 737 return adoptRef(new ClearObjectStore(scriptState, objectStoreName, reque
stCallback)); |
| 731 } | 738 } |
| 732 | 739 |
| 733 ClearObjectStore(ExecutionContext* context, const String& objectStoreName, P
assRefPtr<ClearObjectStoreCallback> requestCallback) | 740 ClearObjectStore(NewScriptState* scriptState, const String& objectStoreName,
PassRefPtr<ClearObjectStoreCallback> requestCallback) |
| 734 : ExecutableWithDatabase(context) | 741 : ExecutableWithDatabase(scriptState) |
| 735 , m_objectStoreName(objectStoreName) | 742 , m_objectStoreName(objectStoreName) |
| 736 , m_requestCallback(requestCallback) | 743 , m_requestCallback(requestCallback) |
| 737 { | 744 { |
| 738 } | 745 } |
| 739 | 746 |
| 740 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE | 747 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
| 741 { | 748 { |
| 742 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 749 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
| 743 if (!requestCallback()->isActive()) | 750 if (!requestCallback()->isActive()) |
| 744 return; | 751 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 if (!idbFactory) | 787 if (!idbFactory) |
| 781 return; | 788 return; |
| 782 | 789 |
| 783 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 790 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 784 v8::Isolate* isolate = toIsolate(frame); | 791 v8::Isolate* isolate = toIsolate(frame); |
| 785 v8::HandleScope handleScope(isolate); | 792 v8::HandleScope handleScope(isolate); |
| 786 v8::Handle<v8::Context> context = toV8Context(isolate, document->frame(), DO
MWrapperWorld::mainWorld()); | 793 v8::Handle<v8::Context> context = toV8Context(isolate, document->frame(), DO
MWrapperWorld::mainWorld()); |
| 787 ASSERT(!context.IsEmpty()); | 794 ASSERT(!context.IsEmpty()); |
| 788 v8::Context::Scope contextScope(context); | 795 v8::Context::Scope contextScope(context); |
| 789 | 796 |
| 790 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen
t, objectStoreName, requestCallback); | 797 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(NewScri
ptState::current(isolate), objectStoreName, requestCallback); |
| 791 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); | 798 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); |
| 792 } | 799 } |
| 793 | 800 |
| 794 } // namespace WebCore | 801 } // namespace WebCore |
| OLD | NEW |