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

Unified Diff: ui/display/chromeos/x11/native_display_delegate_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/display/util/x11/edid_parser_x11.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/chromeos/x11/native_display_delegate_x11.cc
diff --git a/ui/display/chromeos/x11/native_display_delegate_x11.cc b/ui/display/chromeos/x11/native_display_delegate_x11.cc
index 5394c0985687bdd7e5e243603cee00f30409b17d..902d2263a5c14fc2460dee0b467a6fd266515175 100644
--- a/ui/display/chromeos/x11/native_display_delegate_x11.cc
+++ b/ui/display/chromeos/x11/native_display_delegate_x11.cc
@@ -400,7 +400,6 @@ bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output,
// TODO(kcwu): Use X11AtomCache to save round trip time of XInternAtom.
Atom prop = XInternAtom(display_, kContentProtectionAtomName, False);
- bool ok = true;
// TODO(kcwu): Move this to x11_util (similar method calls in this file and
// output_util.cc)
success = XRRGetOutputProperty(display_,
@@ -416,12 +415,15 @@ bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output,
&nitems,
&bytes_after,
&values);
+ gfx::XScopedPtr<unsigned char> scoped_values(values);
if (actual_type == None) {
LOG(ERROR) << "Property '" << kContentProtectionAtomName
<< "' does not exist";
- ok = false;
- } else if (success == Success && actual_type == XA_ATOM &&
- actual_format == 32 && nitems == 1) {
+ return false;
+ }
+
+ if (success == Success && actual_type == XA_ATOM && actual_format == 32 &&
+ nitems == 1) {
Atom value = reinterpret_cast<Atom*>(values)[0];
if (value == XInternAtom(display_, kProtectionUndesiredAtomName, False)) {
*state = HDCP_STATE_UNDESIRED;
@@ -434,17 +436,15 @@ bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output,
} else {
LOG(ERROR) << "Unknown " << kContentProtectionAtomName
<< " value: " << value;
- ok = false;
+ return false;
}
} else {
LOG(ERROR) << "XRRGetOutputProperty failed";
- ok = false;
+ return false;
}
- if (values)
- XFree(values);
- VLOG(3) << "HDCP state: " << ok << "," << *state;
- return ok;
+ VLOG(3) << "HDCP state: success," << *state;
+ return true;
}
bool NativeDisplayDelegateX11::SetHDCPState(const DisplaySnapshot& output,
@@ -537,16 +537,14 @@ void NativeDisplayDelegateX11::UpdateCrtcsForNewFramebuffer(
}
bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) {
- bool ret = false;
-
Atom scaling_prop = XInternAtom(display_, "scaling mode", False);
Atom full_aspect_atom = XInternAtom(display_, "Full aspect", False);
if (scaling_prop == None || full_aspect_atom == None)
return false;
int nprop = 0;
- Atom* props = XRRListOutputProperties(display_, id, &nprop);
- for (int j = 0; j < nprop && !ret; j++) {
+ gfx::XScopedPtr<Atom[]> props(XRRListOutputProperties(display_, id, &nprop));
+ for (int j = 0; j < nprop; j++) {
Atom prop = props[j];
if (scaling_prop == prop) {
unsigned char* values = NULL;
@@ -569,20 +567,16 @@ bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) {
&nitems,
&bytes_after,
&values);
+ gfx::XScopedPtr<unsigned char> scoped_value(values);
if (success == Success && actual_type == XA_ATOM && actual_format == 32 &&
nitems == 1) {
Atom value = reinterpret_cast<Atom*>(values)[0];
if (full_aspect_atom == value)
- ret = true;
+ return true;
}
- if (values)
- XFree(values);
}
}
- if (props)
- XFree(props);
-
- return ret;
+ return false;
}
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/display/util/x11/edid_parser_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698