OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_BASE_X_X11_ATOM_CACHE_H_ | 5 #ifndef UI_AURA_X11_ATOM_CACHE_H_ |
6 #define UI_BASE_X_X11_ATOM_CACHE_H_ | 6 #define UI_AURA_X11_ATOM_CACHE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/singleton.h" | 9 #include "ui/aura/aura_export.h" |
10 #include "ui/base/ui_export.h" | |
11 | 10 |
12 #include <X11/Xlib.h> | 11 #include <X11/Xlib.h> |
13 | 12 |
14 #include <map> | 13 #include <map> |
15 | 14 |
16 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 15 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
17 #undef RootWindow | 16 #undef RootWindow |
18 | 17 |
19 namespace ui { | 18 namespace aura { |
| 19 class Env; |
20 | 20 |
21 // Names of cached atoms that we fetch from X11AtomCache. Adding an entry here | 21 // Names of cached atoms that we fetch from X11AtomCache. Adding an entry here |
22 // also requires adding an entry in the cc file. | 22 // also requires adding an entry in the cc file. |
23 enum AtomName { | 23 enum AtomName { |
24 ATOM_WM_DELETE_WINDOW = 0, | 24 ATOM_WM_DELETE_WINDOW = 0, |
25 ATOM__NET_WM_MOVERESIZE, | 25 ATOM__NET_WM_MOVERESIZE, |
26 ATOM__NET_WM_PING, | 26 ATOM__NET_WM_PING, |
27 ATOM__NET_WM_PID, | 27 ATOM__NET_WM_PID, |
28 ATOM_WM_S0, | 28 ATOM_WM_S0, |
29 ATOM__MOTIF_WM_HINTS, | 29 ATOM__MOTIF_WM_HINTS, |
30 | 30 |
31 ATOM_COUNT | 31 ATOM_COUNT |
32 }; | 32 }; |
33 | 33 |
34 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 | 34 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 |
35 // server. Assumes that we only have a single X11 display, | 35 // server. Assumes that we only have a single X11 display, |
36 // base::MessagePumpX::GetDefaultXDisplay(). | 36 // base::MessagePumpX::GetDefaultXDisplay(). |
37 class UI_EXPORT X11AtomCache { | 37 class AURA_EXPORT X11AtomCache { |
38 public: | 38 public: |
39 static X11AtomCache* GetInstance(); | |
40 | |
41 // Returns the pre-interned Atom by enum instead of string. | 39 // Returns the pre-interned Atom by enum instead of string. |
42 ::Atom GetAtom(AtomName name) const; | 40 ::Atom GetAtom(AtomName name) const; |
43 | 41 |
44 private: | 42 private: |
45 friend struct DefaultSingletonTraits<X11AtomCache>; | 43 friend class aura::Env; |
46 | 44 |
47 // Constructor performs all interning | 45 // Constructor performs all interning |
48 X11AtomCache(); | 46 X11AtomCache(); |
49 ~X11AtomCache(); | 47 ~X11AtomCache(); |
50 | 48 |
51 std::map<AtomName, ::Atom> cached_atoms_; | 49 std::map<AtomName, ::Atom> cached_atoms_; |
52 | 50 |
53 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); | 51 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); |
54 }; | 52 }; |
55 | 53 |
56 } // namespace ui | 54 } // namespace aura |
57 | 55 |
58 #endif // UI_BASE_X_ATOM_CACHE_H_ | 56 #endif // UI_AURA_ATOM_CACHE_H_ |
OLD | NEW |