| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/apps/js/v8_environment.h" | |
| 6 | |
| 7 #include <stdlib.h> | |
| 8 #include <string.h> | |
| 9 | |
| 10 #include "mojo/public/system/macros.h" | |
| 11 #include "v8/include/v8.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 namespace apps { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | |
| 19 virtual void* Allocate(size_t length) MOJO_OVERRIDE { | |
| 20 return calloc(1, length); | |
| 21 } | |
| 22 virtual void* AllocateUninitialized(size_t length) MOJO_OVERRIDE { | |
| 23 return malloc(length); | |
| 24 } | |
| 25 virtual void Free(void* data, size_t length) MOJO_OVERRIDE { | |
| 26 free(data); | |
| 27 } | |
| 28 }; | |
| 29 | |
| 30 bool GenerateEntropy(unsigned char* buffer, size_t amount) { | |
| 31 // TODO(abarth): Mojo needs a source of entropy. | |
| 32 // https://code.google.com/p/chromium/issues/detail?id=316387 | |
| 33 return false; | |
| 34 } | |
| 35 | |
| 36 const char kFlags[] = "--use_strict --harmony"; | |
| 37 | |
| 38 } | |
| 39 | |
| 40 void InitializeV8() { | |
| 41 v8::V8::SetArrayBufferAllocator(new ArrayBufferAllocator()); | |
| 42 v8::V8::InitializeICU(); | |
| 43 v8::V8::SetFlagsFromString(kFlags, strlen(kFlags)); | |
| 44 v8::V8::SetEntropySource(&GenerateEntropy); | |
| 45 v8::V8::Initialize(); | |
| 46 } | |
| 47 | |
| 48 } // namespace apps | |
| 49 } // mojo | |
| OLD | NEW |