Use blink's allocator in Node's Buffer

This commit is contained in:
Cheng Zhao 2015-08-11 12:31:41 +08:00
parent 2dc533c4b9
commit 0f990d40cc
3 changed files with 17 additions and 2 deletions

View file

@ -24,6 +24,7 @@
#include "third_party/WebKit/public/web/WebPluginParams.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/Source/wtf/ArrayBufferContents.h"
#include "atom/common/node_includes.h"
@ -52,6 +53,17 @@ bool IsGuestFrame(blink::WebFrame* frame) {
return frame->uniqueName().utf8() == "ATOM_SHELL_GUEST_WEB_VIEW";
}
void* BlinkAllocate(size_t size) {
void* ptr = nullptr;
WTF::ArrayBufferContents::allocateMemory(
size, WTF::ArrayBufferContents::DontInitialize, ptr);
return ptr;
}
void BlinkFree(void* ptr, size_t size) {
WTF::ArrayBufferContents::freeMemory(ptr, size);
}
// Helper class to forward the messages to the client.
class AtomRenderFrameObserver : public content::RenderFrameObserver {
public:
@ -91,6 +103,9 @@ void AtomRendererClient::WebKitInitialized() {
blink::WebCustomElement::addEmbedderCustomElementName("webview");
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
// Override Node's Buffer allocator with WTF's allocator.
node::Buffer::SetAllocator(&BlinkAllocate, &BlinkFree);
node_bindings_->Initialize();
node_bindings_->PrepareMessageLoop();

View file

@ -8,7 +8,7 @@ import sys
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
'http://github-janky-artifacts.s3.amazonaws.com/libchromiumcontent'
LIBCHROMIUMCONTENT_COMMIT = '01345b4ef5f2a766e6f58dbbe7729fb089b357ba'
LIBCHROMIUMCONTENT_COMMIT = '21768a17f4f1203a50df5c0908b788fa2ecb96ab'
PLATFORM = {
'cygwin': 'win32',

2
vendor/node vendored

@ -1 +1 @@
Subproject commit 02d6e45de63d4bbb133cc73ab3937e5115fb4ddd
Subproject commit 6472143e364343f73ee6a9e1b67902cc5c30f7ef