Index: ui/base/x/x11_atom_cache.cc |
diff --git a/ui/base/x/x11_atom_cache.cc b/ui/base/x/x11_atom_cache.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7706eda77b797ae69a2977047d82d11f5a0e604a |
--- /dev/null |
+++ b/ui/base/x/x11_atom_cache.cc |
@@ -0,0 +1,47 @@ |
+// Copyright (c) 2012 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. |
+ |
+#include "ui/base/x/x11_atom_cache.h" |
+ |
+#include <X11/Xatom.h> |
+ |
+#include "base/message_pump_x.h" |
+ |
+namespace { |
+ |
+// A list of atoms that we'll intern on host creation to save roundtrips to the |
+// X11 server. Must be kept in sync with AtomCache::AtomName |
Daniel Erat
2012/05/15 20:59:41
This makes me nervous (especially combined with no
Elliot Glaysher
2012/05/15 21:56:32
Done.
|
+const char* kAtomList[] = { |
+ "WM_DELETE_WINDOW", |
+ "_NET_WM_MOVERESIZE", |
+ "_NET_WM_PING", |
+ "_NET_WM_PID", |
+ "WM_S0", |
+ "_MOTIF_WM_HINTS" |
+}; |
+ |
+} // namespace |
+ |
+namespace ui { |
+ |
+X11AtomCache* X11AtomCache::GetInstance() { |
+ return Singleton<X11AtomCache>::get(); |
+} |
+ |
+::Atom X11AtomCache::GetAtom(AtomName name) const { |
+ return cached_atoms_[name]; |
+} |
+ |
+X11AtomCache::X11AtomCache() { |
+ // Grab all the atoms we need now to minimize roundtrips to the X11 server. |
+ XInternAtoms(base::MessagePumpX::GetDefaultXDisplay(), |
+ const_cast<char**>(kAtomList), ATOM_COUNT, False, |
+ cached_atoms_); |
+} |
+ |
+X11AtomCache::~X11AtomCache() {} |
+ |
+} // namespace ui |
+ |
+ |