diff options
Diffstat (limited to 'Source/WebKit2/Platform/IPC/DataReference.h')
-rw-r--r-- | Source/WebKit2/Platform/IPC/DataReference.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/WebKit2/Platform/IPC/DataReference.h b/Source/WebKit2/Platform/IPC/DataReference.h index 66c3761e4..fb57591db 100644 --- a/Source/WebKit2/Platform/IPC/DataReference.h +++ b/Source/WebKit2/Platform/IPC/DataReference.h @@ -26,12 +26,13 @@ #ifndef DataReference_h #define DataReference_h +#include <WebCore/SharedBuffer.h> #include <wtf/Vector.h> namespace IPC { -class ArgumentDecoder; -class ArgumentEncoder; +class Decoder; +class Encoder; class DataReference { public: @@ -72,14 +73,40 @@ public: return result; } - void encode(ArgumentEncoder&) const; - static bool decode(ArgumentDecoder&, DataReference&); + virtual void encode(Encoder&) const; + static bool decode(Decoder&, DataReference&); + + virtual ~DataReference() { } private: const uint8_t* m_data; size_t m_size; }; +class SharedBufferDataReference : public DataReference { +public: + // FIXME: This class doesn't handle null, so the argument should be a reference or PassRef. + SharedBufferDataReference(WebCore::SharedBuffer* buffer) + : m_buffer(buffer) + { + } + +private: + // FIXME: It is a bad idea to violate the Liskov Substitution Principle as we do here. + // Since we are using DataReference as a polymoprhic base class in this fashion, + // then we need it to be a base class that does not have functions such as isEmpty, + // size, data, and vector, all of which will do the wrong thing if they are called. + // Deleting these functions here does not prevent them from being called. + bool isEmpty() const = delete; + size_t size() const = delete; + const uint8_t* data() const = delete; + Vector<uint8_t> vector() const = delete; + + void encode(Encoder&) const override; + + RefPtr<WebCore::SharedBuffer> m_buffer; +}; + } // namespace IPC #endif // DataReference_h |