summaryrefslogtreecommitdiff
path: root/Source/WebKit2/Platform/IPC/DataReference.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Platform/IPC/DataReference.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebKit2/Platform/IPC/DataReference.h')
-rw-r--r--Source/WebKit2/Platform/IPC/DataReference.h35
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