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

Side by Side Diff: mojo/apps/js/v8_environment.cc

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix skipped comment Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW
« gin/arguments.cc ('K') | « mojo/apps/js/v8_environment.h ('k') | mojo/mojo.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698