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

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: Fixes for sky; ptal 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
« no previous file with comments | « ui/base/x/selection_utils.cc ('k') | ui/base/x/x11_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c1c72ba019141e34001e7ff8fd27085f73b89af4 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,29 @@ 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:
+ XRefcountedMemory(unsigned char* x11_data, size_t length)
+ : x11_data_(length ? x11_data : NULL),
+ length_(length) {
+ }
+
+ // 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 {
« no previous file with comments | « ui/base/x/selection_utils.cc ('k') | ui/base/x/x11_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698