Changeset 244501 in webkit
- Timestamp:
- Apr 22, 2019 9:38:11 AM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 added
- 1 deleted
- 3 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r244483 r244501 1 2019-04-22 Basuke Suzuki <basuke.suzuki@sony.com> 2 3 [PlayStation] Restructuring Remote Inspector classes to support multiple platform. 4 https://bugs.webkit.org/show_bug.cgi?id=197030 5 6 Reviewed by Don Olmstead. 7 8 Restructuring the PlayStation's RemoteInspector backend which uses native socket for the communication to be ready for WinCairo. 9 10 What we did is basically: 11 - Renamed `remote/playstation/` to `remote/socket/`. This directory is now platform independent implementation of socket backend. 12 - Renamed `RemoteInspectorSocket` class to `RemoteInspectorSocketEndpoint`. This class is platform independent and core of the backend. 13 - Merged `RemoteInspectorSocket{Client|Server}` classes into `RemoteInspectorSocketEndpoint` class because the differences are little. 14 - Defined a new interface functions in `Inspector::Socket` (new) namespace. 15 - Moved POSIX socket implementation into `posix\RemoteInspectorSocketPOSIX.{h|cpp}`. 16 17 * PlatformPlayStation.cmake: 18 * inspector/remote/RemoteInspector.h: 19 * inspector/remote/playstation/RemoteInspectorSocketClient.h: Merged into RemoteInspectorSocketEndpoint. 20 * inspector/remote/playstation/RemoteInspectorSocketClientPlayStation.cpp: Merged into RemoteInspectorSocketEndpoint. 21 * inspector/remote/playstation/RemoteInspectorSocketPlayStation.cpp: Removed. 22 * inspector/remote/playstation/RemoteInspectorSocketServer.h: Merged into RemoteInspectorSocketEndpoint. 23 * inspector/remote/playstation/RemoteInspectorSocketServerPlayStation.cpp: Merged into RemoteInspectorSocketEndpoint. 24 * inspector/remote/socket/RemoteInspectorConnectionClient.cpp: Renamed from inspector\remote\playstation\RemoteInspectorConnectionClientPlayStation.cpp. 25 * inspector/remote/socket/RemoteInspectorConnectionClient.h: Renamed from inspector\remote\playstation\RemoteInspectorConnectionClient.h. 26 (Inspector::RemoteInspectorConnectionClient::didAccept): 27 * inspector/remote/socket/RemoteInspectorMessageParser.cpp: Renamed from inspector\remote\playstation\RemoteInspectorMessageParserPlayStation.cpp. 28 * inspector/remote/socket/RemoteInspectorMessageParser.h: Renamed from inspector\remote\playstation\RemoteInspectorMessageParser.h. 29 * inspector/remote/socket/RemoteInspectorServer.cpp: Renamed from inspector\remote\playstation\RemoteInspectorServerPlayStation.cpp. 30 (Inspector::RemoteInspectorServer::didAccept): 31 (Inspector::RemoteInspectorServer::start): 32 * inspector/remote/socket/RemoteInspectorServer.h: Renamed from inspector\remote\playstation\RemoteInspectorServer.h. 33 * inspector/remote/socket/RemoteInspectorSocket.cpp: Renamed from inspector\remote\playstation\RemoteInspectorPlayStation.cpp. 34 (Inspector::RemoteInspector::start): 35 * inspector/remote/socket/RemoteInspectorSocket.h: Copied from inspector\remote\playstation\RemoteInspectorSocket.h. 36 * inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp: Added. 37 (Inspector::RemoteInspectorSocketEndpoint::RemoteInspectorSocketEndpoint): 38 (Inspector::RemoteInspectorSocketEndpoint::~RemoteInspectorSocketEndpoint): 39 (Inspector::RemoteInspectorSocketEndpoint::wakeupWorkerThread): 40 (Inspector::RemoteInspectorSocketEndpoint::connectInet): 41 (Inspector::RemoteInspectorSocketEndpoint::listenInet): 42 (Inspector::RemoteInspectorSocketEndpoint::isListening): 43 (Inspector::RemoteInspectorSocketEndpoint::workerThread): 44 (Inspector::RemoteInspectorSocketEndpoint::createClient): 45 (Inspector::RemoteInspectorSocketEndpoint::recvIfEnabled): 46 (Inspector::RemoteInspectorSocketEndpoint::sendIfEnabled): 47 (Inspector::RemoteInspectorSocketEndpoint::send): 48 (Inspector::RemoteInspectorSocketEndpoint::acceptInetSocketIfEnabled): 49 * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: Renamed from inspector\remote\playstation\RemoteInspectorSocket.h. 50 * inspector/remote/socket/posix/RemoteInspectorSocketPOSIX.cpp: Added. 51 (Inspector::Socket::connect): 52 (Inspector::Socket::listen): 53 (Inspector::Socket::accept): 54 (Inspector::Socket::createPair): 55 (Inspector::Socket::setup): 56 (Inspector::Socket::isValid): 57 (Inspector::Socket::isListening): 58 (Inspector::Socket::read): 59 (Inspector::Socket::write): 60 (Inspector::Socket::close): 61 (Inspector::Socket::preparePolling): 62 (Inspector::Socket::poll): 63 (Inspector::Socket::isReadable): 64 (Inspector::Socket::isWritable): 65 (Inspector::Socket::markWaitingWritable): 66 (Inspector::Socket::clearWaitingWritable): 67 1 68 2019-04-20 Yusuke Suzuki <ysuzuki@apple.com> 2 69 -
trunk/Source/JavaScriptCore/PlatformPlayStation.cmake
r242306 r244501 1 1 list(APPEND JavaScriptCore_PRIVATE_INCLUDE_DIRECTORIES 2 "${JAVASCRIPTCORE_DIR}/inspector/remote/ playstation"2 "${JAVASCRIPTCORE_DIR}/inspector/remote/socket" 3 3 ) 4 4 … … 10 10 inspector/remote/RemoteInspector.h 11 11 12 inspector/remote/playstation/RemoteInspectorConnectionClient.h 13 inspector/remote/playstation/RemoteInspectorMessageParser.h 14 inspector/remote/playstation/RemoteInspectorServer.h 15 inspector/remote/playstation/RemoteInspectorSocket.h 16 inspector/remote/playstation/RemoteInspectorSocketClient.h 17 inspector/remote/playstation/RemoteInspectorSocketServer.h 12 inspector/remote/socket/RemoteInspectorConnectionClient.h 13 inspector/remote/socket/RemoteInspectorMessageParser.h 14 inspector/remote/socket/RemoteInspectorServer.h 15 inspector/remote/socket/RemoteInspectorSocket.h 16 inspector/remote/socket/RemoteInspectorSocketEndpoint.h 18 17 ) 19 18 … … 27 26 inspector/remote/RemoteInspector.cpp 28 27 29 inspector/remote/ playstation/RemoteInspectorConnectionClientPlayStation.cpp30 inspector/remote/ playstation/RemoteInspectorMessageParserPlayStation.cpp31 inspector/remote/ playstation/RemoteInspectorPlayStation.cpp32 inspector/remote/ playstation/RemoteInspectorServerPlayStation.cpp33 inspector/remote/ playstation/RemoteInspectorSocketClientPlayStation.cpp34 inspector/remote/playstation/RemoteInspectorSocketPlayStation.cpp 35 inspector/remote/ playstation/RemoteInspectorSocketServerPlayStation.cpp28 inspector/remote/socket/RemoteInspectorConnectionClient.cpp 29 inspector/remote/socket/RemoteInspectorMessageParser.cpp 30 inspector/remote/socket/RemoteInspectorServer.cpp 31 inspector/remote/socket/RemoteInspectorSocket.cpp 32 inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp 33 34 inspector/remote/socket/posix/RemoteInspectorSocketPOSIX.cpp 36 35 ) 37 36 -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h
r242306 r244501 55 55 #include "RemoteConnectionToTarget.h" 56 56 #include "RemoteInspectorConnectionClient.h" 57 #include "RemoteInspectorSocket Client.h"57 #include "RemoteInspectorSocketEndpoint.h" 58 58 #include <wtf/JSONValues.h> 59 59 #include <wtf/RefCounted.h> … … 237 237 238 238 #if PLATFORM(PLAYSTATION) 239 std::unique_ptr<RemoteInspectorSocket Client> m_socketConnection;239 std::unique_ptr<RemoteInspectorSocketEndpoint> m_socketConnection; 240 240 static PlatformSocketType s_connectionIdentifier; 241 241 Optional<ClientID> m_clientID; -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorConnectionClient.cpp
r244500 r244501 29 29 #if ENABLE(REMOTE_INSPECTOR) 30 30 31 #include "RemoteInspectorSocket .h"31 #include "RemoteInspectorSocketEndpoint.h" 32 32 #include <wtf/JSONValues.h> 33 33 #include <wtf/RunLoop.h> -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorConnectionClient.h
r244500 r244501 28 28 #if ENABLE(REMOTE_INSPECTOR) 29 29 30 #include "RemoteInspectorSocket .h"30 #include "RemoteInspectorSocketEndpoint.h" 31 31 #include <wtf/WeakPtr.h> 32 32 #include <wtf/text/WTFString.h> … … 37 37 public: 38 38 void didReceiveWebInspectorEvent(ClientID, Vector<uint8_t>&&); 39 virtual void didAccept(ClientID, RemoteInspectorSocket::DomainType) { };39 virtual void didAccept(ClientID, Socket::Domain) { }; 40 40 virtual void didClose(ClientID) = 0; 41 41 -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorMessageParser.cpp
r244500 r244501 27 27 #include "RemoteInspectorMessageParser.h" 28 28 29 #include < netinet/in.h>29 #include <wtf/ByteOrder.h> 30 30 31 31 #if ENABLE(REMOTE_INSPECTOR) -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorMessageParser.h
r244500 r244501 28 28 #if ENABLE(REMOTE_INSPECTOR) 29 29 30 #include "RemoteInspectorSocket .h"30 #include "RemoteInspectorSocketEndpoint.h" 31 31 #include <wtf/Vector.h> 32 32 -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorServer.cpp
r244500 r244501 45 45 } 46 46 47 void RemoteInspectorServer::didAccept(ClientID clientID, RemoteInspectorSocket::DomainTypetype)47 void RemoteInspectorServer::didAccept(ClientID clientID, Socket::Domain type) 48 48 { 49 49 ASSERT(!isMainThread()); 50 50 51 if (type == RemoteInspectorSocket::DomainType::Inet) {51 if (type == Socket::Domain::Network) { 52 52 if (m_clientConnection) { 53 53 LOG_ERROR("Inspector server can accept only 1 client"); … … 55 55 } 56 56 m_clientConnection = clientID; 57 } else if (type == RemoteInspectorSocket::DomainType::Unix) {57 } else if (type == Socket::Domain::Local) { 58 58 LockHolder lock(m_connectionsLock); 59 59 m_inspectorConnections.append(clientID); … … 107 107 bool RemoteInspectorServer::start(uint16_t port) 108 108 { 109 m_server = RemoteInspectorSocket Server::create(this);109 m_server = RemoteInspectorSocketEndpoint::create(this, "RemoteInspectorServer"); 110 110 111 111 if (!m_server->listenInet(port)) { -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorServer.h
r244500 r244501 31 31 32 32 #include "RemoteInspectorConnectionClient.h" 33 #include "RemoteInspectorSocketServer.h"34 33 #include <wtf/HashMap.h> 35 34 #include <wtf/HashSet.h> … … 60 59 void clientConnectionClosed(); 61 60 62 void didAccept(ClientID, RemoteInspectorSocket::DomainType) override;61 void didAccept(ClientID, Socket::Domain) override; 63 62 void didClose(ClientID) override; 64 63 … … 68 67 69 68 HashSet<std::pair<uint64_t, uint64_t>> m_inspectionTargets; 70 std::unique_ptr<RemoteInspectorSocket Server> m_server;69 std::unique_ptr<RemoteInspectorSocketEndpoint> m_server; 71 70 72 71 // Connections to the WebProcess. -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.cpp
r244500 r244501 93 93 m_enabled = true; 94 94 95 m_socketConnection = RemoteInspectorSocket Client::create(this);95 m_socketConnection = RemoteInspectorSocketEndpoint::create(this, "RemoteInspector"); 96 96 97 97 m_clientID = m_socketConnection->createClient(s_connectionIdentifier); -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.h
r244500 r244501 28 28 #if ENABLE(REMOTE_INSPECTOR) 29 29 30 #include <array> 31 #include <wtf/Optional.h> 32 #include <wtf/Vector.h> 33 34 #if PLATFORM(PLAYSTATION) 30 35 #include <poll.h> 31 #include <thread> 32 #include <wtf/Condition.h> 33 #include <wtf/Function.h> 34 #include <wtf/HashMap.h> 35 #include <wtf/Lock.h> 36 #include <wtf/Threading.h> 37 #include <wtf/Vector.h> 38 #include <wtf/WeakPtr.h> 36 #endif 37 38 #if OS(WINDOWS) 39 #include <winsock2.h> 40 #endif 39 41 40 42 namespace Inspector { 41 43 44 #if OS(WINDOWS) 45 46 using ClientID = unsigned; 47 using PlatformSocketType = SOCKET; 48 using PollingDescriptor = WSAPOLLFD; 49 constexpr PlatformSocketType INVALID_SOCKET_VALUE = INVALID_SOCKET; 50 51 #else 52 42 53 using ClientID = unsigned; 43 54 using PlatformSocketType = int; 55 using PollingDescriptor = struct pollfd; 44 56 constexpr PlatformSocketType INVALID_SOCKET_VALUE = -1; 45 57 58 #endif 59 46 60 class MessageParser; 47 class RemoteInspectorConnectionClient;48 61 49 class JS_EXPORT_PRIVATE RemoteInspectorSocket { 50 public: 51 RemoteInspectorSocket(RemoteInspectorConnectionClient*); 52 ~RemoteInspectorSocket(); 62 namespace Socket { 53 63 54 enum class DomainType{55 Unix,56 Inet,57 64 enum class Domain { 65 Local, 66 Network, 67 }; 58 68 59 void send(ClientID, const uint8_t* data, size_t); 69 Optional<PlatformSocketType> connect(const char* serverAddress, uint16_t serverPort); 70 Optional<PlatformSocketType> listen(uint16_t port); 71 Optional<PlatformSocketType> accept(PlatformSocketType); 72 Optional<std::array<PlatformSocketType, 2>> createPair(); 60 73 61 Optional<ClientID> createClient(PlatformSocketType fd); 74 void setup(PlatformSocketType); 75 bool isValid(PlatformSocketType); 76 bool isListening(PlatformSocketType); 62 77 63 protected: 64 void recvIfEnabled(ClientID); 65 void sendIfEnabled(ClientID); 66 void workerThread(); 67 void wakeupWorkerThread(); 68 void acceptInetSocketIfEnabled(ClientID); 69 bool isListening(ClientID); 78 Optional<size_t> read(PlatformSocketType, void* buffer, int bufferSize); 79 Optional<size_t> write(PlatformSocketType, const void* data, int size); 70 80 71 struct Connection { 72 std::unique_ptr<MessageParser> parser; 73 Vector<uint8_t> sendBuffer; 74 struct pollfd poll; 75 PlatformSocketType socket { INVALID_SOCKET_VALUE }; 76 }; 81 void close(PlatformSocketType&); 77 82 78 Lock m_connectionsLock; 79 HashMap<ClientID, std::unique_ptr<struct Connection>> m_connections; 83 PollingDescriptor preparePolling(PlatformSocketType); 84 bool poll(Vector<PollingDescriptor>&, int timeout); 85 bool isReadable(const PollingDescriptor&); 86 bool isWritable(const PollingDescriptor&); 87 void markWaitingWritable(PollingDescriptor&); 88 void clearWaitingWritable(PollingDescriptor&); 80 89 81 PlatformSocketType m_wakeupSendSocket { INVALID_SOCKET_VALUE }; 82 PlatformSocketType m_wakeupReceiveSocket { INVALID_SOCKET_VALUE }; 90 struct Connection { 91 std::unique_ptr<MessageParser> parser; 92 Vector<uint8_t> sendBuffer; 93 PlatformSocketType socket { INVALID_SOCKET_VALUE }; 94 PollingDescriptor poll; 95 }; 83 96 84 RefPtr<Thread> m_workerThread; 85 std::atomic<bool> m_shouldAbortWorkerThread { false }; 97 constexpr size_t BufferSize = 65536; 86 98 87 WeakPtr<RemoteInspectorConnectionClient> m_inspectorClient; 88 }; 99 } // namespace Socket 89 100 90 101 } // namespace Inspector -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocketEndpoint.h
r244500 r244501 28 28 #if ENABLE(REMOTE_INSPECTOR) 29 29 30 #include <poll.h>31 #include <thread> 30 #include "RemoteInspectorSocket.h" 31 32 32 #include <wtf/Condition.h> 33 33 #include <wtf/Function.h> … … 40 40 namespace Inspector { 41 41 42 using ClientID = unsigned;43 using PlatformSocketType = int;44 constexpr PlatformSocketType INVALID_SOCKET_VALUE = -1;45 46 42 class MessageParser; 47 43 class RemoteInspectorConnectionClient; 48 44 49 class JS_EXPORT_PRIVATE RemoteInspectorSocket {45 class JS_EXPORT_PRIVATE RemoteInspectorSocketEndpoint { 50 46 public: 51 RemoteInspectorSocket(RemoteInspectorConnectionClient*); 52 ~RemoteInspectorSocket(); 47 static std::unique_ptr<RemoteInspectorSocketEndpoint> create(RemoteInspectorConnectionClient* inspectorClient, const char* name) 48 { 49 return std::make_unique<RemoteInspectorSocketEndpoint>(inspectorClient, name); 50 } 53 51 54 enum class DomainType { 55 Unix, 56 Inet, 57 }; 52 RemoteInspectorSocketEndpoint(RemoteInspectorConnectionClient*, const char*); 53 ~RemoteInspectorSocketEndpoint(); 54 55 Optional<ClientID> connectInet(const char* serverAddr, uint16_t serverPort); 56 bool listenInet(uint16_t port); 58 57 59 58 void send(ClientID, const uint8_t* data, size_t); … … 69 68 bool isListening(ClientID); 70 69 71 struct Connection {72 std::unique_ptr<MessageParser> parser;73 Vector<uint8_t> sendBuffer;74 struct pollfd poll;75 PlatformSocketType socket { INVALID_SOCKET_VALUE };76 };77 78 70 Lock m_connectionsLock; 79 HashMap<ClientID, std::unique_ptr< structConnection>> m_connections;71 HashMap<ClientID, std::unique_ptr<Socket::Connection>> m_connections; 80 72 81 73 PlatformSocketType m_wakeupSendSocket { INVALID_SOCKET_VALUE };
Note: See TracChangeset
for help on using the changeset viewer.