110 строки
4.1 KiB
Diff
110 строки
4.1 KiB
Diff
diff --git a/third_party/WebKit/Source/core/dom/DOMArrayBuffer.h b/third_party/WebKit/Source/core/dom/DOMArrayBuffer.h
|
|
index 6bfee91..55225a9 100644
|
|
--- a/third_party/WebKit/Source/core/dom/DOMArrayBuffer.h
|
|
+++ b/third_party/WebKit/Source/core/dom/DOMArrayBuffer.h
|
|
@@ -28,6 +28,10 @@ class CORE_EXPORT DOMArrayBuffer final : public DOMArrayBufferBase {
|
|
static DOMArrayBuffer* create(WTF::ArrayBufferContents& contents) {
|
|
return create(WTF::ArrayBuffer::create(contents));
|
|
}
|
|
+ static DOMArrayBuffer* createExternal(void* source, unsigned byteLength)
|
|
+ {
|
|
+ return new DOMArrayBuffer(source, byteLength);
|
|
+ }
|
|
|
|
// Only for use by XMLHttpRequest::responseArrayBuffer and
|
|
// Internals::serializeObject.
|
|
@@ -50,6 +54,8 @@ class CORE_EXPORT DOMArrayBuffer final : public DOMArrayBufferBase {
|
|
private:
|
|
explicit DOMArrayBuffer(PassRefPtr<WTF::ArrayBuffer> buffer)
|
|
: DOMArrayBufferBase(std::move(buffer)) {}
|
|
+ DOMArrayBuffer(void* source, unsigned byteLength)
|
|
+ : DOMArrayBufferBase(source, byteLength) {}
|
|
};
|
|
|
|
} // namespace blink
|
|
diff --git a/third_party/WebKit/Source/core/dom/DOMArrayBufferBase.h b/third_party/WebKit/Source/core/dom/DOMArrayBufferBase.h
|
|
index 74738da..06395c6 100644
|
|
--- a/third_party/WebKit/Source/core/dom/DOMArrayBufferBase.h
|
|
+++ b/third_party/WebKit/Source/core/dom/DOMArrayBufferBase.h
|
|
@@ -21,9 +21,24 @@ class CORE_EXPORT DOMArrayBufferBase
|
|
const WTF::ArrayBuffer* buffer() const { return m_buffer.get(); }
|
|
WTF::ArrayBuffer* buffer() { return m_buffer.get(); }
|
|
|
|
- const void* data() const { return buffer()->data(); }
|
|
- void* data() { return buffer()->data(); }
|
|
- unsigned byteLength() const { return buffer()->byteLength(); }
|
|
+ const void* data() const {
|
|
+ if (m_isExternal)
|
|
+ return m_source;
|
|
+ else
|
|
+ return buffer()->data();
|
|
+ }
|
|
+ void* data() {
|
|
+ if (m_isExternal)
|
|
+ return m_source;
|
|
+ else
|
|
+ return buffer()->data();
|
|
+ }
|
|
+ unsigned byteLength() const {
|
|
+ if (m_isExternal)
|
|
+ return m_byteLength;
|
|
+ else
|
|
+ return buffer()->byteLength();
|
|
+ }
|
|
bool transfer(WTF::ArrayBufferContents& result) {
|
|
return buffer()->transfer(result);
|
|
}
|
|
@@ -43,11 +58,22 @@ class CORE_EXPORT DOMArrayBufferBase
|
|
|
|
protected:
|
|
explicit DOMArrayBufferBase(PassRefPtr<WTF::ArrayBuffer> buffer)
|
|
- : m_buffer(buffer) {
|
|
+ : m_buffer(buffer),
|
|
+ m_isExternal(false),
|
|
+ m_source(nullptr),
|
|
+ m_byteLength(0) {
|
|
DCHECK(m_buffer);
|
|
}
|
|
+ DOMArrayBufferBase(void* source, unsigned byteLength)
|
|
+ : m_buffer(WTF::ArrayBuffer::create(source, byteLength)),
|
|
+ m_isExternal(true),
|
|
+ m_source(source),
|
|
+ m_byteLength(byteLength) {}
|
|
|
|
RefPtr<WTF::ArrayBuffer> m_buffer;
|
|
+ bool m_isExternal;
|
|
+ void* m_source;
|
|
+ unsigned m_byteLength;
|
|
};
|
|
|
|
} // namespace blink
|
|
diff --git a/third_party/WebKit/Source/web/WebArrayBuffer.cpp b/third_party/WebKit/Source/web/WebArrayBuffer.cpp
|
|
index 271ec53..0862919 100644
|
|
--- a/third_party/WebKit/Source/web/WebArrayBuffer.cpp
|
|
+++ b/third_party/WebKit/Source/web/WebArrayBuffer.cpp
|
|
@@ -39,6 +39,11 @@ WebArrayBuffer WebArrayBuffer::create(unsigned numElements,
|
|
return WebArrayBuffer(DOMArrayBuffer::create(numElements, elementByteSize));
|
|
}
|
|
|
|
+WebArrayBuffer WebArrayBuffer::createExternal(void* source,
|
|
+ unsigned byteLength) {
|
|
+ return WebArrayBuffer(DOMArrayBuffer::createExternal(source, byteLength));
|
|
+}
|
|
+
|
|
void WebArrayBuffer::reset() {
|
|
m_private.reset();
|
|
}
|
|
diff --git a/third_party/WebKit/public/web/WebArrayBuffer.h b/third_party/WebKit/public/web/WebArrayBuffer.h
|
|
index 6acdddf..7a1097d 100644
|
|
--- a/third_party/WebKit/public/web/WebArrayBuffer.h
|
|
+++ b/third_party/WebKit/public/web/WebArrayBuffer.h
|
|
@@ -51,6 +51,8 @@ class WebArrayBuffer {
|
|
|
|
BLINK_EXPORT static WebArrayBuffer create(unsigned numElements,
|
|
unsigned elementByteSize);
|
|
+ BLINK_EXPORT static WebArrayBuffer createExternal(void* source,
|
|
+ unsigned byteLength);
|
|
|
|
BLINK_EXPORT void reset();
|
|
BLINK_EXPORT void assign(const WebArrayBuffer&);
|