aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2016-04-10 00:11:35 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-04-10 00:11:35 +0000
commitbc302deb3eb226c4759c527f16df63581cf2d652 (patch)
treedab604f33b88f8f781ca2230b38dc96cea7180b5
parent94b900307eef6c62378c68e1b2b4c7578283bc59 (diff)
parent2ff2dd13fb349015dc326d7e54df145e48b4aed6 (diff)
downloadchromium-libpac-nougat-mr1.2-release.tar.gz
Merge "Fixup libpac for V8 4.9.385.28" am: 83f3d60 am: 35a6630android-wear-n-preview-3android-wear-n-preview-1android-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r6android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1nougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-cts-releasenougat-dr1-release
am: 2ff2dd1 * commit '2ff2dd13fb349015dc326d7e54df145e48b4aed6': Fixup libpac for V8 4.9.385.28 Change-Id: I387a1390b9e39783f8edf58936b01ebd3a511956
-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