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

Side by Side Diff: ui/base/idle/idle_query_x11.cc

Issue 989993002: x11: Use scoped_ptr<> for X11 objects where it makes sense. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 9 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 | « content/content_common.gypi ('k') | ui/base/ime/chromeos/ime_keyboard_x11.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 #include "ui/base/idle/idle_query_x11.h" 5 #include "ui/base/idle/idle_query_x11.h"
6 6
7 #include <X11/extensions/scrnsaver.h> 7 #include <X11/extensions/scrnsaver.h>
8 8
9 #include "ui/gfx/x/x11_types.h" 9 #include "ui/gfx/x/x11_types.h"
10 10
11 namespace ui { 11 namespace ui {
12 12
13 class IdleData { 13 class IdleData {
14 public: 14 public:
15 IdleData() { 15 IdleData() {
16 int event_base; 16 int event_base;
17 int error_base; 17 int error_base;
18 if (XScreenSaverQueryExtension(gfx::GetXDisplay(), &event_base, 18 if (XScreenSaverQueryExtension(gfx::GetXDisplay(), &event_base,
19 &error_base)) { 19 &error_base)) {
20 mit_info = XScreenSaverAllocInfo(); 20 mit_info.reset(XScreenSaverAllocInfo());
21 } else {
22 mit_info = NULL;
23 } 21 }
24 } 22 }
25 23
26 ~IdleData() { 24 ~IdleData() {
27 if (mit_info)
28 XFree(mit_info);
29 } 25 }
30 26
31 XScreenSaverInfo *mit_info; 27 gfx::XScopedPtr<XScreenSaverInfo> mit_info;
32 }; 28 };
33 29
34 IdleQueryX11::IdleQueryX11() : idle_data_(new IdleData()) {} 30 IdleQueryX11::IdleQueryX11() : idle_data_(new IdleData()) {}
35 31
36 IdleQueryX11::~IdleQueryX11() {} 32 IdleQueryX11::~IdleQueryX11() {}
37 33
38 int IdleQueryX11::IdleTime() { 34 int IdleQueryX11::IdleTime() {
39 if (!idle_data_->mit_info) 35 if (!idle_data_->mit_info)
40 return 0; 36 return 0;
41 37
42 if (XScreenSaverQueryInfo(gfx::GetXDisplay(), 38 if (XScreenSaverQueryInfo(gfx::GetXDisplay(),
43 RootWindow(gfx::GetXDisplay(), 0), 39 RootWindow(gfx::GetXDisplay(), 0),
44 idle_data_->mit_info)) { 40 idle_data_->mit_info.get())) {
45 return (idle_data_->mit_info->idle) / 1000; 41 return (idle_data_->mit_info->idle) / 1000;
46 } else { 42 } else {
47 return 0; 43 return 0;
48 } 44 }
49 } 45 }
50 46
51 } // namespace ui 47 } // namespace ui
OLDNEW
« no previous file with comments | « content/content_common.gypi ('k') | ui/base/ime/chromeos/ime_keyboard_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698