diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Platform/IPC/ArgumentCoders.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebKit2/Platform/IPC/ArgumentCoders.cpp')
-rw-r--r-- | Source/WebKit2/Platform/IPC/ArgumentCoders.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp b/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp index 5ca064108..0c986425a 100644 --- a/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp +++ b/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp @@ -32,12 +32,27 @@ namespace IPC { -void ArgumentCoder<AtomicString>::encode(ArgumentEncoder& encoder, const AtomicString& atomicString) +void ArgumentCoder<std::chrono::system_clock::time_point>::encode(IPC::Encoder& encoder, const std::chrono::system_clock::time_point& timePoint) +{ + encoder << static_cast<int64_t>(timePoint.time_since_epoch().count()); +} + +bool ArgumentCoder<std::chrono::system_clock::time_point>::decode(Decoder& decoder, std::chrono::system_clock::time_point& result) +{ + int64_t time; + if (!decoder.decode(time)) + return false; + + result = std::chrono::system_clock::time_point(std::chrono::system_clock::duration(static_cast<std::chrono::system_clock::rep>(time))); + return true; +} + +void ArgumentCoder<AtomicString>::encode(Encoder& encoder, const AtomicString& atomicString) { encoder << atomicString.string(); } -bool ArgumentCoder<AtomicString>::decode(ArgumentDecoder& decoder, AtomicString& atomicString) +bool ArgumentCoder<AtomicString>::decode(Decoder& decoder, AtomicString& atomicString) { String string; if (!decoder.decode(string)) @@ -47,7 +62,7 @@ bool ArgumentCoder<AtomicString>::decode(ArgumentDecoder& decoder, AtomicString& return true; } -void ArgumentCoder<CString>::encode(ArgumentEncoder& encoder, const CString& string) +void ArgumentCoder<CString>::encode(Encoder& encoder, const CString& string) { // Special case the null string. if (string.isNull()) { @@ -60,7 +75,7 @@ void ArgumentCoder<CString>::encode(ArgumentEncoder& encoder, const CString& str encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length, 1); } -bool ArgumentCoder<CString>::decode(ArgumentDecoder& decoder, CString& result) +bool ArgumentCoder<CString>::decode(Decoder& decoder, CString& result) { uint32_t length; if (!decoder.decode(length)) @@ -88,7 +103,7 @@ bool ArgumentCoder<CString>::decode(ArgumentDecoder& decoder, CString& result) } -void ArgumentCoder<String>::encode(ArgumentEncoder& encoder, const String& string) +void ArgumentCoder<String>::encode(Encoder& encoder, const String& string) { // Special case the null string. if (string.isNull()) { @@ -108,7 +123,7 @@ void ArgumentCoder<String>::encode(ArgumentEncoder& encoder, const String& strin } template <typename CharacterType> -static inline bool decodeStringText(ArgumentDecoder& decoder, uint32_t length, String& result) +static inline bool decodeStringText(Decoder& decoder, uint32_t length, String& result) { // Before allocating the string, make sure that the decoder buffer is big enough. if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length)) { @@ -125,7 +140,7 @@ static inline bool decodeStringText(ArgumentDecoder& decoder, uint32_t length, S return true; } -bool ArgumentCoder<String>::decode(ArgumentDecoder& decoder, String& result) +bool ArgumentCoder<String>::decode(Decoder& decoder, String& result) { uint32_t length; if (!decoder.decode(length)) @@ -147,4 +162,15 @@ bool ArgumentCoder<String>::decode(ArgumentDecoder& decoder, String& result) return decodeStringText<UChar>(decoder, length, result); } + +void ArgumentCoder<SHA1::Digest>::encode(Encoder& encoder, const SHA1::Digest& digest) +{ + encoder.encodeFixedLengthData(digest.data(), sizeof(digest), 1); +} + +bool ArgumentCoder<SHA1::Digest>::decode(Decoder& decoder, SHA1::Digest& digest) +{ + return decoder.decodeFixedLengthData(digest.data(), sizeof(digest), 1); +} + } // namespace IPC |