Changeset 267370 in webkit
- Timestamp:
- Sep 21, 2020, 2:45:23 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/inspector/remote/RemoteControllableTarget.h (modified) (1 diff)
-
JavaScriptCore/inspector/remote/RemoteInspector.h (modified) (2 diffs)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorConnectionClient.cpp (modified) (1 diff)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorConnectionClient.h (modified) (1 diff)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorServer.cpp (modified) (3 diffs)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorServer.h (modified) (1 diff)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.cpp (modified) (1 diff)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.h (modified) (2 diffs)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp (modified) (14 diffs)
-
JavaScriptCore/inspector/remote/socket/RemoteInspectorSocketEndpoint.h (modified) (5 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp (modified) (1 diff)
-
WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r267364 r267370 1 2020-09-21 Basuke Suzuki <basuke.suzuki@sony.com> 2 3 [WinCairo][PlayStation] Support different instances of listener client. 4 https://bugs.webkit.org/show_bug.cgi?id=216733 5 6 Reviewed by Don Olmstead. 7 8 Currently RemoteInspectorSocketEndpoint support one client instance for all 9 listeners. This patch allows listeners to create its own listener client on 10 accept timing. 11 12 * inspector/remote/RemoteControllableTarget.h: 13 * inspector/remote/RemoteInspector.h: 14 * inspector/remote/socket/RemoteInspectorConnectionClient.cpp: 15 (Inspector::RemoteInspectorConnectionClient::didReceive): 16 * inspector/remote/socket/RemoteInspectorConnectionClient.h: 17 * inspector/remote/socket/RemoteInspectorServer.cpp: 18 (Inspector::RemoteInspectorServer::start): 19 (Inspector::RemoteInspectorServer::doAccept): 20 * inspector/remote/socket/RemoteInspectorServer.h: 21 * inspector/remote/socket/RemoteInspectorSocket.cpp: 22 (Inspector::RemoteInspector::didClose): 23 * inspector/remote/socket/RemoteInspectorSocket.h: 24 * inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp: 25 (Inspector::RemoteInspectorSocketEndpoint::RemoteInspectorSocketEndpoint): 26 (Inspector::RemoteInspectorSocketEndpoint::~RemoteInspectorSocketEndpoint): 27 (Inspector::RemoteInspectorSocketEndpoint::listenInet): 28 (Inspector::RemoteInspectorSocketEndpoint::workerThread): 29 (Inspector::RemoteInspectorSocketEndpoint::generateConnectionID): 30 (Inspector::RemoteInspectorSocketEndpoint::createClient): 31 (Inspector::RemoteInspectorSocketEndpoint::disconnect): 32 (Inspector::RemoteInspectorSocketEndpoint::createListener): 33 (Inspector::RemoteInspectorSocketEndpoint::invalidateClient): 34 (Inspector::RemoteInspectorSocketEndpoint::invalidateListener): 35 (Inspector::RemoteInspectorSocketEndpoint::getPort const): 36 (Inspector::RemoteInspectorSocketEndpoint::recvIfEnabled): 37 (Inspector::RemoteInspectorSocketEndpoint::sendIfEnabled): 38 (Inspector::RemoteInspectorSocketEndpoint::send): 39 (Inspector::RemoteInspectorSocketEndpoint::acceptInetSocketIfEnabled): 40 * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: 41 1 42 2020-09-21 Keith Miller <keith_miller@apple.com> 2 43 -
trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h
r262302 r267370 28 28 #if ENABLE(REMOTE_INSPECTOR) 29 29 30 #include "JSExportMacros.h" 30 31 #include <wtf/TypeCasts.h> 31 32 #include <wtf/text/WTFString.h> -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h
r265276 r267370 80 80 { 81 81 public: 82 class Client {82 class JS_EXPORT_PRIVATE Client { 83 83 public: 84 84 struct Capabilities { … … 225 225 #if USE(INSPECTOR_SOCKET_SERVER) 226 226 HashMap<String, CallHandler>& dispatchMap() final; 227 void didClose( ConnectionID) final;227 void didClose(RemoteInspectorSocketEndpoint&, ConnectionID) final; 228 228 229 229 void sendWebInspectorEvent(const String&); -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorConnectionClient.cpp
r266885 r267370 63 63 } 64 64 65 void RemoteInspectorConnectionClient::didReceive( ConnectionID clientID, Vector<uint8_t>&& data)65 void RemoteInspectorConnectionClient::didReceive(RemoteInspectorSocketEndpoint&, ConnectionID clientID, Vector<uint8_t>&& data) 66 66 { 67 67 ASSERT(!isMainThread()); -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorConnectionClient.h
r250988 r267370 47 47 void send(ConnectionID, const uint8_t* data, size_t); 48 48 49 void didReceive( ConnectionID, Vector<uint8_t>&&) override;49 void didReceive(RemoteInspectorSocketEndpoint&, ConnectionID, Vector<uint8_t>&&) override; 50 50 51 51 struct Event { -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorServer.cpp
r265276 r267370 56 56 57 57 auto& endpoint = Inspector::RemoteInspectorSocketEndpoint::singleton(); 58 m_server = endpoint.listenInet(address, port, *this , RemoteInspector::singleton());58 m_server = endpoint.listenInet(address, port, *this); 59 59 return isRunning(); 60 60 } … … 69 69 } 70 70 71 bool RemoteInspectorServer::didAccept(ConnectionID acceptedID, ConnectionID, Socket::Domain)71 Optional<ConnectionID> RemoteInspectorServer::doAccept(RemoteInspectorSocketEndpoint& endpoint, PlatformSocketType socket) 72 72 { 73 73 ASSERT(!isMainThread()); … … 76 76 if (inspector.isConnected()) { 77 77 LOG_ERROR("RemoteInspector can accept only 1 client"); 78 return WTF::nullopt; 79 } 78 80 79 return false; 81 if (auto newID = endpoint.createClient(socket, inspector)) { 82 inspector.connect(newID.value()); 83 return newID; 80 84 } 81 inspector.connect(acceptedID); 82 return true;85 86 return WTF::nullopt; 83 87 } 84 88 -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorServer.h
r265276 r267370 47 47 RemoteInspectorServer() { Socket::init(); } 48 48 49 bool didAccept(ConnectionID acceptedID, ConnectionID listenerID, Socket::Domain) final;50 void didClose( ConnectionID) final { }49 Optional<ConnectionID> doAccept(RemoteInspectorSocketEndpoint&, PlatformSocketType) final; 50 void didClose(RemoteInspectorSocketEndpoint&, ConnectionID) final { }; 51 51 52 52 Optional<ConnectionID> m_server; -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.cpp
r266885 r267370 64 64 } 65 65 66 void RemoteInspector::didClose( ConnectionID)66 void RemoteInspector::didClose(RemoteInspectorSocketEndpoint&, ConnectionID) 67 67 { 68 68 ASSERT(isConnected()); -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.h
r253281 r267370 28 28 #if ENABLE(REMOTE_INSPECTOR) 29 29 30 #include "JSExportMacros.h" 30 31 #include <array> 31 32 #include <wtf/Optional.h> … … 65 66 void init(); 66 67 67 Optional<PlatformSocketType> connect(const char* serverAddress, uint16_t serverPort);68 Optional<PlatformSocketType> listen(const char* address, uint16_t port);69 Optional<PlatformSocketType> accept(PlatformSocketType);70 Optional<std::array<PlatformSocketType, 2>> createPair();68 JS_EXPORT_PRIVATE Optional<PlatformSocketType> connect(const char* serverAddress, uint16_t serverPort); 69 JS_EXPORT_PRIVATE Optional<PlatformSocketType> listen(const char* address, uint16_t port); 70 JS_EXPORT_PRIVATE Optional<PlatformSocketType> accept(PlatformSocketType); 71 JS_EXPORT_PRIVATE Optional<std::array<PlatformSocketType, 2>> createPair(); 71 72 72 bool setup(PlatformSocketType);73 bool isValid(PlatformSocketType);74 bool isListening(PlatformSocketType);75 Optional<uint16_t> getPort(PlatformSocketType);73 JS_EXPORT_PRIVATE bool setup(PlatformSocketType); 74 JS_EXPORT_PRIVATE bool isValid(PlatformSocketType); 75 JS_EXPORT_PRIVATE bool isListening(PlatformSocketType); 76 JS_EXPORT_PRIVATE Optional<uint16_t> getPort(PlatformSocketType); 76 77 77 Optional<size_t> read(PlatformSocketType, void* buffer, int bufferSize);78 Optional<size_t> write(PlatformSocketType, const void* data, int size);78 JS_EXPORT_PRIVATE Optional<size_t> read(PlatformSocketType, void* buffer, int bufferSize); 79 JS_EXPORT_PRIVATE Optional<size_t> write(PlatformSocketType, const void* data, int size); 79 80 80 void close(PlatformSocketType&);81 JS_EXPORT_PRIVATE void close(PlatformSocketType&); 81 82 82 83 PollingDescriptor preparePolling(PlatformSocketType); -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp
r265276 r267370 48 48 RemoteInspectorSocketEndpoint::RemoteInspectorSocketEndpoint() 49 49 { 50 Socket::init(); 51 50 52 if (auto sockets = Socket::createPair()) { 51 53 m_wakeupSendSocket = sockets->at(0); … … 68 70 Socket::close(m_wakeupSendSocket); 69 71 Socket::close(m_wakeupReceiveSocket); 70 for (const auto& connection : m_c onnections.values())72 for (const auto& connection : m_clients.values()) 71 73 Socket::close(connection->socket); 72 74 for (const auto& connection : m_listeners.values()) … … 87 89 } 88 90 89 Optional<ConnectionID> RemoteInspectorSocketEndpoint::listenInet(const char* address, uint16_t port, Listener& listener , Client& client)91 Optional<ConnectionID> RemoteInspectorSocketEndpoint::listenInet(const char* address, uint16_t port, Listener& listener) 90 92 { 91 93 if (auto socket = Socket::listen(address, port)) 92 return createListener(*socket, listener , client);94 return createListener(*socket, listener); 93 95 94 96 return WTF::nullopt; … … 122 124 { 123 125 LockHolder lock(m_connectionsLock); 124 for (const auto& connection : m_c onnections) {126 for (const auto& connection : m_clients) { 125 127 pollfds.append(connection.value->poll); 126 128 ids.append(connection.key); … … 167 169 do { 168 170 id = cryptographicallyRandomNumber(); 169 } while (!id || m_c onnections.contains(id) || m_listeners.contains(id));171 } while (!id || m_clients.contains(id) || m_listeners.contains(id)); 170 172 171 173 return id; 172 174 } 173 175 174 std::unique_ptr<RemoteInspectorSocketEndpoint::Connection> RemoteInspectorSocketEndpoint::makeConnection(PlatformSocketType socket, Client& client)175 {176 ASSERT(m_connectionsLock.isLocked());177 178 Socket::setup(socket);179 180 auto connection = makeUnique<Connection>(client);181 182 connection->id = generateConnectionID();183 connection->poll = Socket::preparePolling(socket);184 connection->socket = socket;185 186 return connection;187 }188 189 176 Optional<ConnectionID> RemoteInspectorSocketEndpoint::createClient(PlatformSocketType socket, Client& client) 190 177 { 191 if (!Socket::isValid(socket)) 192 return WTF::nullopt; 193 194 LockHolder lock(m_connectionsLock); 195 auto connection = makeConnection(socket, client); 196 auto id = connection->id; 197 m_connections.add(id, WTFMove(connection)); 178 ASSERT(Socket::isValid(socket)); 179 180 LockHolder lock(m_connectionsLock); 181 auto id = generateConnectionID(); 182 auto connection = makeUnique<ClientConnection>(id, socket, client); 183 m_clients.add(id, WTFMove(connection)); 198 184 wakeupWorkerThread(); 199 185 … … 201 187 } 202 188 203 Optional<ConnectionID> RemoteInspectorSocketEndpoint::createListener(PlatformSocketType socket, Listener& listener, Client& client) 204 { 205 if (!Socket::isValid(socket)) 206 return WTF::nullopt; 207 208 LockHolder lock(m_connectionsLock); 189 void RemoteInspectorSocketEndpoint::disconnect(ConnectionID id) 190 { 191 LockHolder lock(m_connectionsLock); 192 193 if (const auto& connection = m_listeners.get(id)) { 194 m_listeners.remove(id); 195 Socket::close(connection->socket); 196 lock.unlockEarly(); 197 connection->listener.didClose(*this, id); 198 } else if (const auto& connection = m_clients.get(id)) { 199 m_clients.remove(id); 200 Socket::close(connection->socket); 201 lock.unlockEarly(); 202 connection->client.didClose(*this, id); 203 } else 204 LOG_ERROR("Error: Cannot disconnect: Invalid id"); 205 } 206 207 Optional<ConnectionID> RemoteInspectorSocketEndpoint::createListener(PlatformSocketType socket, Listener& listener) 208 { 209 ASSERT(Socket::isValid(socket)); 209 210 210 211 if (!Socket::setup(socket)) 211 212 return WTF::nullopt; 212 213 213 auto connection = makeConnection(socket, client);214 auto id = connection->id;215 connection->listener = &listener;214 LockHolder lock(m_connectionsLock); 215 auto id = generateConnectionID(); 216 auto connection = makeUnique<ListenerConnection>(id, socket, listener); 216 217 m_listeners.add(id, WTFMove(connection)); 217 218 wakeupWorkerThread(); … … 220 221 } 221 222 223 Optional<ConnectionID> RemoteInspectorSocketEndpoint::createListener(PlatformSocketType socket, Listener& listener, Client& client) 224 { 225 ASSERT(Socket::isValid(socket)); 226 227 if (!Socket::setup(socket)) 228 return WTF::nullopt; 229 230 LockHolder lock(m_connectionsLock); 231 auto id = generateConnectionID(); 232 auto connection = makeUnique<ListenerConnection>(id, socket, listener); 233 m_listeners.add(id, WTFMove(connection)); 234 wakeupWorkerThread(); 235 236 return id; 237 } 238 222 239 void RemoteInspectorSocketEndpoint::invalidateClient(Client& client) 223 240 { 224 241 LockHolder lock(m_connectionsLock); 225 m_c onnections.removeIf([&client](auto& keyValue) {242 m_clients.removeIf([&client](auto& keyValue) { 226 243 const auto& connection = keyValue.value; 227 244 … … 241 258 const auto& connection = keyValue.value; 242 259 243 if ( connection->listener == &listener) {260 if (&connection->listener == &listener) { 244 261 Socket::close(connection->socket); 245 262 return true; … … 255 272 if (const auto& connection = m_listeners.get(id)) 256 273 return Socket::getPort(connection->socket); 257 if (const auto& connection = m_c onnections.get(id))274 if (const auto& connection = m_clients.get(id)) 258 275 return Socket::getPort(connection->socket); 259 276 … … 264 281 { 265 282 LockHolder lock(m_connectionsLock); 266 if (const auto& connection = m_c onnections.get(id)) {283 if (const auto& connection = m_clients.get(id)) { 267 284 Vector<uint8_t> recvBuffer(Socket::BufferSize); 268 285 if (auto readSize = Socket::read(connection->socket, recvBuffer.data(), recvBuffer.size())) { 269 286 if (*readSize > 0) { 270 287 recvBuffer.shrink(*readSize); 271 connection->client.didReceive(id, WTFMove(recvBuffer)); 288 lock.unlockEarly(); 289 connection->client.didReceive(*this, id, WTFMove(recvBuffer)); 272 290 return; 273 291 } … … 275 293 276 294 Socket::close(connection->socket); 277 m_c onnections.remove(id);295 m_clients.remove(id); 278 296 279 297 lock.unlockEarly(); 280 connection->client.didClose( id);298 connection->client.didClose(*this, id); 281 299 } 282 300 } … … 285 303 { 286 304 LockHolder lock(m_connectionsLock); 287 if (const auto& connection = m_c onnections.get(id)) {305 if (const auto& connection = m_clients.get(id)) { 288 306 Socket::clearWaitingWritable(connection->poll); 289 307 … … 310 328 { 311 329 LockHolder lock(m_connectionsLock); 312 if (const auto& connection = m_c onnections.get(id)) {330 if (const auto& connection = m_clients.get(id)) { 313 331 size_t offset = 0; 314 332 if (connection->sendBuffer.isEmpty()) { … … 340 358 // Need to unlock before calling createClient as it also attempts to lock. 341 359 lock.unlockEarly(); 342 if (auto newID = createClient(*socket, connection->client)) { 343 if (connection->listener->didAccept(newID.value(), connection->id, Socket::Domain::Network)) 344 return; 345 346 m_connections.remove(id); 347 } 348 360 if (connection->listener.doAccept(*this, socket.value())) 361 return; 349 362 Socket::close(*socket); 350 363 } -
trunk/Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocketEndpoint.h
r250988 r267370 29 29 30 30 #include "RemoteInspectorSocket.h" 31 32 31 #include <wtf/Condition.h> 33 32 #include <wtf/Function.h> … … 39 38 namespace Inspector { 40 39 41 class RemoteInspectorSocketEndpoint {40 class JS_EXPORT_PRIVATE RemoteInspectorSocketEndpoint { 42 41 WTF_MAKE_FAST_ALLOCATED; 43 42 public: 44 43 class Client { 45 44 public: 46 virtual void didReceive(ConnectionID, Vector<uint8_t>&&) = 0; 47 virtual void didClose(ConnectionID) = 0; 45 virtual ~Client() { } 46 virtual void didReceive(RemoteInspectorSocketEndpoint&, ConnectionID, Vector<uint8_t>&&) = 0; 47 virtual void didClose(RemoteInspectorSocketEndpoint&, ConnectionID) = 0; 48 48 }; 49 49 50 50 class Listener { 51 51 public: 52 virtual bool didAccept(ConnectionID acceptedID, ConnectionID listenerID, Socket::Domain) = 0; 53 virtual void didClose(ConnectionID) = 0; 52 virtual ~Listener() { } 53 virtual Optional<ConnectionID> doAccept(RemoteInspectorSocketEndpoint&, PlatformSocketType) = 0; 54 virtual void didClose(RemoteInspectorSocketEndpoint&, ConnectionID) = 0; 54 55 }; 55 56 … … 60 61 61 62 Optional<ConnectionID> connectInet(const char* serverAddr, uint16_t serverPort, Client&); 62 Optional<ConnectionID> listenInet(const char* address, uint16_t port, Listener& , Client&);63 Optional<ConnectionID> listenInet(const char* address, uint16_t port, Listener&); 63 64 void invalidateClient(Client&); 64 65 void invalidateListener(Listener&); 65 66 66 67 void send(ConnectionID, const uint8_t* data, size_t); 68 inline void send(ConnectionID id, const Vector<uint8_t>& data) { send(id, data.data(), data.size()); } 69 inline void send(ConnectionID id, const char* data, size_t length) { send(id, reinterpret_cast<const uint8_t*>(data), length); } 67 70 68 71 Optional<ConnectionID> createClient(PlatformSocketType, Client&); … … 71 74 Optional<uint16_t> getPort(ConnectionID) const; 72 75 76 void disconnect(ConnectionID); 77 73 78 protected: 74 struct Connection {79 struct BaseConnection { 75 80 WTF_MAKE_STRUCT_FAST_ALLOCATED; 76 explicit Connection(Client& client) 77 : client(client) 81 82 BaseConnection(ConnectionID id, PlatformSocketType socket) 83 : id { id } 84 , socket { socket } 85 , poll { Socket::preparePolling(socket) } 86 { 87 ASSERT(Socket::isValid(socket)); 88 } 89 90 ConnectionID id; 91 PlatformSocketType socket; 92 PollingDescriptor poll; 93 }; 94 95 struct ClientConnection : public BaseConnection { 96 ClientConnection(ConnectionID id, PlatformSocketType socket, Client& client) 97 : BaseConnection(id, socket) 98 , client { client } 78 99 { 79 100 } 80 101 81 C onnectionID id;102 Client& client; 82 103 Vector<uint8_t> sendBuffer; 83 PlatformSocketType socket { INVALID_SOCKET_VALUE }; 84 PollingDescriptor poll; 85 Client& client; 86 Listener* listener { }; 104 }; 105 106 struct ListenerConnection : public BaseConnection { 107 ListenerConnection(ConnectionID id, PlatformSocketType socket, Listener& listener) 108 : BaseConnection(id, socket) 109 , listener { listener } 110 { 111 } 112 113 Listener& listener; 87 114 }; 88 115 89 116 ConnectionID generateConnectionID(); 90 std::unique_ptr<Connection> makeConnection(PlatformSocketType, Client&);117 Optional<ConnectionID> createListener(PlatformSocketType, Listener&); 91 118 92 119 void recvIfEnabled(ConnectionID); … … 98 125 99 126 mutable Lock m_connectionsLock; 100 HashMap<ConnectionID, std::unique_ptr<C onnection>> m_connections;101 HashMap<ConnectionID, std::unique_ptr< Connection>> m_listeners;127 HashMap<ConnectionID, std::unique_ptr<ClientConnection>> m_clients; 128 HashMap<ConnectionID, std::unique_ptr<ListenerConnection>> m_listeners; 102 129 103 130 PlatformSocketType m_wakeupSendSocket { INVALID_SOCKET_VALUE }; -
trunk/Source/WebKit/ChangeLog
r267366 r267370 1 2020-09-21 Basuke Suzuki <basuke.suzuki@sony.com> 2 3 [WinCairo][PlayStation] Support different instances of listener client. 4 https://bugs.webkit.org/show_bug.cgi?id=216733 5 6 Reviewed by Don Olmstead. 7 8 Follows the change of RemoteInspectorSocketEndpoint::Client interface change. 9 10 No new tests because there's no behaivior change. 11 12 * UIProcess/Inspector/socket/RemoteInspectorClient.cpp: 13 (WebKit::RemoteInspectorClient::didClose): 14 * UIProcess/Inspector/socket/RemoteInspectorClient.h: 15 1 16 2020-09-21 Youenn Fablet <youenn@apple.com> 2 17 -
trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp
r266885 r267370 146 146 } 147 147 148 void RemoteInspectorClient::didClose( ConnectionID)148 void RemoteInspectorClient::didClose(Inspector::RemoteInspectorSocketEndpoint&, ConnectionID) 149 149 { 150 150 callOnMainThread([this] { -
trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.h
r255214 r267370 83 83 void setBackendCommands(const Event&); 84 84 85 void didClose( ConnectionID) final;85 void didClose(Inspector::RemoteInspectorSocketEndpoint&, ConnectionID) final; 86 86 HashMap<String, CallHandler>& dispatchMap() final; 87 87
Note:
See TracChangeset
for help on using the changeset viewer.