Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file defines utility functions for X11 (Linux only). This code has been | 5 // This file defines utility functions for X11 (Linux only). This code has been |
| 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support | 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support |
| 7 // remains woefully incomplete. | 7 // remains woefully incomplete. |
| 8 | 8 |
| 9 #include "ui/base/x/x11_util.h" | 9 #include "ui/base/x/x11_util.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 CachedPictFormats* get_cached_pict_formats() { | 49 CachedPictFormats* get_cached_pict_formats() { |
| 50 static CachedPictFormats* formats = NULL; | 50 static CachedPictFormats* formats = NULL; |
| 51 if (!formats) | 51 if (!formats) |
| 52 formats = new CachedPictFormats(); | 52 formats = new CachedPictFormats(); |
| 53 return formats; | 53 return formats; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Maximum number of CachedPictFormats we keep around. | 56 // Maximum number of CachedPictFormats we keep around. |
| 57 const size_t kMaxCacheSize = 5; | 57 const size_t kMaxCacheSize = 5; |
| 58 | 58 |
| 59 XErrorHandler error_handler_ = NULL; | |
|
Ami GONE FROM CHROMIUM
2011/09/14 17:11:13
file-statics don't get trailing underscores (here
dominich
2011/09/14 19:55:06
Done.
| |
| 60 XIOErrorHandler io_error_handler_ = NULL; | |
| 61 | |
| 59 int DefaultX11ErrorHandler(Display* d, XErrorEvent* e) { | 62 int DefaultX11ErrorHandler(Display* d, XErrorEvent* e) { |
| 60 MessageLoop::current()->PostTask( | 63 MessageLoop::current()->PostTask( |
| 61 FROM_HERE, NewRunnableFunction(LogErrorEventDescription, d, *e)); | 64 FROM_HERE, NewRunnableFunction(LogErrorEventDescription, d, *e)); |
| 62 return 0; | 65 return 0; |
| 63 } | 66 } |
| 64 | 67 |
| 65 int DefaultX11IOErrorHandler(Display* d) { | 68 int DefaultX11IOErrorHandler(Display* d) { |
| 66 // If there's an IO error it likely means the X server has gone away | 69 // If there's an IO error it likely means the X server has gone away |
| 67 LOG(ERROR) << "X IO Error detected"; | 70 LOG(ERROR) << "X IO Error detected"; |
| 68 _exit(1); | 71 _exit(1); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 // always blowing away the cache. If we are, then we should figure out why | 784 // always blowing away the cache. If we are, then we should figure out why |
| 782 // and make it bigger. | 785 // and make it bigger. |
| 783 NOTREACHED(); | 786 NOTREACHED(); |
| 784 } | 787 } |
| 785 | 788 |
| 786 return pictformat; | 789 return pictformat; |
| 787 } | 790 } |
| 788 | 791 |
| 789 void SetX11ErrorHandlers(XErrorHandler error_handler, | 792 void SetX11ErrorHandlers(XErrorHandler error_handler, |
| 790 XIOErrorHandler io_error_handler) { | 793 XIOErrorHandler io_error_handler) { |
| 791 XSetErrorHandler(error_handler ? error_handler : DefaultX11ErrorHandler); | 794 error_handler_ = error_handler ? error_handler : DefaultX11ErrorHandler; |
| 792 XSetIOErrorHandler( | 795 io_error_handler_ = io_error_handler ? |
| 793 io_error_handler ? io_error_handler : DefaultX11IOErrorHandler); | 796 io_error_handler : DefaultX11IOErrorHandler; |
| 797 XSetErrorHandler(error_handler_); | |
| 798 XSetIOErrorHandler(io_error_handler_); | |
| 794 } | 799 } |
| 795 | 800 |
| 796 void LogErrorEventDescription(Display* dpy, | 801 void LogErrorEventDescription(Display* dpy, |
| 797 const XErrorEvent& error_event) { | 802 const XErrorEvent& error_event) { |
| 798 char error_str[256]; | 803 char error_str[256]; |
| 799 char request_str[256]; | 804 char request_str[256]; |
| 800 | 805 |
| 801 XGetErrorText(dpy, error_event.error_code, error_str, sizeof(error_str)); | 806 XGetErrorText(dpy, error_event.error_code, error_str, sizeof(error_str)); |
| 802 | 807 |
| 803 strncpy(request_str, "Unknown", sizeof(request_str)); | 808 strncpy(request_str, "Unknown", sizeof(request_str)); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 828 LOG(ERROR) | 833 LOG(ERROR) |
| 829 << "X Error detected: " | 834 << "X Error detected: " |
| 830 << "serial " << error_event.serial << ", " | 835 << "serial " << error_event.serial << ", " |
| 831 << "error_code " << static_cast<int>(error_event.error_code) | 836 << "error_code " << static_cast<int>(error_event.error_code) |
| 832 << " (" << error_str << "), " | 837 << " (" << error_str << "), " |
| 833 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 838 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 834 << "minor_code " << static_cast<int>(error_event.minor_code) | 839 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 835 << " (" << request_str << ")"; | 840 << " (" << request_str << ")"; |
| 836 } | 841 } |
| 837 | 842 |
| 843 ScopedX11ErrorHandlerOverride::ScopedX11ErrorHandlerOverride( | |
| 844 XErrorHandler error_handler, XIOErrorHandler io_error_handler) | |
| 845 : old_error_handler_(error_handler_), | |
| 846 old_io_error_handler_(io_error_handler_) { | |
| 847 ui::SetX11ErrorHandlers(error_handler, io_error_handler); | |
|
Ami GONE FROM CHROMIUM
2011/09/14 17:11:13
ui:: here and below unnecessary?
Ami GONE FROM CHROMIUM
2011/09/14 17:11:13
I expected sync calls here and in the dtor.
dominich
2011/09/14 19:55:06
Done.
dominich
2011/09/14 19:55:06
Done.
| |
| 848 } | |
| 849 | |
| 850 ScopedX11ErrorHandlerOverride::~ScopedX11ErrorHandlerOverride() { | |
| 851 ui::SetX11ErrorHandlers(old_error_handler_, old_io_error_handler_); | |
| 852 } | |
| 853 | |
| 838 // ---------------------------------------------------------------------------- | 854 // ---------------------------------------------------------------------------- |
| 839 // End of x11_util_internal.h | 855 // End of x11_util_internal.h |
| 840 | 856 |
| 841 | 857 |
| 842 } // namespace ui | 858 } // namespace ui |
| OLD | NEW |