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

Unified Diff: runtime/embedders/openglui/common/vm_glue.cc

Issue 14752023: Fix the embedder on the desktop. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/embedders/openglui/common/vm_glue.cc
===================================================================
--- runtime/embedders/openglui/common/vm_glue.cc (revision 22522)
+++ runtime/embedders/openglui/common/vm_glue.cc (working copy)
@@ -129,6 +129,37 @@
// "--trace_compiler",
};
+static void* openFileCallback(const char* name, bool write) {
+ return fopen(name, write ? "w" : "r");
+}
+
+static void readFileCallback(const uint8_t** data, intptr_t* fileLength,
+ void* stream) {
+ if (!stream) {
+ *data = 0;
+ *fileLength = 0;
+ } else {
+ FILE* file = reinterpret_cast<FILE*>(stream);
+
+ // Get the file size.
+ fseek(file, 0, SEEK_END);
+ *fileLength = ftell(file);
+ rewind(file);
+
+ // Allocate data buffer.
+ *data = new uint8_t[*fileLength];
+ *fileLength = fread(const_cast<uint8_t*>(*data), 1, *fileLength, file);
+ }
+}
+
+static void writeFileCallback(const void* data, intptr_t length, void* file) {
+ fwrite(data, 1, length, reinterpret_cast<FILE*>(file));
+}
+
+static void closeFileCallback(void* file) {
+ fclose(reinterpret_cast<FILE*>(file));
+}
+
int VMGlue::InitializeVM() {
// We need the next call to get Dart_Initialize not to bail early.
LOGI("Setting VM Options");
@@ -138,13 +169,13 @@
// creating and shutting down isolates.
LOGI("Initializing Dart");
if (!Dart_Initialize(CreateIsolateAndSetup,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL)) {
+ 0,
+ 0,
+ 0,
+ openFileCallback,
+ readFileCallback,
+ writeFileCallback,
+ closeFileCallback)) {
LOGE("VM initialization failed\n");
return -1;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698