Changeset 286788 in webkit for trunk/Source/WebKit/Shared/PushMessageForTesting.h
- Timestamp:
- Dec 9, 2021, 10:58:34 AM (3 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/Shared/PushMessageForTesting.h
r286787 r286788 26 26 #pragma once 27 27 28 29 30 28 31 namespace WebKit::WebPushD { 29 32 30 constexpr const char* protocolVersionKey = "protocol version"; 31 constexpr uint64_t protocolVersionValue = 1;32 constexpr const char* protocolEncodedMessageKey = "encoded message";33 struct PushMessageForTesting { 34 ; 35 ; 33 36 34 constexpr const char* protocolDebugMessageKey { "debug message" }; 35 constexpr const char* protocolDebugMessageLevelKey { "debug message level" }; 36 37 constexpr const char* protocolMessageTypeKey { "message type" }; 38 enum class MessageType : uint8_t { 39 EchoTwice = 1, 40 RequestSystemNotificationPermission, 41 DeletePushAndNotificationRegistration, 42 GetOriginsWithPushAndNotificationPermissions, 43 SetDebugModeIsEnabled, 44 UpdateConnectionConfiguration, 37 String targetAppCodeSigningIdentifier; 38 URL registrationURL; 39 String message; 45 40 }; 46 41 47 inline bool messageTypeSendsReply(MessageType messageType) 42 template<class Encoder> 43 void PushMessageForTesting::encode(Encoder& encoder) const 48 44 { 49 switch (messageType) { 50 case MessageType::EchoTwice: 51 case MessageType::GetOriginsWithPushAndNotificationPermissions: 52 case MessageType::DeletePushAndNotificationRegistration: 53 case MessageType::RequestSystemNotificationPermission: 54 return true; 55 case MessageType::SetDebugModeIsEnabled: 56 case MessageType::UpdateConnectionConfiguration: 57 return false; 58 } 59 ASSERT_NOT_REACHED(); 60 return false; 45 encoder << targetAppCodeSigningIdentifier << registrationURL << message; 46 } 47 48 template<class Decoder> 49 std::optional<PushMessageForTesting> PushMessageForTesting::decode(Decoder& decoder) 50 { 51 std::optional<String> targetAppCodeSigningIdentifier; 52 decoder >> targetAppCodeSigningIdentifier; 53 if (!targetAppCodeSigningIdentifier) 54 return std::nullopt; 55 56 std::optional<URL> registrationURL; 57 decoder >> registrationURL; 58 if (!registrationURL) 59 return std::nullopt; 60 61 std::optional<String> message; 62 decoder >> message; 63 if (!message) 64 return std::nullopt; 65 66 return { { 67 WTFMove(*targetAppCodeSigningIdentifier), 68 WTFMove(*registrationURL), 69 WTFMove(*message), 70 } }; 61 71 } 62 72
Note:
See TracChangeset
for help on using the changeset viewer.