| 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_GFX_X_X11_ATOM_CACHE_H_ | 5 #ifndef UI_GFX_X_X11_ATOM_CACHE_H_ |
| 6 #define UI_GFX_X_X11_ATOM_CACHE_H_ | 6 #define UI_GFX_X_X11_ATOM_CACHE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | |
| 9 #include "ui/gfx/gfx_export.h" | |
| 10 | |
| 11 #include <map> | 8 #include <map> |
| 12 #include <string> | 9 #include <string> |
| 13 | 10 |
| 14 #include <X11/Xlib.h> | 11 #include "base/basictypes.h" |
| 12 #include "ui/gfx/gfx_export.h" |
| 13 #include "ui/gfx/x/x11_types.h" |
| 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 ui { |
| 20 | 19 |
| 21 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 | 20 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 |
| 22 // server. By default, GetAtom() will CHECK() that atoms accessed through | 21 // server. By default, GetAtom() will CHECK() that atoms accessed through |
| 23 // GetAtom() were passed to the constructor, but this behaviour can be changed | 22 // GetAtom() were passed to the constructor, but this behaviour can be changed |
| 24 // with allow_uncached_atoms(). | 23 // with allow_uncached_atoms(). |
| 25 class GFX_EXPORT X11AtomCache { | 24 class GFX_EXPORT X11AtomCache { |
| 26 public: | 25 public: |
| 27 // Preinterns the NULL terminated list of string |to_cache_ on |xdisplay|. | 26 // Preinterns the NULL terminated list of string |to_cache_ on |xdisplay|. |
| 28 X11AtomCache(Display* xdisplay, const char** to_cache); | 27 X11AtomCache(XDisplay* xdisplay, const char** to_cache); |
| 29 ~X11AtomCache(); | 28 ~X11AtomCache(); |
| 30 | 29 |
| 31 // Returns the pre-interned Atom without having to go to the x server. | 30 // Returns the pre-interned Atom without having to go to the x server. |
| 32 ::Atom GetAtom(const char*) const; | 31 ::Atom GetAtom(const char*) const; |
| 33 | 32 |
| 34 // When an Atom isn't in the list of items we've cached, we should look it | 33 // When an Atom isn't in the list of items we've cached, we should look it |
| 35 // up, cache it locally, and then return the result. | 34 // up, cache it locally, and then return the result. |
| 36 void allow_uncached_atoms() { uncached_atoms_allowed_ = true; } | 35 void allow_uncached_atoms() { uncached_atoms_allowed_ = true; } |
| 37 | 36 |
| 38 private: | 37 private: |
| 39 Display* xdisplay_; | 38 XDisplay* xdisplay_; |
| 40 | 39 |
| 41 bool uncached_atoms_allowed_; | 40 bool uncached_atoms_allowed_; |
| 42 | 41 |
| 43 mutable std::map<std::string, ::Atom> cached_atoms_; | 42 mutable std::map<std::string, Atom> cached_atoms_; |
| 44 | 43 |
| 45 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); | 44 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 } // namespace ui | 47 } // namespace ui |
| 49 | 48 |
| 50 #endif // UI_GFX_X_X11_ATOM_CACHE_H_ | 49 #endif // UI_GFX_X_X11_ATOM_CACHE_H_ |
| OLD | NEW |