Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit de67463

Browse files
[PlayStation] Upstream playstation's remote inspector server
https://bugs.webkit.org/show_bug.cgi?id=193806 Reviewed by Joseph Pecoraro. Upstreaming PlayStation's Remote Inspector implementation. It is using a JSON RPC protocol over TCP sockets. This inspector implementation is planned to also support running on a WinCairo Client and Server. * PlatformPlayStation.cmake: * SourcesGTK.txt: * SourcesWPE.txt: * inspector/remote/RemoteConnectionToTarget.cpp: Renamed from Source/JavaScriptCore/inspector/remote/glib/RemoteConnectionToTargetGlib.cpp. * inspector/remote/RemoteInspector.h: * inspector/remote/playstation/RemoteInspectorConnectionClient.h: Added. * inspector/remote/playstation/RemoteInspectorConnectionClientPlayStation.cpp: Added. * inspector/remote/playstation/RemoteInspectorMessageParser.h: Added. * inspector/remote/playstation/RemoteInspectorMessageParserPlayStation.cpp: Added. * inspector/remote/playstation/RemoteInspectorPlayStation.cpp: Added. * inspector/remote/playstation/RemoteInspectorServer.h: Added. * inspector/remote/playstation/RemoteInspectorServerPlayStation.cpp: Added. * inspector/remote/playstation/RemoteInspectorSocket.h: Added. * inspector/remote/playstation/RemoteInspectorSocketClient.h: Added. * inspector/remote/playstation/RemoteInspectorSocketClientPlayStation.cpp: Added. * inspector/remote/playstation/RemoteInspectorSocketPlayStation.cpp: Added. * inspector/remote/playstation/RemoteInspectorSocketServer.h: Added. * inspector/remote/playstation/RemoteInspectorSocketServerPlayStation.cpp: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@242306 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent af44982 commit de67463

20 files changed

+1667
-5
lines changed

Source/JavaScriptCore/ChangeLog

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
2019-03-01 Christopher Reid <[email protected]>
2+
3+
[PlayStation] Upstream playstation's remote inspector server
4+
https://bugs.webkit.org/show_bug.cgi?id=193806
5+
6+
Reviewed by Joseph Pecoraro.
7+
8+
Upstreaming PlayStation's Remote Inspector implementation.
9+
It is using a JSON RPC protocol over TCP sockets.
10+
This inspector implementation is planned to also support running on a WinCairo Client and Server.
11+
12+
* PlatformPlayStation.cmake:
13+
* SourcesGTK.txt:
14+
* SourcesWPE.txt:
15+
* inspector/remote/RemoteConnectionToTarget.cpp: Renamed from Source/JavaScriptCore/inspector/remote/glib/RemoteConnectionToTargetGlib.cpp.
16+
* inspector/remote/RemoteInspector.h:
17+
* inspector/remote/playstation/RemoteInspectorConnectionClient.h: Added.
18+
* inspector/remote/playstation/RemoteInspectorConnectionClientPlayStation.cpp: Added.
19+
* inspector/remote/playstation/RemoteInspectorMessageParser.h: Added.
20+
* inspector/remote/playstation/RemoteInspectorMessageParserPlayStation.cpp: Added.
21+
* inspector/remote/playstation/RemoteInspectorPlayStation.cpp: Added.
22+
* inspector/remote/playstation/RemoteInspectorServer.h: Added.
23+
* inspector/remote/playstation/RemoteInspectorServerPlayStation.cpp: Added.
24+
* inspector/remote/playstation/RemoteInspectorSocket.h: Added.
25+
* inspector/remote/playstation/RemoteInspectorSocketClient.h: Added.
26+
* inspector/remote/playstation/RemoteInspectorSocketClientPlayStation.cpp: Added.
27+
* inspector/remote/playstation/RemoteInspectorSocketPlayStation.cpp: Added.
28+
* inspector/remote/playstation/RemoteInspectorSocketServer.h: Added.
29+
* inspector/remote/playstation/RemoteInspectorSocketServerPlayStation.cpp: Added.
30+
131
2019-03-01 Saam Barati <[email protected]>
232

333
Create SPI to crash if a JSC VM is created

Source/JavaScriptCore/PlatformPlayStation.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
list(APPEND JavaScriptCore_PRIVATE_INCLUDE_DIRECTORIES
2+
"${JAVASCRIPTCORE_DIR}/inspector/remote/playstation"
3+
)
4+
5+
list(APPEND JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
6+
inspector/remote/RemoteAutomationTarget.h
7+
inspector/remote/RemoteConnectionToTarget.h
8+
inspector/remote/RemoteControllableTarget.h
9+
inspector/remote/RemoteInspectionTarget.h
10+
inspector/remote/RemoteInspector.h
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
18+
)
19+
20+
list(APPEND JavaScriptCore_SOURCES
21+
API/JSRemoteInspector.cpp
22+
23+
inspector/remote/RemoteAutomationTarget.cpp
24+
inspector/remote/RemoteConnectionToTarget.cpp
25+
inspector/remote/RemoteControllableTarget.cpp
26+
inspector/remote/RemoteInspectionTarget.cpp
27+
inspector/remote/RemoteInspector.cpp
28+
29+
inspector/remote/playstation/RemoteInspectorConnectionClientPlayStation.cpp
30+
inspector/remote/playstation/RemoteInspectorMessageParserPlayStation.cpp
31+
inspector/remote/playstation/RemoteInspectorPlayStation.cpp
32+
inspector/remote/playstation/RemoteInspectorServerPlayStation.cpp
33+
inspector/remote/playstation/RemoteInspectorSocketClientPlayStation.cpp
34+
inspector/remote/playstation/RemoteInspectorSocketPlayStation.cpp
35+
inspector/remote/playstation/RemoteInspectorSocketServerPlayStation.cpp
36+
)
37+
138
if (${WTF_LIBRARY_TYPE} STREQUAL "STATIC")
239
add_definitions(-DSTATICALLY_LINKED_WITH_WTF)
340
endif ()

Source/JavaScriptCore/SourcesGTK.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
API/JSRemoteInspector.cpp
2525

2626
inspector/remote/RemoteAutomationTarget.cpp
27+
inspector/remote/RemoteConnectionToTarget.cpp
2728
inspector/remote/RemoteControllableTarget.cpp
2829
inspector/remote/RemoteInspectionTarget.cpp
2930
inspector/remote/RemoteInspector.cpp
3031

31-
inspector/remote/glib/RemoteConnectionToTargetGlib.cpp
3232
inspector/remote/glib/RemoteInspectorGlib.cpp
3333
inspector/remote/glib/RemoteInspectorServer.cpp
3434
inspector/remote/glib/RemoteInspectorUtils.cpp

Source/JavaScriptCore/SourcesWPE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
API/JSRemoteInspector.cpp
2525

2626
inspector/remote/RemoteAutomationTarget.cpp
27+
inspector/remote/RemoteConnectionToTarget.cpp
2728
inspector/remote/RemoteControllableTarget.cpp
2829
inspector/remote/RemoteInspectionTarget.cpp
2930
inspector/remote/RemoteInspector.cpp
3031

31-
inspector/remote/glib/RemoteConnectionToTargetGlib.cpp
3232
inspector/remote/glib/RemoteInspectorGlib.cpp
3333
inspector/remote/glib/RemoteInspectorServer.cpp
3434
inspector/remote/glib/RemoteInspectorUtils.cpp

Source/JavaScriptCore/inspector/remote/RemoteInspector.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ typedef struct _GDBusConnection GDBusConnection;
5151
typedef struct _GDBusInterfaceVTable GDBusInterfaceVTable;
5252
#endif
5353

54+
#if PLATFORM(PLAYSTATION)
55+
#include "RemoteConnectionToTarget.h"
56+
#include "RemoteInspectorConnectionClient.h"
57+
#include "RemoteInspectorSocketClient.h"
58+
#include <wtf/JSONValues.h>
59+
#include <wtf/RefCounted.h>
60+
#include <wtf/RefPtr.h>
61+
62+
namespace Inspector {
63+
using TargetListing = RefPtr<JSON::Object>;
64+
}
65+
#endif
66+
5467
namespace Inspector {
5568

5669
class RemoteAutomationTarget;
@@ -62,6 +75,8 @@ class RemoteInspectorClient;
6275
class JS_EXPORT_PRIVATE RemoteInspector final
6376
#if PLATFORM(COCOA)
6477
: public RemoteInspectorXPCConnection::Client
78+
#elif PLATFORM(PLAYSTATION)
79+
: public RemoteInspectorConnectionClient
6580
#endif
6681
{
6782
public:
@@ -128,9 +143,14 @@ class JS_EXPORT_PRIVATE RemoteInspector final
128143

129144
#if USE(GLIB)
130145
void requestAutomationSession(const char* sessionID, const Client::SessionCapabilities&);
146+
#endif
147+
#if USE(GLIB) || PLATFORM(PLAYSTATION)
131148
void setup(unsigned targetIdentifier);
132149
void sendMessageToTarget(unsigned targetIdentifier, const char* message);
133150
#endif
151+
#if PLATFORM(PLAYSTATION)
152+
static void setConnectionIdentifier(PlatformSocketType);
153+
#endif
134154

135155
private:
136156
RemoteInspector();
@@ -184,7 +204,17 @@ class JS_EXPORT_PRIVATE RemoteInspector final
184204
void receivedAutomaticInspectionRejectMessage(NSDictionary *userInfo);
185205
void receivedAutomationSessionRequestMessage(NSDictionary *userInfo);
186206
#endif
207+
#if PLATFORM(PLAYSTATION)
208+
HashMap<String, CallHandler>& dispatchMap() override;
209+
void didClose(ClientID) override;
210+
211+
void sendWebInspectorEvent(const String&);
187212

213+
void receivedGetTargetListMessage(const struct Event&);
214+
void receivedSetupMessage(const struct Event&);
215+
void receivedDataMessage(const struct Event&);
216+
void receivedCloseMessage(const struct Event&);
217+
#endif
188218
static bool startEnabled;
189219

190220
// Targets can be registered from any thread at any time.
@@ -205,6 +235,12 @@ class JS_EXPORT_PRIVATE RemoteInspector final
205235
GRefPtr<GCancellable> m_cancellable;
206236
#endif
207237

238+
#if PLATFORM(PLAYSTATION)
239+
std::unique_ptr<RemoteInspectorSocketClient> m_socketConnection;
240+
static PlatformSocketType s_connectionIdentifier;
241+
Optional<ClientID> m_clientID;
242+
#endif
243+
208244
RemoteInspector::Client* m_client { nullptr };
209245
Optional<RemoteInspector::Client::Capabilities> m_clientCapabilities;
210246

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (C) 2019 Sony Interactive Entertainment Inc.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#if ENABLE(REMOTE_INSPECTOR)
29+
30+
#include "RemoteInspectorSocket.h"
31+
#include <wtf/WeakPtr.h>
32+
#include <wtf/text/WTFString.h>
33+
34+
namespace Inspector {
35+
36+
class RemoteInspectorConnectionClient : public CanMakeWeakPtr<RemoteInspectorConnectionClient> {
37+
public:
38+
void didReceiveWebInspectorEvent(ClientID, Vector<uint8_t>&&);
39+
virtual void didAccept(ClientID, RemoteInspectorSocket::DomainType) { };
40+
virtual void didClose(ClientID) = 0;
41+
42+
struct Event {
43+
ClientID clientID;
44+
Optional<uint64_t> connectionID;
45+
Optional<uint64_t> targetID;
46+
Optional<String> message;
47+
};
48+
49+
using CallHandler = void (RemoteInspectorConnectionClient::*)(const struct Event&);
50+
virtual HashMap<String, CallHandler>& dispatchMap() = 0;
51+
};
52+
53+
} // namespace Inspector
54+
55+
#endif // ENABLE(REMOTE_INSPECTOR)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (C) 2019 Sony Interactive Entertainment Inc.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "RemoteInspectorConnectionClient.h"
28+
29+
#if ENABLE(REMOTE_INSPECTOR)
30+
31+
#include "RemoteInspectorSocket.h"
32+
#include <wtf/JSONValues.h>
33+
#include <wtf/RunLoop.h>
34+
35+
namespace Inspector {
36+
37+
void RemoteInspectorConnectionClient::didReceiveWebInspectorEvent(ClientID clientID, Vector<uint8_t>&& data)
38+
{
39+
ASSERT(!isMainThread());
40+
41+
if (data.isEmpty())
42+
return;
43+
44+
String jsonData = String::fromUTF8(data);
45+
46+
RefPtr<JSON::Value> messageValue;
47+
if (!JSON::Value::parseJSON(jsonData, messageValue))
48+
return;
49+
50+
RefPtr<JSON::Object> messageObject;
51+
if (!messageValue->asObject(messageObject))
52+
return;
53+
54+
String methodName;
55+
if (!messageObject->getString("event"_s, methodName))
56+
return;
57+
58+
struct Event event;
59+
event.clientID = clientID;
60+
61+
uint64_t connectionID;
62+
if (messageObject->getInteger("connectionID"_s, connectionID))
63+
event.connectionID = connectionID;
64+
65+
uint64_t targetID;
66+
if (messageObject->getInteger("targetID"_s, targetID))
67+
event.targetID = targetID;
68+
69+
String message;
70+
if (messageObject->getString("message"_s, message))
71+
event.message = message;
72+
73+
RunLoop::main().dispatch([this, methodName, event = WTFMove(event)] {
74+
auto& methods = dispatchMap();
75+
if (methods.contains(methodName)) {
76+
auto call = methods.get(methodName);
77+
(this->*call)(event);
78+
} else
79+
LOG_ERROR("Unknown event: %s", methodName.utf8().data());
80+
});
81+
}
82+
83+
} // namespace Inspector
84+
85+
#endif // ENABLE(REMOTE_INSPECTOR)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (C) 2019 Sony Interactive Entertainment Inc.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#if ENABLE(REMOTE_INSPECTOR)
29+
30+
#include "RemoteInspectorSocket.h"
31+
#include <wtf/Vector.h>
32+
33+
namespace Inspector {
34+
35+
class MessageParser {
36+
public:
37+
static Vector<uint8_t> createMessage(const uint8_t*, size_t);
38+
39+
MessageParser(ClientID, size_t);
40+
void pushReceivedData(const uint8_t*, size_t);
41+
void setDidParseMessageListener(Function<void(ClientID, Vector<uint8_t>)>&& listener) { m_didParseMessageListener = WTFMove(listener); }
42+
43+
void clearReceivedData();
44+
45+
private:
46+
bool parse();
47+
48+
Function<void(ClientID, Vector<uint8_t>&&)> m_didParseMessageListener;
49+
Vector<uint8_t> m_buffer;
50+
ClientID m_clientID;
51+
};
52+
53+
} // namespace Inspector
54+
55+
#endif // ENABLE(REMOTE_INSPECTOR)

0 commit comments

Comments
 (0)