summaryrefslogtreecommitdiffstats
path: root/ui/gfx/x/x11_error_tracker.h
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/x/x11_error_tracker.h')
-rw-r--r--ui/gfx/x/x11_error_tracker.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/gfx/x/x11_error_tracker.h b/ui/gfx/x/x11_error_tracker.h
new file mode 100644
index 0000000..efcac0c
--- /dev/null
+++ b/ui/gfx/x/x11_error_tracker.h
@@ -0,0 +1,36 @@
+// Copyright 2014 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.
+
+#ifndef UI_GFX_X_X11_ERROR_TRACKER_H_
+#define UI_GFX_X_X11_ERROR_TRACKER_H_
+
+#include <X11/Xlib.h>
+
+#include "base/basictypes.h"
+#include "ui/gfx/gfx_export.h"
+
+namespace gfx {
+
+// X11ErrorTracker catches X11 errors in a non-fatal way. It does so by
+// temporarily changing the X11 error handler. The old error handler is
+// restored when the tracker is destroyed.
+class GFX_EXPORT X11ErrorTracker {
+ public:
+ X11ErrorTracker();
+ ~X11ErrorTracker();
+
+ // Returns whether an X11 error happened since this function was last called
+ // (or since the creation of the tracker). This is potentially expensive,
+ // since this causes a sync with the X server.
+ bool FoundNewError();
+
+ private:
+ XErrorHandler old_handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(X11ErrorTracker);
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_X_X11_ERROR_TRACKER_H_