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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 5 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
« no previous file with comments | « ui/base/x/x11_menu_list.cc ('k') | ui/chromeos/ime/input_method_menu_manager.h » ('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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 DISALLOW_COPY_AND_ASSIGN(XCursorCache); 205 DISALLOW_COPY_AND_ASSIGN(XCursorCache);
206 }; 206 };
207 207
208 XCursorCache* cursor_cache = NULL; 208 XCursorCache* cursor_cache = NULL;
209 209
210 // A process wide singleton cache for custom X cursors. 210 // A process wide singleton cache for custom X cursors.
211 class XCustomCursorCache { 211 class XCustomCursorCache {
212 public: 212 public:
213 static XCustomCursorCache* GetInstance() { 213 static XCustomCursorCache* GetInstance() {
214 return Singleton<XCustomCursorCache>::get(); 214 return base::Singleton<XCustomCursorCache>::get();
215 } 215 }
216 216
217 ::Cursor InstallCustomCursor(XcursorImage* image) { 217 ::Cursor InstallCustomCursor(XcursorImage* image) {
218 XCustomCursor* custom_cursor = new XCustomCursor(image); 218 XCustomCursor* custom_cursor = new XCustomCursor(image);
219 ::Cursor xcursor = custom_cursor->cursor(); 219 ::Cursor xcursor = custom_cursor->cursor();
220 cache_[xcursor] = custom_cursor; 220 cache_[xcursor] = custom_cursor;
221 return xcursor; 221 return xcursor;
222 } 222 }
223 223
224 void Ref(::Cursor cursor) { 224 void Ref(::Cursor cursor) {
225 cache_[cursor]->Ref(); 225 cache_[cursor]->Ref();
226 } 226 }
227 227
228 void Unref(::Cursor cursor) { 228 void Unref(::Cursor cursor) {
229 if (cache_[cursor]->Unref()) 229 if (cache_[cursor]->Unref())
230 cache_.erase(cursor); 230 cache_.erase(cursor);
231 } 231 }
232 232
233 void Clear() { 233 void Clear() {
234 cache_.clear(); 234 cache_.clear();
235 } 235 }
236 236
237 const XcursorImage* GetXcursorImage(::Cursor cursor) const { 237 const XcursorImage* GetXcursorImage(::Cursor cursor) const {
238 return cache_.find(cursor)->second->image(); 238 return cache_.find(cursor)->second->image();
239 } 239 }
240 240
241 private: 241 private:
242 friend struct DefaultSingletonTraits<XCustomCursorCache>; 242 friend struct base::DefaultSingletonTraits<XCustomCursorCache>;
243 243
244 class XCustomCursor { 244 class XCustomCursor {
245 public: 245 public:
246 // This takes ownership of the image. 246 // This takes ownership of the image.
247 XCustomCursor(XcursorImage* image) 247 XCustomCursor(XcursorImage* image)
248 : image_(image), 248 : image_(image),
249 ref_(1) { 249 ref_(1) {
250 cursor_ = XcursorImageLoadCursor(gfx::GetXDisplay(), image); 250 cursor_ = XcursorImageLoadCursor(gfx::GetXDisplay(), image);
251 } 251 }
252 252
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1407 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1408 << "minor_code " << static_cast<int>(error_event.minor_code) 1408 << "minor_code " << static_cast<int>(error_event.minor_code)
1409 << " (" << request_str << ")"; 1409 << " (" << request_str << ")";
1410 } 1410 }
1411 1411
1412 // ---------------------------------------------------------------------------- 1412 // ----------------------------------------------------------------------------
1413 // End of x11_util_internal.h 1413 // End of x11_util_internal.h
1414 1414
1415 1415
1416 } // namespace ui 1416 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/x11_menu_list.cc ('k') | ui/chromeos/ime/input_method_menu_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698