|
| 1 | +2013-12-03 Joseph Pecoraro < [email protected]> |
| 2 | + |
| 3 | + Web Inspector: Push Remote Inspector debugging connection management into JavaScriptCore |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=124613 |
| 5 | + |
| 6 | + Reviewed by Timothy Hatcher. |
| 7 | + |
| 8 | + Move the ENABLE(REMOTE_INSPECTOR) remote debugger connection management |
| 9 | + into JavaScriptCore (originally from WebKit/mac). Include enhancements: |
| 10 | + |
| 11 | + * allow for different types of remote debuggable targets, |
| 12 | + eventually at least a JSContext, WebView, WKView. |
| 13 | + * allow debuggables to be registered and debugged on any thread. Unlike |
| 14 | + WebViews, JSContexts may be run entirely off of the main thread. |
| 15 | + * move the remote connection (XPC connection) itself off of the main thread, |
| 16 | + it doesn't need to be on the main thread. |
| 17 | + |
| 18 | + Make JSContext @class and JavaScriptCore::JSContextRef |
| 19 | + "JavaScript" Remote Debuggables. |
| 20 | + |
| 21 | + * inspector/remote/RemoteInspectorDebuggable.h: Added. |
| 22 | + * inspector/remote/RemoteInspectorDebuggable.cpp: Added. |
| 23 | + (Inspector::RemoteInspectorDebuggable::RemoteInspectorDebuggable): |
| 24 | + (Inspector::RemoteInspectorDebuggable::~RemoteInspectorDebuggable): |
| 25 | + (Inspector::RemoteInspectorDebuggable::init): |
| 26 | + (Inspector::RemoteInspectorDebuggable::update): |
| 27 | + (Inspector::RemoteInspectorDebuggable::setRemoteDebuggingAllowed): |
| 28 | + (Inspector::RemoteInspectorDebuggable::info): |
| 29 | + RemoteInspectorDebuggable defines a debuggable target. As long as |
| 30 | + something creates a debuggable and is set to allow remote inspection |
| 31 | + it will be listed in remote debuggers. For the different types of |
| 32 | + debuggables (JavaScript and Web) there is different basic information |
| 33 | + that may be listed. |
| 34 | + |
| 35 | + * inspector/InspectorFrontendChannel.h: Added. |
| 36 | + (Inspector::InspectorFrontendChannel::~InspectorFrontendChannel): |
| 37 | + The only thing a debuggable needs for remote debugging is an |
| 38 | + InspectorFrontendChannel a way to send messages to a remote frontend. |
| 39 | + This class provides that method, and is vended to the |
| 40 | + RemoteInspectorDebuggable when a remote connection is setup. |
| 41 | + |
| 42 | + * inspector/remote/RemoteInspector.h: Added. |
| 43 | + * inspector/remote/RemoteInspector.mm: Added. |
| 44 | + Singleton, created at least when the first Debuggable is created. |
| 45 | + This class manages the list of debuggables, any connection to a |
| 46 | + remote debugger proxy (XPC service "com.apple.webinspector"). |
| 47 | + |
| 48 | + (Inspector::dispatchAsyncOnQueueSafeForAnyDebuggable): |
| 49 | + (Inspector::RemoteInspector::shared): |
| 50 | + (Inspector::RemoteInspector::RemoteInspector): |
| 51 | + (Inspector::RemoteInspector::nextAvailableIdentifier): |
| 52 | + (Inspector::RemoteInspector::registerDebuggable): |
| 53 | + (Inspector::RemoteInspector::unregisterDebuggable): |
| 54 | + (Inspector::RemoteInspector::updateDebuggable): |
| 55 | + Debuggable management. When debuggables are added, removed, or updated |
| 56 | + we stash a copy of the debuggable information and push an update to |
| 57 | + debuggers. Stashing a copy of the information in the RemoteInspector |
| 58 | + is a thread safe way to avoid walking over all debuggables to gather |
| 59 | + the information when it is needed. |
| 60 | + |
| 61 | + (Inspector::RemoteInspector::start): |
| 62 | + (Inspector::RemoteInspector::stop): |
| 63 | + Runtime API to enable / disable the feature. |
| 64 | + |
| 65 | + (Inspector::RemoteInspector::listingForDebuggable): |
| 66 | + (Inspector::RemoteInspector::pushListingNow): |
| 67 | + (Inspector::RemoteInspector::pushListingSoon): |
| 68 | + Pushing a listing to remote debuggers. |
| 69 | + |
| 70 | + (Inspector::RemoteInspector::sendMessageToRemoteFrontend): |
| 71 | + (Inspector::RemoteInspector::setupXPCConnectionIfNeeded): |
| 72 | + (Inspector::RemoteInspector::xpcConnectionReceivedMessage): |
| 73 | + (Inspector::RemoteInspector::xpcConnectionFailed): |
| 74 | + (Inspector::RemoteInspector::xpcConnectionUnhandledMessage): |
| 75 | + XPC setup, send, and receive handling. |
| 76 | + |
| 77 | + (Inspector::RemoteInspector::updateHasActiveDebugSession): |
| 78 | + Applications being debugged may want to know when a debug |
| 79 | + session is active. This provides that notification. |
| 80 | + |
| 81 | + (Inspector::RemoteInspector::receivedSetupMessage): |
| 82 | + (Inspector::RemoteInspector::receivedDataMessage): |
| 83 | + (Inspector::RemoteInspector::receivedDidCloseMessage): |
| 84 | + (Inspector::RemoteInspector::receivedGetListingMessage): |
| 85 | + (Inspector::RemoteInspector::receivedIndicateMessage): |
| 86 | + (Inspector::RemoteInspector::receivedConnectionDiedMessage): |
| 87 | + Dispatching incoming remote debugging protocol messages. |
| 88 | + These are wrapping above the inspector protocol messages. |
| 89 | + |
| 90 | + * inspector/remote/RemoteInspectorConstants.h: Added. |
| 91 | + Protocol messages and dictionary keys inside the messages. |
| 92 | + |
| 93 | + (Inspector::RemoteInspectorDebuggableInfo::RemoteInspectorDebuggableInfo): |
| 94 | + * inspector/remote/RemoteInspectorDebuggableConnection.h: Added. |
| 95 | + * inspector/remote/RemoteInspectorDebuggableConnection.mm: Added. |
| 96 | + This is a connection between the RemoteInspector singleton and a RemoteInspectorDebuggable. |
| 97 | + |
| 98 | + (Inspector::RemoteInspectorDebuggableConnection::RemoteInspectorDebuggableConnection): |
| 99 | + (Inspector::RemoteInspectorDebuggableConnection::~RemoteInspectorDebuggableConnection): |
| 100 | + Allow for dispatching messages on JavaScript debuggables on a dispatch_queue |
| 101 | + instead of the main queue. |
| 102 | + |
| 103 | + (Inspector::RemoteInspectorDebuggableConnection::destination): |
| 104 | + (Inspector::RemoteInspectorDebuggableConnection::connectionIdentifier): |
| 105 | + Needed in the remote debugging protocol to identify the remote debugger. |
| 106 | + |
| 107 | + (Inspector::RemoteInspectorDebuggableConnection::dispatchSyncOnDebuggable): |
| 108 | + (Inspector::RemoteInspectorDebuggableConnection::dispatchAsyncOnDebuggable): |
| 109 | + (Inspector::RemoteInspectorDebuggableConnection::setup): |
| 110 | + (Inspector::RemoteInspectorDebuggableConnection::closeFromDebuggable): |
| 111 | + (Inspector::RemoteInspectorDebuggableConnection::close): |
| 112 | + (Inspector::RemoteInspectorDebuggableConnection::sendMessageToBackend): |
| 113 | + (Inspector::RemoteInspectorDebuggableConnection::sendMessageToFrontend): |
| 114 | + The connection is a thin channel between the two sides that can be closed |
| 115 | + from either side, so there is some logic around multi-threaded access. |
| 116 | + |
| 117 | + * inspector/remote/RemoteInspectorXPCConnection.h: Added. |
| 118 | + (Inspector::RemoteInspectorXPCConnection::Client::~Client): |
| 119 | + * inspector/remote/RemoteInspectorXPCConnection.mm: Added. |
| 120 | + (Inspector::RemoteInspectorXPCConnection::RemoteInspectorXPCConnection): |
| 121 | + (Inspector::RemoteInspectorXPCConnection::~RemoteInspectorXPCConnection): |
| 122 | + (Inspector::RemoteInspectorXPCConnection::close): |
| 123 | + (Inspector::RemoteInspectorXPCConnection::deserializeMessage): |
| 124 | + (Inspector::RemoteInspectorXPCConnection::handleEvent): |
| 125 | + (Inspector::RemoteInspectorXPCConnection::sendMessage): |
| 126 | + This is a connection between the RemoteInspector singleton and an XPC service |
| 127 | + named "com.apple.webinspector". This handles serialization of the dictionary |
| 128 | + messages to and from the service. The receiving is done on a non-main queue. |
| 129 | + |
| 130 | + * API/JSContext.h: |
| 131 | + * API/JSContext.mm: |
| 132 | + (-[JSContext name]): |
| 133 | + (-[JSContext setName:]): |
| 134 | + ObjC API to enable/disable JSContext remote inspection and give a name. |
| 135 | + |
| 136 | + * API/JSContextRef.h: |
| 137 | + * API/JSContextRef.cpp: |
| 138 | + (JSGlobalContextGetName): |
| 139 | + (JSGlobalContextSetName): |
| 140 | + C API to give a JSContext a name. |
| 141 | + |
| 142 | + * runtime/JSGlobalObject.cpp: |
| 143 | + (JSC::JSGlobalObject::setName): |
| 144 | + * runtime/JSGlobalObject.h: |
| 145 | + (JSC::JSGlobalObject::name): |
| 146 | + Shared handling of the APIs above. |
| 147 | + |
| 148 | + * runtime/JSGlobalObjectDebuggable.cpp: Added. |
| 149 | + (JSC::JSGlobalObjectDebuggable::JSGlobalObjectDebuggable): |
| 150 | + (JSC::JSGlobalObjectDebuggable::name): |
| 151 | + (JSC::JSGlobalObjectDebuggable::connect): |
| 152 | + (JSC::JSGlobalObjectDebuggable::disconnect): |
| 153 | + (JSC::JSGlobalObjectDebuggable::dispatchMessageFromRemoteFrontend): |
| 154 | + * runtime/JSGlobalObjectDebuggable.h: Added. |
| 155 | + Stub for the actual remote debugging implementation. We will push |
| 156 | + down the appropriate WebCore/inspector peices suitable for debugging |
| 157 | + just a JavaScript context. |
| 158 | + |
| 159 | + * CMakeLists.txt: |
| 160 | + * JavaScriptCore.xcodeproj/project.pbxproj: |
| 161 | + * GNUmakefile.am: |
| 162 | + * GNUmakefile.list.am: |
| 163 | + * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: |
| 164 | + * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: |
| 165 | + Update build files. |
| 166 | + |
1 | 167 | 2013-12-04 Michael Saboff < [email protected]> |
2 | 168 |
|
3 | 169 | Move the setting up of callee's callFrame from pushFrame to callToJavaScript thunk |
|
0 commit comments