53template<typename T> struct ArgumentCoder<WTF::Optional<T>> {
54 static void encode(ArgumentEncoder& encoder, const WTF::Optional<T>& optional)
55 {
56 if (!optional) {
57 encoder << false;
58 return;
59 }
60
61 encoder << true;
62 encoder << optional.value();
63 }
64
65 static bool decode(ArgumentDecoder& decoder, WTF::Optional<T>& optional)
66 {
67 bool isEngaged;
68 if (!decoder.decode(isEngaged))
69 return false;
70
71 if (!isEngaged) {
72 optional = Nullopt;
73 return true;
74 }
75
76 T value;
77 if (!decoder.decode(value))
78 return false;
79
80 optional = std::move(value);
81 return true;
82 }
83};
84