Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/InspectorIndexedDBAgent.h" | 32 #include "modules/indexeddb/InspectorIndexedDBAgent.h" |
| 33 | 33 |
| 34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
| 35 #include "bindings/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 36 #include "bindings/v8/ScriptController.h" | 36 #include "bindings/v8/ScriptController.h" |
| 37 #include "bindings/v8/ScriptState.h" | |
| 37 #include "core/dom/DOMStringList.h" | 38 #include "core/dom/DOMStringList.h" |
| 38 #include "core/dom/Document.h" | 39 #include "core/dom/Document.h" |
| 39 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
| 40 #include "core/events/EventListener.h" | 41 #include "core/events/EventListener.h" |
| 41 #include "core/inspector/InjectedScript.h" | 42 #include "core/frame/Frame.h" |
| 42 #include "core/inspector/InspectorPageAgent.h" | 43 #include "core/inspector/InspectorController.h" |
| 43 #include "core/inspector/InspectorState.h" | 44 #include "core/inspector/InspectorState.h" |
| 44 #include "core/frame/Frame.h" | 45 #include "core/page/Page.h" |
| 45 #include "modules/indexeddb/DOMWindowIndexedDatabase.h" | 46 #include "modules/indexeddb/DOMWindowIndexedDatabase.h" |
| 46 #include "modules/indexeddb/IDBCursor.h" | 47 #include "modules/indexeddb/IDBCursor.h" |
| 47 #include "modules/indexeddb/IDBCursorWithValue.h" | 48 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 48 #include "modules/indexeddb/IDBDatabase.h" | 49 #include "modules/indexeddb/IDBDatabase.h" |
| 49 #include "modules/indexeddb/IDBFactory.h" | 50 #include "modules/indexeddb/IDBFactory.h" |
| 50 #include "modules/indexeddb/IDBIndex.h" | 51 #include "modules/indexeddb/IDBIndex.h" |
| 51 #include "modules/indexeddb/IDBKey.h" | 52 #include "modules/indexeddb/IDBKey.h" |
| 52 #include "modules/indexeddb/IDBKeyPath.h" | 53 #include "modules/indexeddb/IDBKeyPath.h" |
| 53 #include "modules/indexeddb/IDBKeyRange.h" | 54 #include "modules/indexeddb/IDBKeyRange.h" |
| 54 #include "modules/indexeddb/IDBMetadata.h" | 55 #include "modules/indexeddb/IDBMetadata.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 IDBKey::KeyArray keyArray; | 344 IDBKey::KeyArray keyArray; |
| 344 RefPtr<JSONArray> array = key->getArray("array"); | 345 RefPtr<JSONArray> array = key->getArray("array"); |
| 345 for (size_t i = 0; i < array->length(); ++i) { | 346 for (size_t i = 0; i < array->length(); ++i) { |
| 346 RefPtr<JSONValue> value = array->get(i); | 347 RefPtr<JSONValue> value = array->get(i); |
| 347 RefPtr<JSONObject> object; | 348 RefPtr<JSONObject> object; |
| 348 if (!value->asObject(&object)) | 349 if (!value->asObject(&object)) |
| 349 return 0; | 350 return 0; |
| 350 keyArray.append(idbKeyFromInspectorObject(object.get())); | 351 keyArray.append(idbKeyFromInspectorObject(object.get())); |
| 351 } | 352 } |
| 352 idbKey = IDBKey::createArray(keyArray); | 353 idbKey = IDBKey::createArray(keyArray); |
| 353 } else | 354 } else { |
| 354 return 0; | 355 return 0; |
| 356 } | |
| 355 | 357 |
| 356 return idbKey.release(); | 358 return idbKey.release(); |
| 357 } | 359 } |
| 358 | 360 |
| 359 static PassRefPtr<IDBKeyRange> idbKeyRangeFromKeyRange(JSONObject* keyRange) | 361 static PassRefPtr<IDBKeyRange> idbKeyRangeFromKeyRange(JSONObject* keyRange) |
| 360 { | 362 { |
| 361 RefPtr<JSONObject> lower = keyRange->getObject("lower"); | 363 RefPtr<JSONObject> lower = keyRange->getObject("lower"); |
| 362 RefPtr<IDBKey> idbLower = lower ? idbKeyFromInspectorObject(lower.get()) : 0 ; | 364 RefPtr<IDBKey> idbLower = lower ? idbKeyFromInspectorObject(lower.get()) : 0 ; |
| 363 if (lower && !idbLower) | 365 if (lower && !idbLower) |
| 364 return 0; | 366 return 0; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 379 IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperB oundOpen : IDBKeyRange::UpperBoundClosed; | 381 IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperB oundOpen : IDBKeyRange::UpperBoundClosed; |
| 380 | 382 |
| 381 RefPtr<IDBKeyRange> idbKeyRange = IDBKeyRange::create(idbLower, idbUpper, lo werBoundType, upperBoundType); | 383 RefPtr<IDBKeyRange> idbKeyRange = IDBKeyRange::create(idbLower, idbUpper, lo werBoundType, upperBoundType); |
| 382 return idbKeyRange.release(); | 384 return idbKeyRange.release(); |
| 383 } | 385 } |
| 384 | 386 |
| 385 class DataLoader; | 387 class DataLoader; |
| 386 | 388 |
| 387 class OpenCursorCallback FINAL : public EventListener { | 389 class OpenCursorCallback FINAL : public EventListener { |
| 388 public: | 390 public: |
| 389 static PassRefPtr<OpenCursorCallback> create(InjectedScript injectedScript, PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSiz e) | 391 static PassRefPtr<OpenCursorCallback> create(PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize) |
| 390 { | 392 { |
| 391 return adoptRef(new OpenCursorCallback(injectedScript, requestCallback, skipCount, pageSize)); | 393 return adoptRef(new OpenCursorCallback(requestCallback, skipCount, pageS ize)); |
| 392 } | 394 } |
| 393 | 395 |
| 394 virtual ~OpenCursorCallback() { } | 396 virtual ~OpenCursorCallback() { } |
| 395 | 397 |
| 396 virtual bool operator==(const EventListener& other) OVERRIDE | 398 virtual bool operator==(const EventListener& other) OVERRIDE |
| 397 { | 399 { |
| 398 return this == &other; | 400 return this == &other; |
| 399 } | 401 } |
| 400 | 402 |
| 401 virtual void handleEvent(ExecutionContext* context, Event* event) OVERRIDE | 403 virtual void handleEvent(ExecutionContext* context, Event* event) OVERRIDE |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 } | 435 } |
| 434 | 436 |
| 435 // Continue cursor before making injected script calls, otherwise transa ction might be finished. | 437 // Continue cursor before making injected script calls, otherwise transa ction might be finished. |
| 436 TrackExceptionState exceptionState; | 438 TrackExceptionState exceptionState; |
| 437 idbCursor->continueFunction(0, 0, exceptionState); | 439 idbCursor->continueFunction(0, 0, exceptionState); |
| 438 if (exceptionState.hadException()) { | 440 if (exceptionState.hadException()) { |
| 439 m_requestCallback->sendFailure("Could not continue cursor."); | 441 m_requestCallback->sendFailure("Could not continue cursor."); |
| 440 return; | 442 return; |
| 441 } | 443 } |
| 442 | 444 |
| 445 Document* document = toDocument(context); | |
| 446 if (!document) | |
| 447 return; | |
| 448 ScriptState* scriptState = mainWorldScriptState(document->frame()); | |
| 449 | |
| 443 RefPtr<DataEntry> dataEntry = DataEntry::create() | 450 RefPtr<DataEntry> dataEntry = DataEntry::create() |
| 444 .setKey(m_injectedScript.wrapObject(idbCursor->key(context), String( ))) | 451 .setKey(idbCursor->key(context).toJSONValue(scriptState)->toJSONStri ng()) |
|
vsevik
2014/06/04 05:48:32
With this change we need to transfer all the (pote
| |
| 445 .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(con text), String())) | 452 .setPrimaryKey(idbCursor->primaryKey(context).toJSONValue(scriptStat e)->toJSONString()) |
| 446 .setValue(m_injectedScript.wrapObject(idbCursor->value(context), Str ing())); | 453 .setValue(idbCursor->value(context).toJSONValue(scriptState)->toJSON String()); |
| 447 m_result->addItem(dataEntry); | 454 m_result->addItem(dataEntry); |
| 448 | 455 |
| 449 } | 456 } |
| 450 | 457 |
| 451 void end(bool hasMore) | 458 void end(bool hasMore) |
| 452 { | 459 { |
| 453 if (!m_requestCallback->isActive()) | 460 if (!m_requestCallback->isActive()) |
| 454 return; | 461 return; |
| 455 m_requestCallback->sendSuccess(m_result.release(), hasMore); | 462 m_requestCallback->sendSuccess(m_result.release(), hasMore); |
| 456 } | 463 } |
| 457 | 464 |
| 458 private: | 465 private: |
| 459 OpenCursorCallback(InjectedScript injectedScript, PassRefPtr<RequestDataCall back> requestCallback, int skipCount, unsigned pageSize) | 466 OpenCursorCallback(PassRefPtr<RequestDataCallback> requestCallback, int skip Count, unsigned pageSize) |
| 460 : EventListener(EventListener::CPPEventListenerType) | 467 : EventListener(EventListener::CPPEventListenerType) |
| 461 , m_injectedScript(injectedScript) | |
| 462 , m_requestCallback(requestCallback) | 468 , m_requestCallback(requestCallback) |
| 463 , m_skipCount(skipCount) | 469 , m_skipCount(skipCount) |
| 464 , m_pageSize(pageSize) | 470 , m_pageSize(pageSize) |
| 465 { | 471 { |
| 466 m_result = Array<DataEntry>::create(); | 472 m_result = Array<DataEntry>::create(); |
| 467 } | 473 } |
| 468 InjectedScript m_injectedScript; | |
| 469 RefPtr<RequestDataCallback> m_requestCallback; | 474 RefPtr<RequestDataCallback> m_requestCallback; |
| 470 int m_skipCount; | 475 int m_skipCount; |
| 471 unsigned m_pageSize; | 476 unsigned m_pageSize; |
| 472 RefPtr<Array<DataEntry> > m_result; | 477 RefPtr<Array<DataEntry> > m_result; |
| 473 }; | 478 }; |
| 474 | 479 |
| 475 class DataLoader FINAL : public ExecutableWithDatabase { | 480 class DataLoader FINAL : public ExecutableWithDatabase { |
| 476 public: | 481 public: |
| 477 static PassRefPtr<DataLoader> create(ExecutionContext* context, PassRefPtr<R equestDataCallback> requestCallback, const InjectedScript& injectedScript, const String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKe yRange, int skipCount, unsigned pageSize) | 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) |
| 478 { | 483 { |
| 479 return adoptRef(new DataLoader(context, requestCallback, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize)); | 484 return adoptRef(new DataLoader(context, requestCallback, objectStoreName , indexName, idbKeyRange, skipCount, pageSize)); |
| 480 } | 485 } |
| 481 | 486 |
| 482 virtual ~DataLoader() { } | 487 virtual ~DataLoader() { } |
| 483 | 488 |
| 484 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE | 489 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
| 485 { | 490 { |
| 486 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 491 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
| 487 if (!requestCallback()->isActive()) | 492 if (!requestCallback()->isActive()) |
| 488 return; | 493 return; |
| 489 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context() , idbDatabase.get(), m_objectStoreName); | 494 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context() , idbDatabase.get(), m_objectStoreName); |
| 490 if (!idbTransaction) { | 495 if (!idbTransaction) { |
| 491 m_requestCallback->sendFailure("Could not get transaction"); | 496 m_requestCallback->sendFailure("Could not get transaction"); |
| 492 return; | 497 return; |
| 493 } | 498 } |
| 494 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra nsaction.get(), m_objectStoreName); | 499 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra nsaction.get(), m_objectStoreName); |
| 495 if (!idbObjectStore) { | 500 if (!idbObjectStore) { |
| 496 m_requestCallback->sendFailure("Could not get object store"); | 501 m_requestCallback->sendFailure("Could not get object store"); |
| 497 return; | 502 return; |
| 498 } | 503 } |
| 499 | 504 |
| 500 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea te(m_injectedScript, m_requestCallback, m_skipCount, m_pageSize); | 505 RefPtr<OpenCursorCallback> openCursorCallback = OpenCursorCallback::crea te(m_requestCallback, m_skipCount, m_pageSize); |
| 501 | 506 |
| 502 RefPtr<IDBRequest> idbRequest; | 507 RefPtr<IDBRequest> idbRequest; |
| 503 if (!m_indexName.isEmpty()) { | 508 if (!m_indexName.isEmpty()) { |
| 504 RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get() , m_indexName); | 509 RefPtr<IDBIndex> idbIndex = indexForObjectStore(idbObjectStore.get() , m_indexName); |
| 505 if (!idbIndex) { | 510 if (!idbIndex) { |
| 506 m_requestCallback->sendFailure("Could not get index"); | 511 m_requestCallback->sendFailure("Could not get index"); |
| 507 return; | 512 return; |
| 508 } | 513 } |
| 509 | 514 |
| 510 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange> (m_idbKeyRange), blink::WebIDBCursor::Next); | 515 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange> (m_idbKeyRange), blink::WebIDBCursor::Next); |
| 511 } else { | 516 } else { |
| 512 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey Range>(m_idbKeyRange), blink::WebIDBCursor::Next); | 517 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey Range>(m_idbKeyRange), blink::WebIDBCursor::Next); |
| 513 } | 518 } |
| 514 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback , false); | 519 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback , false); |
| 515 } | 520 } |
| 516 | 521 |
| 517 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba ck.get(); } | 522 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba ck.get(); } |
| 518 DataLoader(ExecutionContext* executionContext, PassRefPtr<RequestDataCallbac k> requestCallback, const InjectedScript& injectedScript, const String& objectSt oreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipC ount, unsigned pageSize) | 523 DataLoader(ExecutionContext* executionContext, PassRefPtr<RequestDataCallbac k> requestCallback, const String& objectStoreName, const String& indexName, Pass RefPtr<IDBKeyRange> idbKeyRange, int skipCount, unsigned pageSize) |
| 519 : ExecutableWithDatabase(executionContext) | 524 : ExecutableWithDatabase(executionContext) |
| 520 , m_requestCallback(requestCallback) | 525 , m_requestCallback(requestCallback) |
| 521 , m_injectedScript(injectedScript) | |
| 522 , m_objectStoreName(objectStoreName) | 526 , m_objectStoreName(objectStoreName) |
| 523 , m_indexName(indexName) | 527 , m_indexName(indexName) |
| 524 , m_idbKeyRange(idbKeyRange) | 528 , m_idbKeyRange(idbKeyRange) |
| 525 , m_skipCount(skipCount) | 529 , m_skipCount(skipCount) |
| 526 , m_pageSize(pageSize) { } | 530 , m_pageSize(pageSize) { } |
| 527 RefPtr<RequestDataCallback> m_requestCallback; | 531 RefPtr<RequestDataCallback> m_requestCallback; |
| 528 InjectedScript m_injectedScript; | |
| 529 String m_objectStoreName; | 532 String m_objectStoreName; |
| 530 String m_indexName; | 533 String m_indexName; |
| 531 RefPtr<IDBKeyRange> m_idbKeyRange; | 534 RefPtr<IDBKeyRange> m_idbKeyRange; |
| 532 int m_skipCount; | 535 int m_skipCount; |
| 533 unsigned m_pageSize; | 536 unsigned m_pageSize; |
| 534 }; | 537 }; |
| 535 | 538 |
| 539 Frame* findFrameWithSecurityOrigin(Page* page, const String& securityOrigin) | |
| 540 { | |
| 541 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse Next()) { | |
| 542 RefPtr<SecurityOrigin> documentOrigin = frame->document()->securityOrigi n(); | |
| 543 if (documentOrigin->toRawString() == securityOrigin) | |
| 544 return frame; | |
| 545 } | |
| 546 return 0; | |
| 547 } | |
| 548 | |
| 536 } // namespace | 549 } // namespace |
| 537 | 550 |
| 538 InspectorIndexedDBAgent::InspectorIndexedDBAgent(InjectedScriptManager* injected ScriptManager, InspectorPageAgent* pageAgent) | 551 void InspectorIndexedDBAgent::provideTo(Page* page) |
| 552 { | |
| 553 OwnPtr<InspectorIndexedDBAgent> agent(adoptPtr(new InspectorIndexedDBAgent(p age))); | |
| 554 page->inspectorController().registerModuleAgent(agent.release()); | |
| 555 } | |
| 556 | |
| 557 InspectorIndexedDBAgent::InspectorIndexedDBAgent(Page* page) | |
| 539 : InspectorBaseAgent<InspectorIndexedDBAgent>("IndexedDB") | 558 : InspectorBaseAgent<InspectorIndexedDBAgent>("IndexedDB") |
| 540 , m_injectedScriptManager(injectedScriptManager) | 559 , m_page(page) |
| 541 , m_pageAgent(pageAgent) | |
| 542 { | 560 { |
| 543 } | 561 } |
| 544 | 562 |
| 545 InspectorIndexedDBAgent::~InspectorIndexedDBAgent() | 563 InspectorIndexedDBAgent::~InspectorIndexedDBAgent() |
| 546 { | 564 { |
| 547 } | 565 } |
| 548 | 566 |
| 549 void InspectorIndexedDBAgent::clearFrontend() | 567 void InspectorIndexedDBAgent::clearFrontend() |
| 550 { | 568 { |
| 551 disable(0); | 569 disable(0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 IDBFactory* idbFactory = DOMWindowIndexedDatabase::indexedDB(domWindow); | 607 IDBFactory* idbFactory = DOMWindowIndexedDatabase::indexedDB(domWindow); |
| 590 | 608 |
| 591 if (!idbFactory) | 609 if (!idbFactory) |
| 592 *errorString = "No IndexedDB factory for given frame found"; | 610 *errorString = "No IndexedDB factory for given frame found"; |
| 593 | 611 |
| 594 return idbFactory; | 612 return idbFactory; |
| 595 } | 613 } |
| 596 | 614 |
| 597 void InspectorIndexedDBAgent::requestDatabaseNames(ErrorString* errorString, con st String& securityOrigin, PassRefPtr<RequestDatabaseNamesCallback> requestCallb ack) | 615 void InspectorIndexedDBAgent::requestDatabaseNames(ErrorString* errorString, con st String& securityOrigin, PassRefPtr<RequestDatabaseNamesCallback> requestCallb ack) |
| 598 { | 616 { |
| 599 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); | 617 Frame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
| 600 Document* document = assertDocument(errorString, frame); | 618 Document* document = assertDocument(errorString, frame); |
| 601 if (!document) | 619 if (!document) |
| 602 return; | 620 return; |
| 603 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 621 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
| 604 if (!idbFactory) | 622 if (!idbFactory) |
| 605 return; | 623 return; |
| 606 | 624 |
| 607 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 625 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 608 v8::HandleScope handleScope(toIsolate(frame)); | 626 v8::HandleScope handleScope(toIsolate(frame)); |
| 609 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); | 627 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); |
| 610 ASSERT(!context.IsEmpty()); | 628 ASSERT(!context.IsEmpty()); |
| 611 v8::Context::Scope contextScope(context); | 629 v8::Context::Scope contextScope(context); |
| 612 | 630 |
| 613 TrackExceptionState exceptionState; | 631 TrackExceptionState exceptionState; |
| 614 RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, excep tionState); | 632 RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, excep tionState); |
| 615 if (exceptionState.hadException()) { | 633 if (exceptionState.hadException()) { |
| 616 requestCallback->sendFailure("Could not obtain database names."); | 634 requestCallback->sendFailure("Could not obtain database names."); |
| 617 return; | 635 return; |
| 618 } | 636 } |
| 619 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); |
| 620 } | 638 } |
| 621 | 639 |
| 622 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) |
| 623 { | 641 { |
| 624 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); | 642 Frame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
| 625 Document* document = assertDocument(errorString, frame); | 643 Document* document = assertDocument(errorString, frame); |
| 626 if (!document) | 644 if (!document) |
| 627 return; | 645 return; |
| 628 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 646 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
| 629 if (!idbFactory) | 647 if (!idbFactory) |
| 630 return; | 648 return; |
| 631 | 649 |
| 632 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 650 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 633 v8::HandleScope handleScope(toIsolate(frame)); | 651 v8::HandleScope handleScope(toIsolate(frame)); |
| 634 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); | 652 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); |
| 635 ASSERT(!context.IsEmpty()); | 653 ASSERT(!context.IsEmpty()); |
| 636 v8::Context::Scope contextScope(context); | 654 v8::Context::Scope contextScope(context); |
| 637 | 655 |
| 638 RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(document, req uestCallback); | 656 RefPtr<DatabaseLoader> databaseLoader = DatabaseLoader::create(document, req uestCallback); |
| 639 databaseLoader->start(idbFactory, document->securityOrigin(), databaseName); | 657 databaseLoader->start(idbFactory, document->securityOrigin(), databaseName); |
| 640 } | 658 } |
| 641 | 659 |
| 642 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) | 660 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) |
| 643 { | 661 { |
| 644 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); | 662 Frame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
| 645 Document* document = assertDocument(errorString, frame); | 663 Document* document = assertDocument(errorString, frame); |
| 646 if (!document) | 664 if (!document) |
| 647 return; | 665 return; |
| 648 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 666 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
| 649 if (!idbFactory) | 667 if (!idbFactory) |
| 650 return; | 668 return; |
| 651 | 669 |
| 652 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m ainWorldScriptState(frame)); | |
| 653 | |
| 654 RefPtr<IDBKeyRange> idbKeyRange = keyRange ? idbKeyRangeFromKeyRange(keyRang e->get()) : 0; | 670 RefPtr<IDBKeyRange> idbKeyRange = keyRange ? idbKeyRangeFromKeyRange(keyRang e->get()) : 0; |
| 655 if (keyRange && !idbKeyRange) { | 671 if (keyRange && !idbKeyRange) { |
| 656 *errorString = "Can not parse key range."; | 672 *errorString = "Can not parse key range."; |
| 657 return; | 673 return; |
| 658 } | 674 } |
| 659 | 675 |
| 660 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 676 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 661 v8::HandleScope handleScope(toIsolate(frame)); | 677 v8::HandleScope handleScope(toIsolate(frame)); |
| 662 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); | 678 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); |
| 663 ASSERT(!context.IsEmpty()); | 679 ASSERT(!context.IsEmpty()); |
| 664 v8::Context::Scope contextScope(context); | 680 v8::Context::Scope contextScope(context); |
| 665 | 681 |
| 666 RefPtr<DataLoader> dataLoader = DataLoader::create(document, requestCallback , injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize); | 682 RefPtr<DataLoader> dataLoader = DataLoader::create(document, requestCallback , objectStoreName, indexName, idbKeyRange, skipCount, pageSize); |
| 667 dataLoader->start(idbFactory, document->securityOrigin(), databaseName); | 683 dataLoader->start(idbFactory, document->securityOrigin(), databaseName); |
| 668 } | 684 } |
| 669 | 685 |
| 670 class ClearObjectStoreListener FINAL : public EventListener { | 686 class ClearObjectStoreListener FINAL : public EventListener { |
| 671 WTF_MAKE_NONCOPYABLE(ClearObjectStoreListener); | 687 WTF_MAKE_NONCOPYABLE(ClearObjectStoreListener); |
| 672 public: | 688 public: |
| 673 static PassRefPtr<ClearObjectStoreListener> create(PassRefPtr<ClearObjectSto reCallback> requestCallback) | 689 static PassRefPtr<ClearObjectStoreListener> create(PassRefPtr<ClearObjectSto reCallback> requestCallback) |
| 674 { | 690 { |
| 675 return adoptRef(new ClearObjectStoreListener(requestCallback)); | 691 return adoptRef(new ClearObjectStoreListener(requestCallback)); |
| 676 } | 692 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 } | 762 } |
| 747 | 763 |
| 748 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba ck.get(); } | 764 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba ck.get(); } |
| 749 private: | 765 private: |
| 750 const String m_objectStoreName; | 766 const String m_objectStoreName; |
| 751 RefPtr<ClearObjectStoreCallback> m_requestCallback; | 767 RefPtr<ClearObjectStoreCallback> m_requestCallback; |
| 752 }; | 768 }; |
| 753 | 769 |
| 754 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S tring& securityOrigin, const String& databaseName, const String& objectStoreName , PassRefPtr<ClearObjectStoreCallback> requestCallback) | 770 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S tring& securityOrigin, const String& databaseName, const String& objectStoreName , PassRefPtr<ClearObjectStoreCallback> requestCallback) |
| 755 { | 771 { |
| 756 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); | 772 Frame* frame = findFrameWithSecurityOrigin(m_page, securityOrigin); |
| 757 Document* document = assertDocument(errorString, frame); | 773 Document* document = assertDocument(errorString, frame); |
| 758 if (!document) | 774 if (!document) |
| 759 return; | 775 return; |
| 760 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 776 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
| 761 if (!idbFactory) | 777 if (!idbFactory) |
| 762 return; | 778 return; |
| 763 | 779 |
| 764 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 780 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
| 765 v8::HandleScope handleScope(toIsolate(frame)); | 781 v8::HandleScope handleScope(toIsolate(frame)); |
| 766 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); | 782 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); |
| 767 ASSERT(!context.IsEmpty()); | 783 ASSERT(!context.IsEmpty()); |
| 768 v8::Context::Scope contextScope(context); | 784 v8::Context::Scope contextScope(context); |
| 769 | 785 |
| 770 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen t, objectStoreName, requestCallback); | 786 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen t, objectStoreName, requestCallback); |
| 771 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName ); | 787 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName ); |
| 772 } | 788 } |
| 773 | 789 |
| 774 } // namespace WebCore | 790 } // namespace WebCore |
| OLD | NEW |