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

Unified Diff: src/api.cc

Issue 75283002: Introduce a v8::Platform class that bundles embedder callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates 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 | « include/v8-platform.h ('k') | src/default-platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 7966e2c57c95d0a987db6c15f302e3417ae22895..214b7c2d6cf8a511931e95ba1124118abf49d872 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -40,6 +40,9 @@
#include "counters.h"
#include "cpu-profiler.h"
#include "debug.h"
+#ifdef V8_USE_DEFAULT_PLATFORM
+#include "default-platform.h"
+#endif
#include "deoptimizer.h"
#include "execution.h"
#include "global-handles.h"
@@ -5047,11 +5050,32 @@ static void* ExternalValue(i::Object* obj) {
// --- E n v i r o n m e n t ---
+void v8::V8::InitializePlatform(Platform* platform) {
+#ifdef V8_USE_DEFAULT_PLATFORM
+ FATAL("Can't override v8::Platform when using default implementation");
+#else
+ i::V8::InitializePlatform(platform);
+#endif
+}
+
+
+void v8::V8::ShutdownPlatform() {
+#ifdef V8_USE_DEFAULT_PLATFORM
+ FATAL("Can't override v8::Platform when using default implementation");
+#else
+ i::V8::ShutdownPlatform();
+#endif
+}
+
+
bool v8::V8::Initialize() {
i::Isolate* isolate = i::Isolate::UncheckedCurrent();
if (isolate != NULL && isolate->IsInitialized()) {
return true;
}
+#ifdef V8_USE_DEFAULT_PLATFORM
+ i::V8::InitializePlatform(new i::DefaultPlatform);
+#endif
return InitializeHelper(isolate);
}
@@ -5116,6 +5140,12 @@ bool v8::V8::Dispose() {
return false;
}
i::V8::TearDown();
+#ifdef V8_USE_DEFAULT_PLATFORM
+ i::DefaultPlatform* platform =
+ static_cast<i::DefaultPlatform*>(i::V8::GetCurrentPlatform());
+ i::V8::ShutdownPlatform();
+ delete platform;
+#endif
return true;
}
« no previous file with comments | « include/v8-platform.h ('k') | src/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698