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

Side by Side Diff: ui/gfx/x/x11_error_tracker.cc

Issue 966173002: Cleanup: Include the associated header file before other includes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h"
6 #include "ui/gfx/x/x11_error_tracker.h" 5 #include "ui/gfx/x/x11_error_tracker.h"
7 6
7 #include "base/logging.h"
8 #include "ui/gfx/x/x11_types.h" 8 #include "ui/gfx/x/x11_types.h"
9 9
10 namespace { 10 namespace {
11 11
12 unsigned char g_x11_error_code = 0; 12 unsigned char g_x11_error_code = 0;
13 static gfx::X11ErrorTracker* g_handler = NULL; 13 static gfx::X11ErrorTracker* g_handler = NULL;
14 14
15 int X11ErrorHandler(Display* display, XErrorEvent* error) { 15 int X11ErrorHandler(Display* display, XErrorEvent* error) {
16 g_x11_error_code = error->error_code; 16 g_x11_error_code = error->error_code;
17 return 0; 17 return 0;
18 } 18 }
19 } 19
20 } // namespace
20 21
21 namespace gfx { 22 namespace gfx {
22 23
23 X11ErrorTracker::X11ErrorTracker() { 24 X11ErrorTracker::X11ErrorTracker() {
24 // This is a poor-man's check for incorrect usage. It disallows nested 25 // This is a poor-man's check for incorrect usage. It disallows nested
25 // X11ErrorTracker instances on the same thread. 26 // X11ErrorTracker instances on the same thread.
26 DCHECK(g_handler == NULL); 27 DCHECK(g_handler == NULL);
27 g_handler = this; 28 g_handler = this;
28 XSync(GetXDisplay(), False); 29 XSync(GetXDisplay(), False);
29 old_handler_ = XSetErrorHandler(X11ErrorHandler); 30 old_handler_ = XSetErrorHandler(X11ErrorHandler);
30 g_x11_error_code = 0; 31 g_x11_error_code = 0;
31 } 32 }
32 33
33 X11ErrorTracker::~X11ErrorTracker() { 34 X11ErrorTracker::~X11ErrorTracker() {
34 g_handler = NULL; 35 g_handler = NULL;
35 XSetErrorHandler(old_handler_); 36 XSetErrorHandler(old_handler_);
36 } 37 }
37 38
38 bool X11ErrorTracker::FoundNewError() { 39 bool X11ErrorTracker::FoundNewError() {
39 XSync(GetXDisplay(), False); 40 XSync(GetXDisplay(), False);
40 unsigned char error = g_x11_error_code; 41 unsigned char error = g_x11_error_code;
41 g_x11_error_code = 0; 42 g_x11_error_code = 0;
42 return error != 0; 43 return error != 0;
43 } 44 }
44 45
45 } // namespace gfx 46 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698