OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gin/initialize.h" | 5 #include "gin/initialize.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "gin/array_buffer.h" | 10 #include "gin/array_buffer.h" |
11 #include "gin/per_isolate_data.h" | 11 #include "gin/per_isolate_data.h" |
12 | 12 |
13 namespace gin { | 13 namespace gin { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 bool GenerateEntropy(unsigned char* buffer, size_t amount) { | 17 bool GenerateEntropy(unsigned char* buffer, size_t amount) { |
18 // TODO(abarth): Gin needs a source of entropy. | 18 // TODO(abarth): Gin needs a source of entropy. |
19 return false; | 19 return false; |
20 } | 20 } |
21 | 21 |
22 const char kFlags[] = "--use_strict --harmony"; | 22 const char kFlags[] = "--use_strict --harmony"; |
23 | 23 |
24 } | 24 } |
25 | 25 |
26 void Initialize() { | 26 void Initialize() { |
27 v8::V8::SetArrayBufferAllocator(ArrayBufferAllocator::SharedInstance()); | 27 v8::V8::SetArrayBufferAllocator(ArrayBufferAllocator::SharedInstance()); |
28 v8::V8::InitializeICU(); | 28 v8::V8::InitializeICU(); |
29 v8::V8::SetFlagsFromString(kFlags, | 29 v8::V8::SetFlagsFromString(kFlags, |
30 static_cast<uint32_t>(sizeof(kFlags) / sizeof(kFlags[0])) - 1); | 30 static_cast<uint32_t>(arraysize(kFlags)) - 1); |
31 v8::V8::SetEntropySource(&GenerateEntropy); | 31 v8::V8::SetEntropySource(&GenerateEntropy); |
32 v8::V8::Initialize(); | 32 v8::V8::Initialize(); |
33 | 33 |
34 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 34 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
35 v8::HandleScope handle_scope(isolate); | 35 v8::HandleScope handle_scope(isolate); |
36 new PerIsolateData(isolate); | 36 new PerIsolateData(isolate); |
37 } | 37 } |
38 | 38 |
39 } // namespace gin | 39 } // namespace gin |
OLD | NEW |