Changeset 243219 in webkit
- Timestamp:
- Mar 20, 2019, 11:53:47 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt (modified) (2 diffs)
-
LayoutTests/inspector/protocol/backend-dispatcher-argument-errors.html (modified) (2 diffs)
-
LayoutTests/inspector/runtime/CommandLineAPI-inspect.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/webdatabase/Database.cpp (modified) (1 diff)
-
Source/WebCore/Modules/webdatabase/Database.h (modified) (2 diffs)
-
Source/WebCore/Modules/webdatabase/DatabaseManager.cpp (modified) (1 diff)
-
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webdatabase/DatabaseTracker.h (modified) (1 diff)
-
Source/WebCore/inspector/CommandLineAPIHost.cpp (modified) (5 diffs)
-
Source/WebCore/inspector/CommandLineAPIHost.h (modified) (4 diffs)
-
Source/WebCore/inspector/InspectorController.cpp (modified) (2 diffs)
-
Source/WebCore/inspector/InspectorDatabaseResource.cpp (modified) (3 diffs)
-
Source/WebCore/inspector/InspectorDatabaseResource.h (modified) (1 diff)
-
Source/WebCore/inspector/InspectorInstrumentation.cpp (modified) (3 diffs)
-
Source/WebCore/inspector/InspectorInstrumentation.h (modified) (5 diffs)
-
Source/WebCore/inspector/WorkerInspectorController.cpp (modified) (1 diff)
-
Source/WebCore/inspector/agents/InspectorDatabaseAgent.cpp (modified) (8 diffs)
-
Source/WebCore/inspector/agents/InspectorDatabaseAgent.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243211 r243219 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Database: lazily create the agent 4 https://bugs.webkit.org/show_bug.cgi?id=195587 5 <rdar://problem/48791735> 6 7 Reviewed by Timothy Hatcher. 8 9 * inspector/protocol/backend-dispatcher-argument-errors.html: 10 * inspector/runtime/CommandLineAPI-inspect.html: 11 1 12 2019-03-20 Simon Fraser <simon.fraser@apple.com> 2 13 -
trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt
r200467 r243219 36 36 37 37 -- Running test case: TestErrorCodeForSyncServerError 38 Sending message: {"id":123,"method":"Database.getDatabaseTableNames","params":{"databaseId":"thisisNotADatabase"}}39 PASS: the backend should send a protocol error when receiving an invalid message.40 PASS: the reported error should be "ServerError" (-32000)41 Actual error code: -3200042 Actual error message: Database agent is not enabled43 Actual error data: [{"code":-32000,"message":"Database agent is not enabled"}]44 45 -- Running test case: TestErrorCodeForAsyncServerError46 Sending message: {"id":123,"method":"Database.executeSQL","params":{"databaseId":"thisisNotADatabase","query":"asdf"}}47 PASS: the backend should send a protocol error when receiving an invalid message.48 PASS: the reported error should be "ServerError" (-32000)49 Actual error code: -3200050 Actual error message: Database agent is not enabled51 Actual error data: [{"code":-32000,"message":"Database agent is not enabled"}]52 53 -- Running test case: CommandWithBadArgumentValue54 38 Sending message: {"id":123,"method":"Runtime.getProperties","params":{"objectId":"thisisNotAnId"}} 55 39 PASS: the backend should send a protocol error when receiving an invalid message. … … 59 43 Actual error data: [{"code":-32000,"message":"Could not find InjectedScript for objectId"}] 60 44 45 -- Running test case: TestErrorCodeForAsyncServerError 46 Sending message: {"id":123,"method":"Runtime.awaitPromise","params":{"promiseObjectId":"thisisNotAnId"}} 47 PASS: the backend should send a protocol error when receiving an invalid message. 48 PASS: the reported error should be "ServerError" (-32000) 49 Actual error code: -32000 50 Actual error message: Could not find InjectedScript for promiseObjectId 51 Actual error data: [{"code":-32000,"message":"Could not find InjectedScript for promiseObjectId"}] 52 -
trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors.html
r210062 r243219 77 77 name: "TestErrorCodeForSyncServerError", 78 78 description: "The backend should return a server error with the correct error code.", 79 message: {id: 123, method: " Database.getDatabaseTableNames", params: {databaseId: "thisisNotADatabase"}},79 message: {id: 123, method: "Runtime.getProperties", params: {objectId: "thisisNotAnId"}}, 80 80 expectedError: "ServerError" 81 81 }); … … 84 84 name: "TestErrorCodeForAsyncServerError", 85 85 description: "The backend should return a server error with the correct error code.", 86 message: {id: 123, method: "Database.executeSQL", params: {databaseId: "thisisNotADatabase", query: "asdf"}}, 87 expectedError: "ServerError" 88 }); 89 90 addErrorResponseTestCase({ 91 name: "CommandWithBadArgumentValue", 92 description: "The backend should return an error if something went wrong when invoking the agent's method.", 93 message: {id: 123, method: "Runtime.getProperties", params: {objectId: "thisisNotAnId"}}, 86 message: {id: 123, method: "Runtime.awaitPromise", params: {promiseObjectId: "thisisNotAnId"}}, 94 87 expectedError: "ServerError" 95 88 }); -
trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html
r220159 r243219 26 26 27 27 InspectorProtocol.awaitCommand({method: "Inspector.enable", params: {}}) 28 InspectorProtocol.awaitCommand({method: "Database.enable", params: {}}) 28 29 29 30 function addTestCase({name, description, expression}) { -
trunk/Source/WebCore/ChangeLog
r243218 r243219 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Database: lazily create the agent 4 https://bugs.webkit.org/show_bug.cgi?id=195587 5 <rdar://problem/48791735> 6 7 Reviewed by Timothy Hatcher. 8 9 No change in functionality. 10 11 * inspector/agents/InspectorDatabaseAgent.h: 12 * inspector/agents/InspectorDatabaseAgent.cpp: 13 (WebCore::InspectorDatabaseAgent::didCommitLoad): Added. 14 (WebCore::InspectorDatabaseAgent::didOpenDatabase): 15 (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent): 16 (WebCore::InspectorDatabaseAgent::enable): 17 (WebCore::InspectorDatabaseAgent::disable): 18 (WebCore::InspectorDatabaseAgent::getDatabaseTableNames): 19 (WebCore::InspectorDatabaseAgent::executeSQL): 20 (WebCore::InspectorDatabaseAgent::databaseId): 21 (WebCore::InspectorDatabaseAgent::findByFileName): 22 (WebCore::InspectorDatabaseAgent::databaseForId): 23 (WebCore::InspectorDatabaseAgent::clearResources): Deleted. 24 (WebCore::InspectorDatabaseAgent::~InspectorDatabaseAgent): Deleted. 25 * inspector/InspectorDatabaseResource.h: 26 (WebCore::InspectorDatabaseResource::database const): 27 (WebCore::InspectorDatabaseResource::setDatabase): 28 (WebCore::InspectorDatabaseResource::database): Deleted. 29 * inspector/InspectorDatabaseResource.cpp: 30 (WebCore::InspectorDatabaseResource::create): 31 (WebCore::InspectorDatabaseResource::InspectorDatabaseResource): 32 (WebCore::InspectorDatabaseResource::bind): 33 * inspector/InspectorInstrumentation.h: 34 (WebCore::InspectorInstrumentation::didOpenDatabase): 35 * inspector/InspectorInstrumentation.cpp: 36 (WebCore::InspectorInstrumentation::didCommitLoadImpl): 37 (WebCore::InspectorInstrumentation::didOpenDatabaseImpl): 38 Pass the `Database` as a reference instead of a pointer. Retrieve any information directly 39 from the `Database`, rather than using the arguments that were used to create it. 40 41 * Modules/webdatabase/Database.h: 42 (WebCore::Database::expectedVersion const): Deleted. 43 * Modules/webdatabase/Database.cpp: 44 (WebCore::Database::expectedVersion const): Added. 45 * Modules/webdatabase/DatabaseManager.cpp: 46 (WebCore::DatabaseManager::openDatabase): 47 * Modules/webdatabase/DatabaseTracker.h: 48 * Modules/webdatabase/DatabaseTracker.cpp: 49 (WebCore::DatabaseTracker::closeAllDatabases): 50 (WebCore::DatabaseTracker::openDatabases): Added. 51 Expose various values used by `InspectorDatabaseAgent` and `InspectorDatabaseResource`. 52 53 * inspector/InspectorController.cpp: 54 (WebCore::InspectorController::InspectorController): 55 (WebCore::InspectorController::createLazyAgents): 56 * inspector/WorkerInspectorController.cpp: 57 (WebCore::WorkerInspectorController::WorkerInspectorController): 58 59 * inspector/CommandLineAPIHost.h: 60 (WebCore::CommandLineAPIHost::init): 61 * inspector/CommandLineAPIHost.cpp: 62 (WebCore::CommandLineAPIHost::disconnect): 63 (WebCore::CommandLineAPIHost::inspect): 64 (WebCore::CommandLineAPIHost::clearConsoleMessages): 65 (WebCore::CommandLineAPIHost::databaseId): 66 (WebCore::CommandLineAPIHost::storageId): 67 Rather than pass each agent individually, pass the entire `InstrumentingAgents` so that the 68 current agent can be used instead of whatever was initially created. 69 1 70 2019-03-20 Oriol Brufau <obrufau@igalia.com> 2 71 -
trunk/Source/WebCore/Modules/webdatabase/Database.cpp
r242251 r243219 619 619 } 620 620 621 String Database::expectedVersion() const 622 { 623 // Return a deep copy for ref counting thread safety 624 return m_expectedVersion.isolatedCopy(); 625 } 626 621 627 unsigned long long Database::estimatedSize() const 622 628 { -
trunk/Source/WebCore/Modules/webdatabase/Database.h
r236348 r243219 89 89 String stringIdentifier() const; 90 90 String displayName() const; 91 String expectedVersion() const; 91 92 unsigned long long estimatedSize() const; 92 93 String fileName() const; … … 134 135 bool setVersionInDatabase(const String& version, bool shouldCacheVersion = true); 135 136 void setExpectedVersion(const String&); 136 const String& expectedVersion() const { return m_expectedVersion; }137 137 String getCachedVersion() const; 138 138 void setCachedVersion(const String&); -
trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
r243163 r243219 212 212 auto databaseContext = this->databaseContext(context); 213 213 databaseContext->setHasOpenDatabases(); 214 InspectorInstrumentation::didOpenDatabase( &context, database.copyRef(), context.securityOrigin()->host(), name, expectedVersion);214 InspectorInstrumentation::didOpenDatabase(*database); 215 215 216 216 if (database->isNew() && creationCallback.get()) { -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
r243163 r243219 290 290 void DatabaseTracker::closeAllDatabases(CurrentQueryBehavior currentQueryBehavior) 291 291 { 292 Vector<Ref<Database>> openDatabases; 293 { 294 LockHolder openDatabaseMapLock(m_openDatabaseMapGuard); 295 if (!m_openDatabaseMap) 296 return; 297 for (auto& nameMap : m_openDatabaseMap->values()) { 298 for (auto& set : nameMap->values()) { 299 for (auto& database : *set) 300 openDatabases.append(*database); 301 } 302 } 303 } 304 for (auto& database : openDatabases) { 292 for (auto& database : openDatabases()) { 305 293 if (currentQueryBehavior == CurrentQueryBehavior::Interrupt) 306 294 database->interrupt(); … … 532 520 LockHolder lockDatabase(m_databaseGuard); 533 521 doneCreatingDatabase(database.securityOrigin(), database.stringIdentifier()); 522 } 523 524 Vector<Ref<Database>> DatabaseTracker::openDatabases() 525 { 526 Vector<Ref<Database>> openDatabases; 527 { 528 LockHolder openDatabaseMapLock(m_openDatabaseMapGuard); 529 530 if (m_openDatabaseMap) { 531 for (auto& nameMap : m_openDatabaseMap->values()) { 532 for (auto& set : nameMap->values()) { 533 for (auto& database : *set) 534 openDatabases.append(*database); 535 } 536 } 537 } 538 } 539 return openDatabases; 534 540 } 535 541 -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h
r237266 r243219 73 73 WEBCORE_EXPORT String fullPathForDatabase(const SecurityOriginData&, const String& name, bool createIfDoesNotExist); 74 74 75 Vector<Ref<Database>> openDatabases(); 75 76 void addOpenDatabase(Database&); 76 77 void removeOpenDatabase(Database&); -
trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp
r243158 r243219 42 42 #include "Pasteboard.h" 43 43 #include "Storage.h" 44 #include "WebConsoleAgent.h" 44 45 #include <JavaScriptCore/InspectorAgent.h> 45 #include <JavaScriptCore/InspectorConsoleAgent.h>46 46 #include <JavaScriptCore/JSCInlines.h> 47 47 #include <JavaScriptCore/JSLock.h> … … 70 70 void CommandLineAPIHost::disconnect() 71 71 { 72 m_inspectorAgent = nullptr; 73 m_consoleAgent = nullptr; 74 m_databaseAgent = nullptr; 72 73 m_instrumentingAgents = nullptr; 75 74 } 76 75 77 76 void CommandLineAPIHost::inspect(JSC::ExecState& state, JSC::JSValue valueToInspect, JSC::JSValue hintsValue) 78 77 { 79 if (!m_inspectorAgent) 78 if (!m_instrumentingAgents) 79 return; 80 81 auto* inspectorAgent = m_instrumentingAgents->inspectorAgent(); 82 if (!inspectorAgent) 80 83 return; 81 84 … … 85 88 86 89 auto remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(Inspector::toInspectorValue(state, valueToInspect)); 87 m_inspectorAgent->inspect(WTFMove(remoteObject), WTFMove(hintsObject));90 inspectorAgent->inspect(WTFMove(remoteObject), WTFMove(hintsObject)); 88 91 } 89 92 … … 127 130 void CommandLineAPIHost::clearConsoleMessages() 128 131 { 129 if (m_consoleAgent) { 130 ErrorString unused; 131 m_consoleAgent->clearMessages(unused); 132 } 132 if (!m_instrumentingAgents) 133 return; 134 135 auto* consoleAgent = m_instrumentingAgents->webConsoleAgent(); 136 if (!consoleAgent) 137 return; 138 139 ErrorString unused; 140 consoleAgent->clearMessages(unused); 133 141 } 134 142 … … 160 168 String CommandLineAPIHost::databaseId(Database& database) 161 169 { 162 if (m_databaseAgent) 163 return m_databaseAgent->databaseId(database); 170 if (m_instrumentingAgents) { 171 if (auto* databaseAgent = m_instrumentingAgents->inspectorDatabaseAgent()) 172 return databaseAgent->databaseId(database); 173 } 164 174 return { }; 165 175 } -
trunk/Source/WebCore/inspector/CommandLineAPIHost.h
r243158 r243219 30 30 #pragma once 31 31 32 #include "InstrumentingAgents.h" 32 33 #include <JavaScriptCore/PerGlobalObjectWrapperWorld.h> 33 34 #include <wtf/RefCounted.h> … … 39 40 } 40 41 41 namespace Inspector {42 class InspectorAgent;43 class InspectorConsoleAgent;44 }45 46 42 namespace WebCore { 47 43 48 44 class Database; 49 45 class EventTarget; 50 class InspectorDatabaseAgent;51 46 class JSDOMGlobalObject; 52 47 class Storage; … … 59 54 ~CommandLineAPIHost(); 60 55 61 void init(Inspector::InspectorAgent* inspectorAgent 62 , Inspector::InspectorConsoleAgent* consoleAgent 63 , InspectorDatabaseAgent* databaseAgent 64 ) 56 void init(RefPtr<InstrumentingAgents> instrumentingAgents) 65 57 { 66 m_inspectorAgent = inspectorAgent; 67 m_consoleAgent = consoleAgent; 68 m_databaseAgent = databaseAgent; 58 m_instrumentingAgents = instrumentingAgents; 69 59 } 70 60 … … 103 93 CommandLineAPIHost(); 104 94 105 Inspector::InspectorAgent* m_inspectorAgent { nullptr }; 106 Inspector::InspectorConsoleAgent* m_consoleAgent { nullptr }; 107 InspectorDatabaseAgent* m_databaseAgent { nullptr }; 108 95 RefPtr<InstrumentingAgents> m_instrumentingAgents; 109 96 std::unique_ptr<InspectableObject> m_inspectedObject; // $0 110 97 Inspector::PerGlobalObjectWrapperWorld m_wrappers; -
trunk/Source/WebCore/inspector/InspectorController.cpp
r243160 r243219 124 124 m_agents.append(WTFMove(domAgentPtr)); 125 125 126 auto databaseAgentPtr = std::make_unique<InspectorDatabaseAgent>(pageContext); 127 InspectorDatabaseAgent* databaseAgent = databaseAgentPtr.get(); 128 m_agents.append(WTFMove(databaseAgentPtr)); 129 130 auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent); 131 WebConsoleAgent* consoleAgent = consoleAgentPtr.get(); 132 m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get()); 133 m_agents.append(WTFMove(consoleAgentPtr)); 126 auto consoleAgent = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent); 127 m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get()); 128 m_agents.append(WTFMove(consoleAgent)); 134 129 135 130 ASSERT(m_injectedScriptManager->commandLineAPIHost()); 136 if ( CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())137 commandLineAPIHost->init(m_ins pectorAgent, consoleAgent, databaseAgent);131 if (auto* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) 132 commandLineAPIHost->init(m_instrumentingAgents.copyRef()); 138 133 } 139 134 … … 186 181 m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext)); 187 182 m_agents.append(std::make_unique<InspectorDOMStorageAgent>(pageContext)); 183 m_agents.append(std::make_unique<InspectorDatabaseAgent>(pageContext)); 188 184 #if ENABLE(INDEXED_DATABASE) 189 185 m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, m_pageAgent)); -
trunk/Source/WebCore/inspector/InspectorDatabaseResource.cpp
r225263 r243219 41 41 static int nextUnusedId = 1; 42 42 43 Ref<InspectorDatabaseResource> InspectorDatabaseResource::create( RefPtr<Database>&& database, const String& domain, const String& name, const String& version)43 Ref<InspectorDatabaseResource> InspectorDatabaseResource::create(Database& database, const String& domain, const String& name, const String& version) 44 44 { 45 return adoptRef(*new InspectorDatabaseResource( WTFMove(database), domain, name, version));45 return adoptRef(*new InspectorDatabaseResource(database, domain, name, version)); 46 46 } 47 47 48 InspectorDatabaseResource::InspectorDatabaseResource( RefPtr<Database>&& database, const String& domain, const String& name, const String& version)48 InspectorDatabaseResource::InspectorDatabaseResource(Database& database, const String& domain, const String& name, const String& version) 49 49 : m_database(database) 50 50 , m_id(String::number(nextUnusedId++)) … … 55 55 } 56 56 57 void InspectorDatabaseResource::bind(Inspector::DatabaseFrontendDispatcher *databaseFrontendDispatcher)57 void InspectorDatabaseResource::bind(Inspector::DatabaseFrontendDispatcher& databaseFrontendDispatcher) 58 58 { 59 59 auto jsonObject = Inspector::Protocol::Database::Database::create() … … 63 63 .setVersion(m_version) 64 64 .release(); 65 databaseFrontendDispatcher ->addDatabase(WTFMove(jsonObject));65 databaseFrontendDispatcher.addDatabase(WTFMove(jsonObject)); 66 66 } 67 67 -
trunk/Source/WebCore/inspector/InspectorDatabaseResource.h
r228218 r243219 42 42 class InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> { 43 43 public: 44 static Ref<InspectorDatabaseResource> create( RefPtr<Database>&&, const String& domain, const String& name, const String& version);44 static Ref<InspectorDatabaseResource> create(Database&, const String& domain, const String& name, const String& version); 45 45 46 void bind(Inspector::DatabaseFrontendDispatcher*); 47 Database* database() { return m_database.get(); } 48 void setDatabase(RefPtr<Database>&& database) { m_database = WTFMove(database); } 46 void bind(Inspector::DatabaseFrontendDispatcher&); 47 48 Database& database() const { return m_database.get(); } 49 void setDatabase(Database& database) { m_database = database; } 50 49 51 String id() const { return m_id; } 50 52 51 53 private: 52 InspectorDatabaseResource( RefPtr<Database>&&, const String& domain, const String& name, const String& version);54 InspectorDatabaseResource(Database&, const String& domain, const String& name, const String& version); 53 55 54 Ref Ptr<Database> m_database;56 Ref<Database> m_database; 55 57 String m_id; 56 58 String m_domain; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r243161 r243219 36 36 #include "DOMWindow.h" 37 37 #include "DOMWrapperWorld.h" 38 #include "Database.h"39 38 #include "DocumentLoader.h" 40 39 #include "Event.h" … … 716 715 cssAgent->reset(); 717 716 718 if ( InspectorDatabaseAgent* databaseAgent = instrumentingAgents.inspectorDatabaseAgent())719 databaseAgent-> clearResources();717 if (auto* databaseAgent = instrumentingAgents.inspectorDatabaseAgent()) 718 databaseAgent->didCommitLoad(); 720 719 721 720 if (InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent()) … … 903 902 } 904 903 905 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents& instrumentingAgents, RefPtr<Database>&& database, const String& domain, const String& name, const String& version) 906 { 907 if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled()) 908 return; 909 if (InspectorDatabaseAgent* dbAgent = instrumentingAgents.inspectorDatabaseAgent()) 910 dbAgent->didOpenDatabase(WTFMove(database), domain, name, version); 904 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents& instrumentingAgents, Database& database) 905 { 906 if (auto* databaseAgent = instrumentingAgents.inspectorDatabaseAgent()) 907 databaseAgent->didOpenDatabase(database); 911 908 } 912 909 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r243161 r243219 36 36 #include "CanvasBase.h" 37 37 #include "CanvasRenderingContext.h" 38 #include "Database.h" 38 39 #include "DocumentThreadableLoader.h" 39 40 #include "Element.h" … … 69 70 class DOMWindow; 70 71 class DOMWrapperWorld; 71 class Database;72 72 class Document; 73 73 class DocumentLoader; … … 241 241 static void didFireObserverCallback(const InspectorInstrumentationCookie&); 242 242 243 static void didOpenDatabase( ScriptExecutionContext*, RefPtr<Database>&&, const String& domain, const String& name, const String& version);243 static void didOpenDatabase(Database&); 244 244 245 245 static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*); … … 418 418 static void didFireObserverCallbackImpl(const InspectorInstrumentationCookie&); 419 419 420 static void didOpenDatabaseImpl(InstrumentingAgents&, RefPtr<Database>&&, const String& domain, const String& name, const String& version);420 static void didOpenDatabaseImpl(InstrumentingAgents&, Database&); 421 421 422 422 static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*); … … 1173 1173 } 1174 1174 1175 inline void InspectorInstrumentation::didOpenDatabase(ScriptExecutionContext* context, RefPtr<Database>&& database, const String& domain, const String& name, const String& version) 1176 { 1177 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) 1178 didOpenDatabaseImpl(*instrumentingAgents, WTFMove(database), domain, name, version); 1175 inline void InspectorInstrumentation::didOpenDatabase(Database& database) 1176 { 1177 FAST_RETURN_IF_NO_FRONTENDS(void()); 1178 if (auto* instrumentingAgents = instrumentingAgentsForContext(database.scriptExecutionContext())) 1179 didOpenDatabaseImpl(*instrumentingAgents, database); 1179 1180 } 1180 1181 -
trunk/Source/WebCore/inspector/WorkerInspectorController.cpp
r243192 r243219 76 76 m_agents.append(WTFMove(consoleAgent)); 77 77 78 if ( CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())79 commandLineAPIHost->init( nullptr, m_instrumentingAgents->webConsoleAgent(), nullptr);78 if (auto* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) 79 commandLineAPIHost->init(m_instrumentingAgents.copyRef()); 80 80 } 81 81 -
trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.cpp
r233122 r243219 32 32 33 33 #include "Database.h" 34 #include "DatabaseTracker.h" 34 35 #include "InspectorDatabaseResource.h" 35 36 #include "InstrumentingAgents.h" … … 198 199 } // namespace 199 200 200 void InspectorDatabaseAgent::didOpenDatabase(RefPtr<Database>&& database, const String& domain, const String& name, const String& version) 201 { 202 if (auto* resource = findByFileName(database->fileName())) { 203 resource->setDatabase(WTFMove(database)); 204 return; 205 } 206 207 auto resource = InspectorDatabaseResource::create(WTFMove(database), domain, name, version); 201 void InspectorDatabaseAgent::didCommitLoad() 202 { 203 m_resources.clear(); 204 } 205 206 void InspectorDatabaseAgent::didOpenDatabase(Database& database) 207 { 208 if (auto resource = findByFileName(database.fileName())) { 209 resource->setDatabase(database); 210 return; 211 } 212 213 auto resource = InspectorDatabaseResource::create(database, database.securityOrigin().host, database.stringIdentifier(), database.expectedVersion()); 208 214 m_resources.add(resource->id(), resource.ptr()); 209 // Resources are only bound while visible. 210 if (m_enabled) 211 resource->bind(m_frontendDispatcher.get()); 212 } 213 214 void InspectorDatabaseAgent::clearResources() 215 { 216 m_resources.clear(); 215 resource->bind(*m_frontendDispatcher); 217 216 } 218 217 … … 222 221 , m_backendDispatcher(Inspector::DatabaseBackendDispatcher::create(context.backendDispatcher, this)) 223 222 { 224 m_instrumentingAgents.setInspectorDatabaseAgent(this);225 }226 227 InspectorDatabaseAgent::~InspectorDatabaseAgent()228 {229 m_instrumentingAgents.setInspectorDatabaseAgent(nullptr);230 223 } 231 224 … … 242 235 void InspectorDatabaseAgent::enable(ErrorString&) 243 236 { 244 if (m_enabled) 245 return; 246 m_enabled = true; 247 248 for (auto& resource : m_resources.values()) 249 resource->bind(m_frontendDispatcher.get()); 237 if (m_instrumentingAgents.inspectorDatabaseAgent() == this) 238 return; 239 240 m_instrumentingAgents.setInspectorDatabaseAgent(this); 241 242 for (auto& database : DatabaseTracker::singleton().openDatabases()) 243 didOpenDatabase(database.get()); 250 244 } 251 245 252 246 void InspectorDatabaseAgent::disable(ErrorString&) 253 247 { 254 if (!m_enabled)255 return; 256 m_ enabled = false;257 } 258 259 void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString& error , const String& databaseId, RefPtr<JSON::ArrayOf<String>>& names)260 { 261 if ( !m_enabled) {262 error = "Database agent is not enabled"_s;248 m_instrumentingAgents.setInspectorDatabaseAgent(nullptr); 249 250 m_resources.clear(); 251 } 252 253 void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString& errorString, const String& databaseId, RefPtr<JSON::ArrayOf<String>>& names) 254 { 255 if (m_instrumentingAgents.inspectorDatabaseAgent() != this) { 256 errorString = "Database agent is not enabled"_s; 263 257 return; 264 258 } … … 274 268 void InspectorDatabaseAgent::executeSQL(const String& databaseId, const String& query, Ref<ExecuteSQLCallback>&& requestCallback) 275 269 { 276 if ( !m_enabled) {277 requestCallback->sendFailure("Database agent is not enabled" );270 if (m_instrumentingAgents.inspectorDatabaseAgent() != this) { 271 requestCallback->sendFailure("Database agent is not enabled"_s); 278 272 return; 279 273 } … … 293 287 { 294 288 for (auto& resource : m_resources) { 295 if ( resource.value->database() == &database)289 if (&resource.value->database() == &database) 296 290 return resource.key; 297 291 } … … 302 296 { 303 297 for (auto& resource : m_resources.values()) { 304 if (resource->database() ->fileName() == fileName)298 if (resource->database().fileName() == fileName) 305 299 return resource.get(); 306 300 } … … 310 304 Database* InspectorDatabaseAgent::databaseForId(const String& databaseId) 311 305 { 312 auto* resource = m_resources.get(databaseId); 313 if (!resource) 314 return nullptr; 315 return resource->database(); 306 if (auto resource = m_resources.get(databaseId)) 307 return &resource->database(); 308 return nullptr; 316 309 } 317 310 -
trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.h
r229493 r243219 34 34 #include <JavaScriptCore/InspectorFrontendDispatchers.h> 35 35 #include <wtf/HashMap.h> 36 #include <wtf/Optional.h> 36 37 #include <wtf/text/WTFString.h> 37 38 … … 48 49 public: 49 50 explicit InspectorDatabaseAgent(WebAgentContext&); 50 virtual ~InspectorDatabaseAgent() ;51 virtual ~InspectorDatabaseAgent() = default; 51 52 52 53 void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override; 53 54 void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override; 54 55 55 void clearResources();56 56 57 57 // Called from the front-end. … … 64 64 String databaseId(Database&); 65 65 66 void didOpenDatabase(RefPtr<Database>&&, const String& domain, const String& name, const String& version); 66 // InspectorInstrumentation 67 void didCommitLoad(); 68 void didOpenDatabase(Database&); 69 67 70 private: 68 71 Database* databaseForId(const String& databaseId); … … 72 75 RefPtr<Inspector::DatabaseBackendDispatcher> m_backendDispatcher; 73 76 74 typedef HashMap<String, RefPtr<InspectorDatabaseResource>> DatabaseResourcesMap; 75 DatabaseResourcesMap m_resources; 76 bool m_enabled { false }; 77 HashMap<String, RefPtr<InspectorDatabaseResource>> m_resources; 77 78 }; 78 79
Note:
See TracChangeset
for help on using the changeset viewer.