| Index: third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
|
| diff --git a/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp b/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
|
| index 87578fe5822a930601f4fbe5b47ad59ccb7d496e..8f230c49a2c96531e54b5b39c0909fc3b1e940a3 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
|
| @@ -56,7 +56,7 @@
|
| #include "modules/indexeddb/IDBRequest.h"
|
| #include "modules/indexeddb/IDBTransaction.h"
|
| #include "platform/inspector_protocol/Values.h"
|
| -#include "platform/v8_inspector/public/V8ToProtocolValue.h"
|
| +#include "platform/v8_inspector/public/V8InspectorSession.h"
|
| #include "platform/weborigin/SecurityOrigin.h"
|
| #include "public/platform/modules/indexeddb/WebIDBCursor.h"
|
| #include "public/platform/modules/indexeddb/WebIDBTypes.h"
|
| @@ -85,6 +85,8 @@ static const char indexedDBAgentEnabled[] = "indexedDBAgentEnabled";
|
|
|
| namespace {
|
|
|
| +static const char indexedDBObjectGroup[] = "indexeddb";
|
| +
|
| class GetDatabaseNamesCallback final : public EventListener {
|
| WTF_MAKE_NONCOPYABLE(GetDatabaseNamesCallback);
|
| public:
|
| @@ -407,9 +409,9 @@ class DataLoader;
|
|
|
| class OpenCursorCallback final : public EventListener {
|
| public:
|
| - static OpenCursorCallback* create(ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize)
|
| + static OpenCursorCallback* create(V8InspectorSession* v8Session, ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize)
|
| {
|
| - return new OpenCursorCallback(scriptState, std::move(requestCallback), skipCount, pageSize);
|
| + return new OpenCursorCallback(v8Session, scriptState, std::move(requestCallback), skipCount, pageSize);
|
| }
|
|
|
| ~OpenCursorCallback() override { }
|
| @@ -464,21 +466,14 @@ public:
|
| Document* document = toDocument(m_scriptState->getExecutionContext());
|
| if (!document)
|
| return;
|
| - // FIXME: There are no tests for this error showing when a recursive
|
| - // object is inspected.
|
| - const String16 errorMessage("\"Inspection error. Maximum depth reached?\"");
|
| ScriptState* scriptState = m_scriptState.get();
|
| ScriptState::Scope scope(scriptState);
|
| - std::unique_ptr<protocol::Value> keyJsonValue = toProtocolValue(scriptState->context(), idbCursor->key(scriptState).v8Value());
|
| - std::unique_ptr<protocol::Value> primaryKeyJsonValue = toProtocolValue(scriptState->context(), idbCursor->primaryKey(scriptState).v8Value());
|
| - std::unique_ptr<protocol::Value> valueJsonValue = toProtocolValue(scriptState->context(), idbCursor->value(scriptState).v8Value());
|
| - String16 key = keyJsonValue ? keyJsonValue->toJSONString() : errorMessage;
|
| - String16 value = valueJsonValue ? valueJsonValue->toJSONString() : errorMessage;
|
| - String primaryKey = primaryKeyJsonValue ? primaryKeyJsonValue->toJSONString() : errorMessage;
|
| + v8::Local<v8::Context> context = scriptState->context();
|
| std::unique_ptr<DataEntry> dataEntry = DataEntry::create()
|
| - .setKey(key)
|
| - .setPrimaryKey(primaryKey)
|
| - .setValue(value).build();
|
| + .setKey(m_v8Session->wrapObject(context, idbCursor->key(scriptState).v8Value(), indexedDBObjectGroup, false))
|
| + .setPrimaryKey(m_v8Session->wrapObject(context, idbCursor->primaryKey(scriptState).v8Value(), indexedDBObjectGroup, false))
|
| + .setValue(m_v8Session->wrapObject(context, idbCursor->value(scriptState).v8Value(), indexedDBObjectGroup, false))
|
| + .build();
|
| m_result->addItem(std::move(dataEntry));
|
| }
|
|
|
| @@ -493,8 +488,9 @@ public:
|
| }
|
|
|
| private:
|
| - OpenCursorCallback(ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize)
|
| + OpenCursorCallback(V8InspectorSession* v8Session, ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSize)
|
| : EventListener(EventListener::CPPEventListenerType)
|
| + , m_v8Session(v8Session)
|
| , m_scriptState(scriptState)
|
| , m_requestCallback(std::move(requestCallback))
|
| , m_skipCount(skipCount)
|
| @@ -503,6 +499,7 @@ private:
|
| m_result = Array<DataEntry>::create();
|
| }
|
|
|
| + V8InspectorSession* m_v8Session;
|
| RefPtr<ScriptState> m_scriptState;
|
| std::unique_ptr<RequestDataCallback> m_requestCallback;
|
| int m_skipCount;
|
| @@ -512,9 +509,9 @@ private:
|
|
|
| class DataLoader final : public ExecutableWithDatabase {
|
| public:
|
| - static PassRefPtr<DataLoader> create(ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, const String& objectStoreName, const String& indexName, IDBKeyRange* idbKeyRange, int skipCount, unsigned pageSize)
|
| + static PassRefPtr<DataLoader> create(V8InspectorSession* v8Session, ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, const String& objectStoreName, const String& indexName, IDBKeyRange* idbKeyRange, int skipCount, unsigned pageSize)
|
| {
|
| - return adoptRef(new DataLoader(scriptState, std::move(requestCallback), objectStoreName, indexName, idbKeyRange, skipCount, pageSize));
|
| + return adoptRef(new DataLoader(v8Session, scriptState, std::move(requestCallback), objectStoreName, indexName, idbKeyRange, skipCount, pageSize));
|
| }
|
|
|
| ~DataLoader() override { }
|
| @@ -544,13 +541,14 @@ public:
|
| } else {
|
| idbRequest = idbObjectStore->openCursor(getScriptState(), m_idbKeyRange.get(), WebIDBCursorDirectionNext);
|
| }
|
| - OpenCursorCallback* openCursorCallback = OpenCursorCallback::create(getScriptState(), std::move(m_requestCallback), m_skipCount, m_pageSize);
|
| + OpenCursorCallback* openCursorCallback = OpenCursorCallback::create(m_v8Session, getScriptState(), std::move(m_requestCallback), m_skipCount, m_pageSize);
|
| idbRequest->addEventListener(EventTypeNames::success, openCursorCallback, false);
|
| }
|
|
|
| RequestCallback* getRequestCallback() override { return m_requestCallback.get(); }
|
| - DataLoader(ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, const String& objectStoreName, const String& indexName, IDBKeyRange* idbKeyRange, int skipCount, unsigned pageSize)
|
| + DataLoader(V8InspectorSession* v8Session, ScriptState* scriptState, std::unique_ptr<RequestDataCallback> requestCallback, const String& objectStoreName, const String& indexName, IDBKeyRange* idbKeyRange, int skipCount, unsigned pageSize)
|
| : ExecutableWithDatabase(scriptState)
|
| + , m_v8Session(v8Session)
|
| , m_requestCallback(std::move(requestCallback))
|
| , m_objectStoreName(objectStoreName)
|
| , m_indexName(indexName)
|
| @@ -560,6 +558,7 @@ public:
|
| {
|
| }
|
|
|
| + V8InspectorSession* m_v8Session;
|
| std::unique_ptr<RequestDataCallback> m_requestCallback;
|
| String m_objectStoreName;
|
| String m_indexName;
|
| @@ -571,13 +570,9 @@ public:
|
| } // namespace
|
|
|
| // static
|
| -InspectorIndexedDBAgent* InspectorIndexedDBAgent::create(InspectedFrames* inspectedFrames)
|
| -{
|
| - return new InspectorIndexedDBAgent(inspectedFrames);
|
| -}
|
| -
|
| -InspectorIndexedDBAgent::InspectorIndexedDBAgent(InspectedFrames* inspectedFrames)
|
| +InspectorIndexedDBAgent::InspectorIndexedDBAgent(InspectedFrames* inspectedFrames, V8InspectorSession* v8Session)
|
| : m_inspectedFrames(inspectedFrames)
|
| + , m_v8Session(v8Session)
|
| {
|
| }
|
|
|
| @@ -593,6 +588,12 @@ void InspectorIndexedDBAgent::restore()
|
| }
|
| }
|
|
|
| +void InspectorIndexedDBAgent::didCommitLoadForLocalFrame(LocalFrame* frame)
|
| +{
|
| + if (frame == m_inspectedFrames->root())
|
| + m_v8Session->releaseObjectGroup(indexedDBObjectGroup);
|
| +}
|
| +
|
| void InspectorIndexedDBAgent::enable(ErrorString*)
|
| {
|
| m_state->setBoolean(IndexedDBAgentState::indexedDBAgentEnabled, true);
|
| @@ -601,6 +602,7 @@ void InspectorIndexedDBAgent::enable(ErrorString*)
|
| void InspectorIndexedDBAgent::disable(ErrorString*)
|
| {
|
| m_state->setBoolean(IndexedDBAgentState::indexedDBAgentEnabled, false);
|
| + m_v8Session->releaseObjectGroup(indexedDBObjectGroup);
|
| }
|
|
|
| static Document* assertDocument(ErrorString* errorString, LocalFrame* frame)
|
| @@ -697,7 +699,7 @@ void InspectorIndexedDBAgent::requestData(ErrorString* errorString,
|
| if (!scriptState)
|
| return;
|
| ScriptState::Scope scope(scriptState);
|
| - RefPtr<DataLoader> dataLoader = DataLoader::create(scriptState, std::move(requestCallback), objectStoreName, indexName, idbKeyRange, skipCount, pageSize);
|
| + RefPtr<DataLoader> dataLoader = DataLoader::create(m_v8Session, scriptState, std::move(requestCallback), objectStoreName, indexName, idbKeyRange, skipCount, pageSize);
|
| dataLoader->start(idbFactory, document->getSecurityOrigin(), databaseName);
|
| }
|
|
|
|
|