aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Murdoch <benm@android.com>2016-04-09 23:56:54 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-04-09 23:56:54 +0000
commit83f3d60742f20133ef58f560706756f78a8c0585 (patch)
treedab604f33b88f8f781ca2230b38dc96cea7180b5
parent94b900307eef6c62378c68e1b2b4c7578283bc59 (diff)
parent1c9888ab57e000ecde4446df364a8b6a09ee4aa3 (diff)
downloadchromium-libpac-83f3d60742f20133ef58f560706756f78a8c0585.tar.gz
Merge "Fixup libpac for V8 4.9.385.28"
-rw-r--r--Android.mk2
-rw-r--r--src/proxy_resolver_v8.cc24
-rw-r--r--src/proxy_resolver_v8.h1
3 files changed, 23 insertions, 4 deletions
diff --git a/Android.mk b/Android.mk
index d25755f..e8a2b26 100644
--- a/Android.mk
+++ b/Android.mk
@@ -23,7 +23,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/src $(LOCAL_PATH)/../v8
LOCAL_STATIC_LIBRARIES := libv8
-LOCAL_SHARED_LIBRARIES := libutils liblog
+LOCAL_SHARED_LIBRARIES := libutils liblog libicuuc libicui18n
LOCAL_CXX_STL := libc++
diff --git a/src/proxy_resolver_v8.cc b/src/proxy_resolver_v8.cc
index 533ef88..f978694 100644
--- a/src/proxy_resolver_v8.cc
+++ b/src/proxy_resolver_v8.cc
@@ -160,7 +160,7 @@ android::String16 V8StringToUTF16(v8::Handle<v8::String> s) {
char16_t* buf = new char16_t[len + 1];
s->Write(reinterpret_cast<uint16_t*>(buf), 0, len);
android::String16 ret(buf, len);
- delete buf;
+ delete[] buf;
return ret;
}
@@ -343,6 +343,17 @@ bool IsInNetEx(const std::string& ip_address, const std::string& ip_prefix) {
} // namespace
+class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t length) {
+ void* data = AllocateUninitialized(length);
+ return data == NULL ? data : memset(data, 0, length);
+ }
+ virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
+ virtual void Free(void* data, size_t) { free(data); }
+};
+
+
// ProxyResolverV8::Context ---------------------------------------------------
class ProxyResolverV8::Context {
@@ -701,15 +712,18 @@ class ProxyResolverV8::Context {
// ProxyResolverV8 ------------------------------------------------------------
+bool ProxyResolverV8::initialized_for_this_process_ = false;
+
ProxyResolverV8::ProxyResolverV8(
ProxyResolverJSBindings* custom_js_bindings,
ProxyErrorListener* error_listener)
: context_(NULL), js_bindings_(custom_js_bindings),
error_listener_(error_listener) {
- if (v8::V8::GetCurrentPlatform() == NULL) {
+ if (!initialized_for_this_process_) {
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
+ initialized_for_this_process_ = true;
}
}
@@ -749,7 +763,11 @@ int ProxyResolverV8::SetPacScript(const android::String16& script_data) {
return ERR_PAC_SCRIPT_FAILED;
// Try parsing the PAC script.
- context_ = new Context(js_bindings_, error_listener_, v8::Isolate::New());
+ ArrayBufferAllocator allocator;
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = &allocator;
+
+ context_ = new Context(js_bindings_, error_listener_, v8::Isolate::New(create_params));
int rv;
if ((rv = context_->InitV8(script_data)) != OK) {
context_ = NULL;
diff --git a/src/proxy_resolver_v8.h b/src/proxy_resolver_v8.h
index 13a1bd8..9b74e29 100644
--- a/src/proxy_resolver_v8.h
+++ b/src/proxy_resolver_v8.h
@@ -71,6 +71,7 @@ class ProxyResolverV8 {
ProxyResolverJSBindings* js_bindings_;
ProxyErrorListener* error_listener_;
+ static bool initialized_for_this_process_;
};
} // namespace net