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

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

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.h
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
index 592e48a0d3d4002f40c3be540a4a7025ca1325c5..9a2f61987ed1217546a13aa5945c73230790ade6 100644
--- a/ui/base/x/x11_util.h
+++ b/ui/base/x/x11_util.h
@@ -16,6 +16,7 @@
#include "base/basictypes.h"
#include "base/event_types.h"
+#include "base/memory/ref_counted_memory.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/ui_export.h"
@@ -166,12 +167,13 @@ UI_EXPORT bool PropertyExists(XID window, const std::string& property_name);
// Returns the raw bytes from a property with minimal
// interpretation. |out_data| should be freed by XFree() after use.
-UI_EXPORT bool GetRawBytesOfProperty(XID window,
- Atom property,
- unsigned char** out_data,
- size_t* out_data_bytes,
- size_t* out_data_items,
- Atom* out_type);
+UI_EXPORT bool GetRawBytesOfProperty(
+ XID window,
+ Atom property,
+ scoped_refptr<base::RefCountedMemory>* out_data,
+ size_t* out_data_bytes,
+ size_t* out_data_items,
+ Atom* out_type);
// Get the value of an int, int array, atom array or string property. On
// success, true is returned and the value is stored in |value|.
@@ -333,6 +335,27 @@ UI_EXPORT void InitXKeyEventForTesting(EventType type,
int flags,
XEvent* event);
+// Manages a piece of X11 allocated memory as a RefCountedMemory segment. This
+// object takes ownership over the passed in memory and will free it with the
+// X11 allocator when done.
+class UI_EXPORT XRefcountedMemory : public base::RefCountedMemory {
+ public:
+ explicit XRefcountedMemory(unsigned char* x11_data, size_t length)
sky 2013/06/24 20:36:18 nit: no explicit
+ : x11_data_(length ? x11_data : NULL), length_(length) {}
sky 2013/06/24 20:36:18 nit: one param per line when you wrap.
+
+ // Overridden from RefCountedMemory:
+ virtual const unsigned char* front() const OVERRIDE;
+ virtual size_t size() const OVERRIDE;
+
+ private:
+ virtual ~XRefcountedMemory();
+
+ unsigned char* x11_data_;
+ size_t length_;
+
+ DISALLOW_COPY_AND_ASSIGN(XRefcountedMemory);
+};
+
// Keeps track of a string returned by an X function (e.g. XGetAtomName) and
// makes sure it's XFree'd.
class UI_EXPORT XScopedString {

Powered by Google App Engine
This is Rietveld 408576698