Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ui/gfx/x/x11_atom_cache.h

Issue 2924343002: Move ui::GetAtom to gfx::GetAtom (Closed)
Patch Set: fix CrOs build Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/icc_profile_x11.cc ('k') | ui/gfx/x/x11_atom_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/gfx/gfx_export.h" 12 #include "ui/gfx/gfx_export.h"
13 #include "ui/gfx/x/x11_types.h" 13 #include "ui/gfx/x/x11_types.h"
14 14
15 namespace base { 15 namespace base {
16 template <typename T> 16 template <typename T>
17 struct DefaultSingletonTraits; 17 struct DefaultSingletonTraits;
18 } 18 }
19 19
20 namespace ui { 20 namespace gfx {
21
22 // Gets the X atom for default display corresponding to atom_name.
23 GFX_EXPORT XAtom GetAtom(const char* atom_name);
21 24
22 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 25 // Pre-caches all Atoms on first use to minimize roundtrips to the X11
23 // server. By default, GetAtom() will CHECK() that atoms accessed through 26 // server. By default, GetAtom() will CHECK() that atoms accessed through
24 // GetAtom() were passed to the constructor, but this behaviour can be changed 27 // GetAtom() were passed to the constructor, but this behaviour can be changed
25 // with allow_uncached_atoms(). 28 // with allow_uncached_atoms().
26 class GFX_EXPORT X11AtomCache { 29 class GFX_EXPORT X11AtomCache {
27 public: 30 public:
28 static X11AtomCache* GetInstance(); 31 static X11AtomCache* GetInstance();
29 32
30 // Returns the pre-interned Atom without having to go to the x server.
31 XAtom GetAtom(const char*) const;
32
33 private: 33 private:
34 friend XAtom GetAtom(const char* atom_name);
34 friend struct base::DefaultSingletonTraits<X11AtomCache>; 35 friend struct base::DefaultSingletonTraits<X11AtomCache>;
35 36
36 X11AtomCache(); 37 X11AtomCache();
37 ~X11AtomCache(); 38 ~X11AtomCache();
38 39
40 // Returns the pre-interned Atom without having to go to the x server.
41 XAtom GetAtom(const char*) const;
42
39 XDisplay* xdisplay_; 43 XDisplay* xdisplay_;
40 44
41 mutable std::map<std::string, XAtom> cached_atoms_; 45 mutable std::map<std::string, XAtom> cached_atoms_;
42 46
43 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); 47 DISALLOW_COPY_AND_ASSIGN(X11AtomCache);
44 }; 48 };
45 49
46 } // namespace ui 50 } // namespace gfx
47 51
48 #endif // UI_GFX_X_X11_ATOM_CACHE_H_ 52 #endif // UI_GFX_X_X11_ATOM_CACHE_H_
OLDNEW
« no previous file with comments | « ui/gfx/icc_profile_x11.cc ('k') | ui/gfx/x/x11_atom_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698