| Index: mojo/public/bindings/js/v8_environment.cc
|
| diff --git a/mojo/apps/js/v8_environment.cc b/mojo/public/bindings/js/v8_environment.cc
|
| similarity index 57%
|
| rename from mojo/apps/js/v8_environment.cc
|
| rename to mojo/public/bindings/js/v8_environment.cc
|
| index 1b4ee834a247e7dc7a9611873a57aad553503f3e..b74258b96cf6ea514137010d2d54d7e2e39ed91c 100644
|
| --- a/mojo/apps/js/v8_environment.cc
|
| +++ b/mojo/public/bindings/js/v8_environment.cc
|
| @@ -2,31 +2,21 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "mojo/apps/js/v8_environment.h"
|
| +#include "mojo/public/bindings/js/v8_environment.h"
|
|
|
| #include <stdlib.h>
|
| #include <string.h>
|
|
|
| +#include "mojo/public/bindings/js/v8_array_buffer.h"
|
| +#include "mojo/public/bindings/js/v8_per_isolate_data.h"
|
| #include "mojo/public/system/macros.h"
|
| #include "v8/include/v8.h"
|
|
|
| namespace mojo {
|
| -namespace apps {
|
| +namespace js {
|
|
|
| namespace {
|
|
|
| -class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
| - virtual void* Allocate(size_t length) MOJO_OVERRIDE {
|
| - return calloc(1, length);
|
| - }
|
| - virtual void* AllocateUninitialized(size_t length) MOJO_OVERRIDE {
|
| - return malloc(length);
|
| - }
|
| - virtual void Free(void* data, size_t length) MOJO_OVERRIDE {
|
| - free(data);
|
| - }
|
| -};
|
| -
|
| bool GenerateEntropy(unsigned char* buffer, size_t amount) {
|
| // TODO(abarth): Mojo needs a source of entropy.
|
| // https://code.google.com/p/chromium/issues/detail?id=316387
|
| @@ -37,13 +27,17 @@ const char kFlags[] = "--use_strict --harmony";
|
|
|
| }
|
|
|
| -void InitializeV8() {
|
| - v8::V8::SetArrayBufferAllocator(new ArrayBufferAllocator());
|
| +void Initialize() {
|
| + v8::V8::SetArrayBufferAllocator(js::ArrayBufferAllocator::SharedInstance());
|
| v8::V8::InitializeICU();
|
| v8::V8::SetFlagsFromString(kFlags, strlen(kFlags));
|
| v8::V8::SetEntropySource(&GenerateEntropy);
|
| v8::V8::Initialize();
|
| +
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
| + new V8PerIsolateData(isolate);
|
| }
|
|
|
| -} // namespace apps
|
| -} // mojo
|
| +} // namespace js
|
| +} // namespace mojo
|
|
|