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

Unified Diff: mojo/apps/js/v8_environment.cc

Issue 65943002: Add a basic Mojo app that initializes V8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base dependency 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/apps/js/v8_environment.h ('k') | mojo/mojo.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/apps/js/v8_environment.cc
diff --git a/mojo/apps/js/v8_environment.cc b/mojo/apps/js/v8_environment.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1b4ee834a247e7dc7a9611873a57aad553503f3e
--- /dev/null
+++ b/mojo/apps/js/v8_environment.cc
@@ -0,0 +1,49 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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 <stdlib.h>
+#include <string.h>
+
+#include "mojo/public/system/macros.h"
+#include "v8/include/v8.h"
+
+namespace mojo {
+namespace apps {
+
+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
+ return false;
+}
+
+const char kFlags[] = "--use_strict --harmony";
+
+}
+
+void InitializeV8() {
+ v8::V8::SetArrayBufferAllocator(new ArrayBufferAllocator());
+ v8::V8::InitializeICU();
+ v8::V8::SetFlagsFromString(kFlags, strlen(kFlags));
+ v8::V8::SetEntropySource(&GenerateEntropy);
+ v8::V8::Initialize();
+}
+
+} // namespace apps
+} // mojo
« no previous file with comments | « 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