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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/win/physical_size.cc ('k') | ui/gfx/x/x11_types.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 #include "ui/gfx/x/x11_atom_cache.h" 5 #include "ui/gfx/x/x11_atom_cache.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include <memory>
11
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 X11AtomCache::X11AtomCache(XDisplay* xdisplay, const char* const* to_cache) 16 X11AtomCache::X11AtomCache(XDisplay* xdisplay, const char* const* to_cache)
16 : xdisplay_(xdisplay), 17 : xdisplay_(xdisplay),
17 uncached_atoms_allowed_(false) { 18 uncached_atoms_allowed_(false) {
18 int cache_count = 0; 19 int cache_count = 0;
19 for (const char* const* i = to_cache; *i; ++i) 20 for (const char* const* i = to_cache; *i; ++i)
20 ++cache_count; 21 ++cache_count;
21 22
22 scoped_ptr<XAtom[]> cached_atoms(new XAtom[cache_count]); 23 std::unique_ptr<XAtom[]> cached_atoms(new XAtom[cache_count]);
23 24
24 // Grab all the atoms we need now to minimize roundtrips to the X11 server. 25 // Grab all the atoms we need now to minimize roundtrips to the X11 server.
25 XInternAtoms(xdisplay_, 26 XInternAtoms(xdisplay_,
26 const_cast<char**>(to_cache), cache_count, False, 27 const_cast<char**>(to_cache), cache_count, False,
27 cached_atoms.get()); 28 cached_atoms.get());
28 29
29 for (int i = 0; i < cache_count; ++i) 30 for (int i = 0; i < cache_count; ++i)
30 cached_atoms_.insert(std::make_pair(to_cache[i], cached_atoms[i])); 31 cached_atoms_.insert(std::make_pair(to_cache[i], cached_atoms[i]));
31 } 32 }
32 33
33 X11AtomCache::~X11AtomCache() {} 34 X11AtomCache::~X11AtomCache() {}
34 35
35 XAtom X11AtomCache::GetAtom(const char* name) const { 36 XAtom X11AtomCache::GetAtom(const char* name) const {
36 std::map<std::string, Atom>::const_iterator it = cached_atoms_.find(name); 37 std::map<std::string, Atom>::const_iterator it = cached_atoms_.find(name);
37 38
38 if (uncached_atoms_allowed_ && it == cached_atoms_.end()) { 39 if (uncached_atoms_allowed_ && it == cached_atoms_.end()) {
39 XAtom atom = XInternAtom(xdisplay_, name, false); 40 XAtom atom = XInternAtom(xdisplay_, name, false);
40 cached_atoms_.insert(std::make_pair(name, atom)); 41 cached_atoms_.insert(std::make_pair(name, atom));
41 return atom; 42 return atom;
42 } 43 }
43 44
44 CHECK(it != cached_atoms_.end()) << " Atom " << name << " not found"; 45 CHECK(it != cached_atoms_.end()) << " Atom " << name << " not found";
45 return it->second; 46 return it->second;
46 } 47 }
47 48
48 } // namespace ui 49 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/win/physical_size.cc ('k') | ui/gfx/x/x11_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698