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

Unified Diff: ui/base/x/x11_util.cc

Issue 17029020: linux_aura: Redo how memory is handled in clipboard/drag code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
Index: ui/base/x/x11_util.cc
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 1ac4513e7d713c41251843123c3b2eb45f4800d9..324cdd13503aa24961bcf02f91a7acfb0a007039 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -763,7 +763,7 @@ bool PropertyExists(XID window, const std::string& property_name) {
bool GetRawBytesOfProperty(XID window,
Atom property,
- unsigned char** out_data,
+ scoped_refptr<base::RefCountedMemory>* out_data,
size_t* out_data_bytes,
size_t* out_data_items,
Atom* out_type) {
@@ -783,31 +783,33 @@ bool GetRawBytesOfProperty(XID window,
if (prop_type == None)
return false;
+ size_t bytes = 0;
+ // So even though we should theoretically have nbytes (and we can't
+ // pass NULL there), we need to manually calculate the byte length here
+ // because nbytes always returns zero.
+ switch (prop_format) {
+ case 8:
+ bytes = nitems;
+ break;
+ case 16:
+ bytes = sizeof(short) * nitems;
+ break;
+ case 32:
+ bytes = sizeof(long) * nitems;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+
+ if (out_data_bytes)
+ *out_data_bytes = bytes;
+
if (out_data)
- *out_data = property_data;
+ *out_data = new XRefcountedMemory(property_data, bytes);
else
XFree(property_data);
- if (out_data_bytes) {
- // So even though we should theoretically have nbytes (and we can't
- // pass NULL there), we need to manually calculate the byte length here
- // because nbytes always returns zero.
- switch (prop_format) {
- case 8:
- *out_data_bytes = nitems;
- break;
- case 16:
- *out_data_bytes = sizeof(short) * nitems;
- break;
- case 32:
- *out_data_bytes = sizeof(long) * nitems;
- break;
- default:
- NOTREACHED();
- break;
- }
- }
-
if (out_data_items)
*out_data_items = nitems;
@@ -1501,6 +1503,18 @@ void InitXKeyEventForTesting(EventType type,
event->xkey = key_event;
}
+const unsigned char* XRefcountedMemory::front() const {
+ return x11_data_;
+}
+
+size_t XRefcountedMemory::size() const {
+ return length_;
+}
+
+XRefcountedMemory::~XRefcountedMemory() {
+ XFree(x11_data_);
+}
+
XScopedString::~XScopedString() {
XFree(string_);
}

Powered by Google App Engine
This is Rietveld 408576698