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

Unified Diff: runtime/bin/file.cc

Issue 1460863002: Redo the interface for capture stdio. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 | « runtime/bin/file.h ('k') | runtime/bin/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index cfd5637081825afb93952ffa2de98ce89d49c6d2..1face6bf2a05bde599393a7e6dd3b809b9f2be20 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -6,6 +6,7 @@
#include "bin/builtin.h"
#include "bin/dartutils.h"
+#include "bin/embedded_dart_io.h"
#include "bin/io_buffer.h"
#include "bin/utils.h"
@@ -18,13 +19,31 @@ namespace bin {
static const int kMSPerSecond = 1000;
// Are we capturing output from stdout for the VM service?
-bool File::capture_stdout_ = false;
+static bool capture_stdout = false;
// Are we capturing output from stderr for the VM service?
-bool File::capture_stderr_ = false;
+static bool capture_stderr = false;
+
+
+void SetCaptureStdout(bool value) {
+ capture_stdout = value;
+}
+
+
+void SetCaptureStderr(bool value) {
+ capture_stderr = value;
+}
+
+
+bool ShouldCaptureStdout() {
+ return capture_stdout;
+}
+
+
+bool ShouldCaptureStderr() {
+ return capture_stderr;
+}
-// Are we capturing output from either stdout or stderr for the VM Service?
-bool File::capture_any_ = false;
// The file pointer has been passed into Dart as an intptr_t and it is safe
@@ -62,13 +81,13 @@ bool File::WriteFully(const void* buffer, int64_t num_bytes) {
remaining -= bytes_written; // Reduce the number of remaining bytes.
current_buffer += bytes_written; // Move the buffer forward.
}
- if (capture_any_) {
+ if (capture_stdout || capture_stderr) {
intptr_t fd = GetFD();
- if (fd == STDOUT_FILENO && capture_stdout_) {
+ if (fd == STDOUT_FILENO && capture_stdout) {
Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
reinterpret_cast<const uint8_t*>(buffer),
num_bytes);
- } else if (fd == STDERR_FILENO && capture_stderr_) {
+ } else if (fd == STDERR_FILENO && capture_stderr) {
Dart_ServiceSendDataEvent("Stderr", "WriteEvent",
reinterpret_cast<const uint8_t*>(buffer),
num_bytes);
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698