diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
| commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
| tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/inspector/remote | |
| parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
| download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz | |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/inspector/remote')
6 files changed, 0 insertions, 645 deletions
diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspector.h b/Source/JavaScriptCore/inspector/remote/RemoteInspector.h deleted file mode 100644 index 68a3c53ec..000000000 --- a/Source/JavaScriptCore/inspector/remote/RemoteInspector.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(REMOTE_INSPECTOR) - -#ifndef RemoteInspector_h -#define RemoteInspector_h - -#import "RemoteInspectorXPCConnection.h" -#import <wtf/Forward.h> -#import <wtf/HashMap.h> -#import <wtf/Lock.h> -#import <wtf/RetainPtr.h> - -OBJC_CLASS NSDictionary; -OBJC_CLASS NSString; - -namespace Inspector { - -class RemoteInspectorClient; -class RemoteInspectorDebuggable; -class RemoteInspectorDebuggableConnection; -struct RemoteInspectorDebuggableInfo; - -class JS_EXPORT_PRIVATE RemoteInspector final : public RemoteInspectorXPCConnection::Client { -public: - static void startDisabled(); - static RemoteInspector& singleton(); - friend class NeverDestroyed<RemoteInspector>; - - void registerDebuggable(RemoteInspectorDebuggable*); - void unregisterDebuggable(RemoteInspectorDebuggable*); - void updateDebuggable(RemoteInspectorDebuggable*); - void updateDebuggableAutomaticInspectCandidate(RemoteInspectorDebuggable*); - void sendMessageToRemoteFrontend(unsigned identifier, const String& message); - void setupFailed(unsigned identifier); - void setupCompleted(unsigned identifier); - bool waitingForAutomaticInspection(unsigned identifier); - - bool enabled() const { return m_enabled; } - bool hasActiveDebugSession() const { return m_hasActiveDebugSession; } - - void start(); - void stop(); - - bool hasParentProcessInformation() const { return m_parentProcessIdentifier != 0; } - pid_t parentProcessIdentifier() const { return m_parentProcessIdentifier; } - RetainPtr<CFDataRef> parentProcessAuditData() const { return m_parentProcessAuditData; } - void setParentProcessInformation(pid_t, RetainPtr<CFDataRef> auditData); - void setParentProcessInfomationIsDelayed(); - -private: - RemoteInspector(); - - unsigned nextAvailableIdentifier(); - - enum class StopSource { API, XPCMessage }; - void stopInternal(StopSource); - - void setupXPCConnectionIfNeeded(); - - NSDictionary *listingForDebuggable(const RemoteInspectorDebuggableInfo&) const; - void pushListingNow(); - void pushListingSoon(); - - void updateHasActiveDebugSession(); - - void sendAutomaticInspectionCandidateMessage(); - - virtual void xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo) override; - virtual void xpcConnectionFailed(RemoteInspectorXPCConnection*) override; - virtual void xpcConnectionUnhandledMessage(RemoteInspectorXPCConnection*, xpc_object_t) override; - - void receivedSetupMessage(NSDictionary *userInfo); - void receivedDataMessage(NSDictionary *userInfo); - void receivedDidCloseMessage(NSDictionary *userInfo); - void receivedGetListingMessage(NSDictionary *userInfo); - void receivedIndicateMessage(NSDictionary *userInfo); - void receivedProxyApplicationSetupMessage(NSDictionary *userInfo); - void receivedConnectionDiedMessage(NSDictionary *userInfo); - void receivedAutomaticInspectionConfigurationMessage(NSDictionary *userInfo); - void receivedAutomaticInspectionRejectMessage(NSDictionary *userInfo); - - static bool startEnabled; - - // Debuggables can be registered from any thread at any time. - // Any debuggable can send messages over the XPC connection. - // So lock access to all maps and state as they can change - // from any thread. - Lock m_mutex; - - HashMap<unsigned, std::pair<RemoteInspectorDebuggable*, RemoteInspectorDebuggableInfo>> m_debuggableMap; - HashMap<unsigned, RefPtr<RemoteInspectorDebuggableConnection>> m_connectionMap; - RefPtr<RemoteInspectorXPCConnection> m_xpcConnection; - - dispatch_queue_t m_xpcQueue; - unsigned m_nextAvailableIdentifier; - int m_notifyToken; - bool m_enabled; - bool m_hasActiveDebugSession; - bool m_pushScheduled; - - pid_t m_parentProcessIdentifier; - RetainPtr<CFDataRef> m_parentProcessAuditData; - bool m_shouldSendParentProcessInformation; - bool m_automaticInspectionEnabled; - bool m_automaticInspectionPaused; - unsigned m_automaticInspectionCandidateIdentifier; -}; - -} // namespace Inspector - -#endif // RemoteInspector_h - -#endif // ENABLE(REMOTE_INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h b/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h deleted file mode 100644 index 5d9ddbdd8..000000000 --- a/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2011 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef RemoteInspectorConstants_h -#define RemoteInspectorConstants_h - -// WIRConstants are "Web Inspector Relay" constants shared between -// the WebInspector framework on the OS X side, webinspectord, and -// iOS WebKit on the device side. - -#define WIRSimulatorTCPPortNumber 27753 -#define WIRXPCMachPortName "com.apple.webinspector" -#define WIRXPCDebuggerServiceName "com.apple.webinspector.debugger" -#define WIRServiceAvailableNotification "com.apple.webinspectord.available" -#define WIRServiceAvailabilityCheckNotification "com.apple.webinspectord.availability_check" -#define WIRServiceEnabledNotification "com.apple.webinspectord.enabled" -#define WIRServiceDisabledNotification "com.apple.webinspectord.disabled" -#define WIRAutomaticInspectionEnabledState "com.apple.webinspectord.automatic_inspection_enabled" - - -#define WIRApplicationIdentifierKey @"WIRApplicationIdentifierKey" -#define WIRApplicationBundleIdentifierKey @"WIRApplicationBundleIdentifierKey" -#define WIRApplicationNameKey @"WIRApplicationNameKey" -#define WIRIsApplicationProxyKey @"WIRIsApplicationProxyKey" -#define WIRIsApplicationActiveKey @"WIRIsApplicationActiveKey" -#define WIRHostApplicationIdentifierKey @"WIRHostApplicationIdentifierKey" -#define WIRHostApplicationNameKey @"WIRHostApplicationNameKey" -#define WIRConnectionIdentifierKey @"WIRConnectionIdentifierKey" -#define WIRPageIdentifierKey @"WIRPageIdentifierKey" -#define WIRHasLocalDebuggerKey @"WIRHasLocalDebuggerKey" -#define WIRTitleKey @"WIRTitleKey" -#define WIRURLKey @"WIRURLKey" -#define WIRUserInfoKey @"WIRUserInfoKey" -#define WIRApplicationDictionaryKey @"WIRApplicationDictionaryKey" -#define WIRMessageDataKey @"WIRMessageDataKey" -#define WIRApplicationGetListingMessage @"WIRApplicationGetListingMessage" -#define WIRIndicateMessage @"WIRIndicateMessage" -#define WIRIndicateEnabledKey @"WIRIndicateEnabledKey" -#define WIRSenderKey @"WIRSenderKey" -#define WIRSocketDataKey @"WIRSocketDataKey" -#define WIRSocketDataMessage @"WIRSocketDataMessage" -#define WIRSocketSetupMessage @"WIRSocketSetupMessage" -#define WIRWebPageCloseMessage @"WIRWebPageCloseMessage" -#define WIRRawDataMessage @"WIRRawDataMessage" -#define WIRRawDataKey @"WIRRawDataKey" -#define WIRListingMessage @"WIRListingMessage" -#define WIRListingKey @"WIRListingKey" -#define WIRDestinationKey @"WIRDestinationKey" -#define WIRConnectionDiedMessage @"WIRConnectionDiedMessage" -#define WIRTypeKey @"WIRTypeKey" -#define WIRTypeJavaScript @"WIRTypeJavaScript" -#define WIRTypeWeb @"WIRTypeWeb" -#define WIRAutomaticallyPause @"WIRAutomaticallyPause" - -#define WIRAutomaticInspectionEnabledKey @"WIRAutomaticInspectionEnabledKey" -#define WIRAutomaticInspectionSessionIdentifierKey @"WIRAutomaticInspectionSessionIdentifierKey" -#define WIRAutomaticInspectionConfigurationMessage @"WIRAutomaticInspectionConfigurationMessage" -#define WIRAutomaticInspectionRejectMessage @"WIRAutomaticInspectionRejectMessage" -#define WIRAutomaticInspectionCandidateMessage @"WIRAutomaticInspectionCandidateMessage" - -// These definitions are shared with a Simulator webinspectord and -// OS X process communicating with it. - -#define WIRSimulatorBuildKey @"WIRSimulatorBuildKey" -#define WIRSimulatorProductVersionKey @"WIRSimulatorProductVersionKey" -#define WIRSimulatorNameKey @"WIRSimulatorNameKey" - -// These definitions are shared between webinspectord and WebKit. - -#define WIRPermissionDenied @"WIRPermissionDenied" -#define WIRProxyApplicationParentPIDKey @"WIRProxyApplicationParentPID" -#define WIRProxyApplicationParentAuditDataKey @"WIRProxyApplicationParentAuditData" -#define WIRProxyApplicationSetupMessage @"WIRProxyApplicationSetupMessage" -#define WIRProxyApplicationSetupResponseMessage @"WIRProxyApplicationSetupResponseMessage" - -#endif diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.cpp b/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.cpp deleted file mode 100644 index ac83a18e9..000000000 --- a/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "RemoteInspectorDebuggable.h" - -#if ENABLE(REMOTE_INSPECTOR) - -#include "EventLoop.h" -#include "InspectorFrontendChannel.h" -#include "RemoteInspector.h" - -namespace Inspector { - -RemoteInspectorDebuggable::RemoteInspectorDebuggable() - : m_identifier(0) - , m_allowed(false) -{ -} - -RemoteInspectorDebuggable::~RemoteInspectorDebuggable() -{ - RemoteInspector::singleton().unregisterDebuggable(this); -} - -void RemoteInspectorDebuggable::init() -{ - RemoteInspector::singleton().registerDebuggable(this); -} - -void RemoteInspectorDebuggable::update() -{ - RemoteInspector::singleton().updateDebuggable(this); -} - -void RemoteInspectorDebuggable::setRemoteDebuggingAllowed(bool allowed) -{ - if (m_allowed == allowed) - return; - - m_allowed = allowed; - - if (m_allowed && automaticInspectionAllowed()) - RemoteInspector::singleton().updateDebuggableAutomaticInspectCandidate(this); - else - RemoteInspector::singleton().updateDebuggable(this); -} - -RemoteInspectorDebuggableInfo RemoteInspectorDebuggable::info() const -{ - RemoteInspectorDebuggableInfo info; - info.identifier = identifier(); - info.type = type(); - info.name = name(); - info.url = url(); - info.hasLocalDebugger = hasLocalDebugger(); - info.remoteDebuggingAllowed = remoteDebuggingAllowed(); - return info; -} - -void RemoteInspectorDebuggable::pauseWaitingForAutomaticInspection() -{ - ASSERT(m_identifier); - ASSERT(m_allowed); - ASSERT(automaticInspectionAllowed()); - - EventLoop loop; - while (RemoteInspector::singleton().waitingForAutomaticInspection(identifier()) && !loop.ended()) - loop.cycle(); -} - -void RemoteInspectorDebuggable::unpauseForInitializedInspector() -{ - RemoteInspector::singleton().setupCompleted(identifier()); -} - -} // namespace Inspector - -#endif // ENABLE(REMOTE_INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h b/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h deleted file mode 100644 index 064b83ae8..000000000 --- a/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(REMOTE_INSPECTOR) - -#ifndef RemoteInspectorDebuggable_h -#define RemoteInspectorDebuggable_h - -#include <CoreFoundation/CFRunLoop.h> -#include <wtf/RetainPtr.h> -#include <wtf/text/WTFString.h> - -namespace Inspector { - -class FrontendChannel; - -struct RemoteInspectorDebuggableInfo; - -class JS_EXPORT_PRIVATE RemoteInspectorDebuggable { -public: - RemoteInspectorDebuggable(); - virtual ~RemoteInspectorDebuggable(); - - void init(); - void update(); - - unsigned identifier() const { return m_identifier; } - void setIdentifier(unsigned identifier) { m_identifier = identifier; } - - bool remoteDebuggingAllowed() const { return m_allowed; } - void setRemoteDebuggingAllowed(bool); - - CFRunLoopRef debuggerRunLoop() { return m_runLoop.get(); } - void setDebuggerRunLoop(CFRunLoopRef runLoop) { m_runLoop = runLoop; } - - RemoteInspectorDebuggableInfo info() const; - - enum DebuggableType { JavaScript, Web }; - virtual DebuggableType type() const = 0; - virtual String name() const { return String(); } // JavaScript and Web - virtual String url() const { return String(); } // Web - virtual bool hasLocalDebugger() const = 0; - - virtual void connect(FrontendChannel*, bool isAutomaticInspection) = 0; - virtual void disconnect() = 0; - virtual void dispatchMessageFromRemoteFrontend(const String& message) = 0; - virtual void setIndicating(bool) { } // Default is to do nothing. - virtual void pause() { }; - - virtual bool automaticInspectionAllowed() const { return false; } - virtual void pauseWaitingForAutomaticInspection(); - virtual void unpauseForInitializedInspector(); - -private: - unsigned m_identifier; - bool m_allowed; - RetainPtr<CFRunLoopRef> m_runLoop; -}; - -struct RemoteInspectorDebuggableInfo { - RemoteInspectorDebuggableInfo() - : identifier(0) - , type(RemoteInspectorDebuggable::JavaScript) - , hasLocalDebugger(false) - , remoteDebuggingAllowed(false) - { - } - - unsigned identifier; - RemoteInspectorDebuggable::DebuggableType type; - String name; - String url; - bool hasLocalDebugger; - bool remoteDebuggingAllowed; -}; - -} // namespace Inspector - -#endif // RemoteInspectorDebuggable_h - -#endif // ENABLE(REMOTE_INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h b/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h deleted file mode 100644 index e5e5d4f5d..000000000 --- a/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(REMOTE_INSPECTOR) - -#ifndef RemoteInspectorDebuggableConnection_h -#define RemoteInspectorDebuggableConnection_h - -#import "InspectorFrontendChannel.h" -#import "RemoteInspectorDebuggable.h" -#import <mutex> -#import <wtf/Lock.h> -#import <wtf/RetainPtr.h> -#import <wtf/ThreadSafeRefCounted.h> - -OBJC_CLASS NSString; - -namespace Inspector { - -class RemoteInspectorBlock { -public: - RemoteInspectorBlock(void (^task)()) - : m_task(Block_copy(task)) - { - } - - RemoteInspectorBlock(const RemoteInspectorBlock& other) - : m_task(Block_copy(other.m_task)) - { - } - - ~RemoteInspectorBlock() - { - Block_release(m_task); - } - - RemoteInspectorBlock& operator=(const RemoteInspectorBlock& other) - { - void (^oldTask)() = m_task; - m_task = Block_copy(other.m_task); - Block_release(oldTask); - return *this; - } - - void operator()() const - { - m_task(); - } - -private: - void (^m_task)(); -}; - -typedef Vector<RemoteInspectorBlock> RemoteInspectorQueue; - -class RemoteInspectorDebuggableConnection final : public ThreadSafeRefCounted<RemoteInspectorDebuggableConnection>, public FrontendChannel { -public: - RemoteInspectorDebuggableConnection(RemoteInspectorDebuggable*, NSString *connectionIdentifier, NSString *destination, RemoteInspectorDebuggable::DebuggableType); - virtual ~RemoteInspectorDebuggableConnection(); - - NSString *destination() const; - NSString *connectionIdentifier() const; - unsigned identifier() const { return m_identifier; } - - bool setup(bool isAutomaticInspection, bool automaticallyPause); - - void close(); - void closeFromDebuggable(); - - void sendMessageToBackend(NSString *); - virtual bool sendMessageToFrontend(const String&) override; - - Lock& queueMutex() { return m_queueMutex; } - RemoteInspectorQueue queue() const { return m_queue; } - void clearQueue() { m_queue.clear(); } - -private: - void dispatchAsyncOnDebuggable(void (^block)()); - - void setupRunLoop(); - void teardownRunLoop(); - void queueTaskOnPrivateRunLoop(void (^block)()); - - // This connection from the RemoteInspector singleton to the Debuggable - // can be used on multiple threads. So any access to the debuggable - // itself must take this mutex to ensure m_debuggable is valid. - Lock m_debuggableMutex; - - // If a debuggable has a specific run loop it wants to evaluate on - // we setup our run loop sources on that specific run loop. - RetainPtr<CFRunLoopRef> m_runLoop; - RetainPtr<CFRunLoopSourceRef> m_runLoopSource; - RemoteInspectorQueue m_queue; - Lock m_queueMutex; - - RemoteInspectorDebuggable* m_debuggable; - RetainPtr<NSString> m_connectionIdentifier; - RetainPtr<NSString> m_destination; - unsigned m_identifier; - bool m_connected; -}; - -} // namespace Inspector - -#endif // RemoteInspectorDebuggableConnection_h - -#endif // ENABLE(REMOTE_INSPECTOR) diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h b/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h deleted file mode 100644 index e97ca719e..000000000 --- a/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(REMOTE_INSPECTOR) - -#ifndef RemoteInspectorXPCConnection_h -#define RemoteInspectorXPCConnection_h - -#import <dispatch/dispatch.h> -#import <wtf/Lock.h> -#import <wtf/ThreadSafeRefCounted.h> -#import <wtf/spi/darwin/XPCSPI.h> - -OBJC_CLASS NSDictionary; -OBJC_CLASS NSString; - -namespace Inspector { - -class RemoteInspectorXPCConnection : public ThreadSafeRefCounted<RemoteInspectorXPCConnection> { -public: - class Client { - public: - virtual ~Client() { } - virtual void xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo) = 0; - virtual void xpcConnectionFailed(RemoteInspectorXPCConnection*) = 0; - virtual void xpcConnectionUnhandledMessage(RemoteInspectorXPCConnection*, xpc_object_t) = 0; - }; - - RemoteInspectorXPCConnection(xpc_connection_t, dispatch_queue_t, Client*); - virtual ~RemoteInspectorXPCConnection(); - - void close(); - void closeFromMessage(); - void sendMessage(NSString *messageName, NSDictionary *userInfo); - -private: - NSDictionary *deserializeMessage(xpc_object_t); - void handleEvent(xpc_object_t); - void closeOnQueue(); - - // We handle XPC events on the queue, but a client may call close() on any queue. - // We make sure that m_client is thread safe and immediately cleared in close(). - Lock m_mutex; - - xpc_connection_t m_connection; - dispatch_queue_t m_queue; - Client* m_client; - bool m_closed; -}; - -} // namespace Inspector - -#endif // RemoteInspectorXPCConnection_h - -#endif // ENABLE(REMOTE_INSPECTOR) |
