summaryrefslogtreecommitdiffstats
path: root/base/x11/x11_error_tracker.h
blob: 5542f52a0562470e75902cab24ca9e7eda610fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2013 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 BASE_X11_X11_ERROR_TRACKER_H_
#define BASE_X11_X11_ERROR_TRACKER_H_

#include <X11/Xlib.h>

#include "base/base_export.h"
#include "base/basictypes.h"

namespace base {

// 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 BASE_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:
#if !defined(TOOLKIT_GTK)
  XErrorHandler old_handler_;
#endif

  DISALLOW_COPY_AND_ASSIGN(X11ErrorTracker);
};

}  // namespace base

#endif  // BASE_X11_X11_ERROR_TRACKER_H_