Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: test/unittests/test-utils.cc

Issue 1116633002: Pass ArrayBuffer::Allocator via Isolate::CreateParams (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/test-utils.h ('k') | tools/parser-shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/test-utils.cc
diff --git a/test/unittests/test-utils.cc b/test/unittests/test-utils.cc
index aa37b2f30d8c0c5af24b6215d15d2f609727c586..fd52a4b21dcf388aeae81df6c682e3e6c2bc93b5 100644
--- a/test/unittests/test-utils.cc
+++ b/test/unittests/test-utils.cc
@@ -11,6 +11,20 @@
namespace v8 {
+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); }
+};
+
+
+// static
+ArrayBufferAllocator* TestWithIsolate::array_buffer_allocator_ = NULL;
+
// static
Isolate* TestWithIsolate::isolate_ = NULL;
@@ -26,7 +40,10 @@ TestWithIsolate::~TestWithIsolate() {}
void TestWithIsolate::SetUpTestCase() {
Test::SetUpTestCase();
EXPECT_EQ(NULL, isolate_);
- isolate_ = v8::Isolate::New();
+ v8::Isolate::CreateParams create_params;
+ array_buffer_allocator_ = new ArrayBufferAllocator;
+ create_params.array_buffer_allocator = array_buffer_allocator_;
+ isolate_ = v8::Isolate::New(create_params);
EXPECT_TRUE(isolate_ != NULL);
}
@@ -36,6 +53,7 @@ void TestWithIsolate::TearDownTestCase() {
ASSERT_TRUE(isolate_ != NULL);
isolate_->Dispose();
isolate_ = NULL;
+ delete array_buffer_allocator_;
Test::TearDownTestCase();
}
« no previous file with comments | « test/unittests/test-utils.h ('k') | tools/parser-shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698