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

Unified Diff: sandbox/linux/seccomp-bpf/die.cc

Issue 10833044: Refactored ErrorCode into it's own class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unittest (and new framework to make this possible) Created 8 years, 4 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
Index: sandbox/linux/seccomp-bpf/die.cc
diff --git a/sandbox/linux/seccomp-bpf/die.cc b/sandbox/linux/seccomp-bpf/die.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b63411c0a3841499ac10611aca55c488b3a90b47
--- /dev/null
+++ b/sandbox/linux/seccomp-bpf/die.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 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 "sandbox/linux/seccomp-bpf/die.h"
+
+
+namespace playground2 {
+
+bool Die::CallHandler(const char *msg, const char *file, int line) {
+ if (!HasCustomHandler()) {
+ return false;
+ }
+ handlers_.back()(msg, file, line);
+ return true;
+}
+
+void Die::LogToStderr(const char *msg, const char *file, int line) {
+ if (msg) {
+ char buf[40];
+ sprintf(buf, "%d", line);
+ std::string s = std::string(file) + ":" + buf + ":" + msg + "\n";
+ if (HANDLE_EINTR(write(2, s.c_str(), s.length()))) { }
+ }
+}
+
+std::vector<Die::Handler> Die::handlers_;
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698