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

Unified Diff: runtime/bin/main.cc

Issue 11442024: Unify specification of file open, close, and write callbacks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/run_vm_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 7505ad1c252bce5910c4c79fb80b5ffddbb201a5..8700364b990d014a83c82fd93dd6e8f0469bbe09 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -41,6 +41,7 @@ static const char* generate_pprof_symbols_filename = NULL;
static bool use_script_snapshot = false;
static File* snapshot_file = NULL;
+
// Global state that indicates whether there is a debug breakpoint.
// This pointer points into an argv buffer and does not need to be
// free'd.
@@ -227,11 +228,26 @@ static bool ProcessMainOptions(const char* option) {
}
-static void WriteToPerfEventsFile(const char* buffer, int64_t num_bytes) {
- ASSERT(perf_events_symbols_file != NULL);
- perf_events_symbols_file->WriteFully(buffer, num_bytes);
+static void* OpenFile(const char* name) {
+ File* file = File::Open(name, File::kWriteTruncate);
+ ASSERT(file != NULL);
+ return reinterpret_cast<void*>(file);
+}
+
+
+static void WriteFile(const void* buffer, intptr_t num_bytes, void* stream) {
+ ASSERT(stream != NULL);
+ File* file_stream = reinterpret_cast<File*>(stream);
+ bool bytes_written = file_stream->WriteFully(buffer, num_bytes);
+ ASSERT(bytes_written);
}
+
+static void CloseFile(void* stream) {
+ delete reinterpret_cast<File*>(stream);
+}
+
+
// Convert all the arguments to UTF8. On Windows, the arguments are
// encoded in the current code page and not UTF8.
//
@@ -291,7 +307,7 @@ static int ParseArguments(int argc,
}
if (perf_events_symbols_file != NULL) {
- Dart_InitPerfEventsSupport(&WriteToPerfEventsFile);
+ Dart_InitPerfEventsSupport(perf_events_symbols_file);
}
if (generate_pprof_symbols_filename != NULL) {
@@ -690,10 +706,8 @@ int main(int argc, char** argv) {
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
// Initialize the Dart VM.
- if (!Dart_Initialize(CreateIsolateAndSetup,
- NULL,
- NULL,
- ShutdownIsolate)) {
+ if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
+ OpenFile, WriteFile, CloseFile)) {
fprintf(stderr, "%s", "VM initialization failed\n");
fflush(stderr);
return kErrorExitCode;
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/run_vm_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698