OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_BASE_X_X11_ATOM_CACHE_H_ |
| 6 #define UI_BASE_X_X11_ATOM_CACHE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/singleton.h" |
| 10 #include "ui/base/ui_export.h" |
| 11 |
| 12 #include <X11/Xlib.h> |
| 13 |
| 14 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
| 15 #undef RootWindow |
| 16 |
| 17 namespace ui { |
| 18 |
| 19 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 |
| 20 // server. Assumes that we only have a single X11 display, |
| 21 // base::MessagePumpX::GetDefaultXDisplay(). |
| 22 class UI_EXPORT X11AtomCache { |
| 23 public: |
| 24 static X11AtomCache* GetInstance(); |
| 25 |
| 26 // Names of cached atoms that we fetch during the constructor to minimize |
| 27 // round trips to the X11 server. |
| 28 enum AtomName { |
| 29 WM_DELETE_WINDOW = 0, |
| 30 _NET_WM_MOVERESIZE, |
| 31 _NET_WM_PING, |
| 32 _NET_WM_PID, |
| 33 WM_S0, |
| 34 |
| 35 _MOTIF_WM_HINTS, |
| 36 |
| 37 ATOM_COUNT |
| 38 }; |
| 39 |
| 40 // Returns the pre-interned Atom by enum instead of string. |
| 41 ::Atom GetAtom(AtomName name) const; |
| 42 |
| 43 private: |
| 44 friend struct DefaultSingletonTraits<X11AtomCache>; |
| 45 |
| 46 // Constructor performs all interning |
| 47 X11AtomCache(); |
| 48 ~X11AtomCache(); |
| 49 |
| 50 ::Atom cached_atoms_[ATOM_COUNT]; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); |
| 53 }; |
| 54 |
| 55 } // namespace ui |
| 56 |
| 57 #endif // UI_BASE_X_ATOM_CACHE_H_ |
OLD | NEW |