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

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

Issue 10829341: Desktop aura: Use the X11 clipboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MessageLoop ordering in tests. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/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_AURA_X11_ATOM_CACHE_H_ 5 #ifndef UI_BASE_X_X11_ATOM_CACHE_H_
6 #define UI_AURA_X11_ATOM_CACHE_H_ 6 #define UI_BASE_X_X11_ATOM_CACHE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "ui/aura/aura_export.h" 9 #include "ui/base/ui_export.h"
10 10
11 #include <X11/Xlib.h> 11 #include <X11/Xlib.h>
12 12
13 #include <map> 13 #include <map>
14 #include <string> 14 #include <string>
15 15
16 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 16 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
17 #undef RootWindow 17 #undef RootWindow
18 18
19 namespace aura { 19 namespace ui {
20 20
21 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 21 // Pre-caches all Atoms on first use to minimize roundtrips to the X11
22 // server. Assumes that we only have a single X11 display, 22 // server. By default, GetAtom() will CHECK() that atoms accessed through
23 // base::MessagePumpX::GetDefaultXDisplay(). 23 // GetAtom() were passed to the constructor, but this behaviour can be changed
24 class AURA_EXPORT X11AtomCache { 24 // with allow_uncached_atoms().
25 class UI_EXPORT X11AtomCache {
25 public: 26 public:
26 // Preinterns the NULL terminated list of string |to_cache_ on |xdisplay|. 27 // Preinterns the NULL terminated list of string |to_cache_ on |xdisplay|.
27 X11AtomCache(Display* xdisplay, const char** to_cache); 28 X11AtomCache(Display* xdisplay, const char** to_cache);
28 ~X11AtomCache(); 29 ~X11AtomCache();
29 30
30 // Returns the pre-interned Atom without having to go to the x server. 31 // Returns the pre-interned Atom without having to go to the x server.
31 ::Atom GetAtom(const char*) const; 32 ::Atom GetAtom(const char*) const;
32 33
34 // 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.
36 void allow_uncached_atoms() { uncached_atoms_allowed_ = true; }
37
33 private: 38 private:
34 Display* xdisplay_; 39 Display* xdisplay_;
35 40
36 std::map<std::string, ::Atom> cached_atoms_; 41 bool uncached_atoms_allowed_;
42
43 mutable std::map<std::string, ::Atom> cached_atoms_;
37 44
38 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); 45 DISALLOW_COPY_AND_ASSIGN(X11AtomCache);
39 }; 46 };
40 47
41 } // namespace aura 48 } // namespace ui
42 49
43 #endif // UI_AURA_ATOM_CACHE_H_ 50 #endif // UI_BASE_X_X11_ATOM_CACHE_H_
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/x/x11_atom_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698