OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_OBJECT_H_ | 5 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_OBJECT_H_ |
6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_OBJECT_H_ | 6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_OBJECT_H_ |
7 | 7 |
8 #include <wayland-client-core.h> | 8 #include <wayland-client-core.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include <memory> |
11 | 11 |
12 struct wl_buffer; | 12 struct wl_buffer; |
13 struct wl_compositor; | 13 struct wl_compositor; |
14 struct wl_pointer; | 14 struct wl_pointer; |
15 struct wl_registry; | 15 struct wl_registry; |
16 struct wl_seat; | 16 struct wl_seat; |
17 struct wl_shm; | 17 struct wl_shm; |
18 struct wl_shm_pool; | 18 struct wl_shm_pool; |
19 struct wl_surface; | 19 struct wl_surface; |
20 struct xdg_shell; | 20 struct xdg_shell; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 }; | 92 }; |
93 | 93 |
94 struct Deleter { | 94 struct Deleter { |
95 template <typename T> | 95 template <typename T> |
96 void operator()(T* obj) { | 96 void operator()(T* obj) { |
97 ObjectTraits<T>::deleter(obj); | 97 ObjectTraits<T>::deleter(obj); |
98 } | 98 } |
99 }; | 99 }; |
100 | 100 |
101 template <typename T> | 101 template <typename T> |
102 class Object : public scoped_ptr<T, Deleter> { | 102 class Object : public std::unique_ptr<T, Deleter> { |
103 public: | 103 public: |
104 Object() {} | 104 Object() {} |
105 explicit Object(T* obj) : scoped_ptr<T, Deleter>(obj) {} | 105 explicit Object(T* obj) : std::unique_ptr<T, Deleter>(obj) {} |
106 | 106 |
107 uint32_t id() { | 107 uint32_t id() { |
108 return wl_proxy_get_id( | 108 return wl_proxy_get_id( |
109 reinterpret_cast<wl_proxy*>(scoped_ptr<T, Deleter>::get())); | 109 reinterpret_cast<wl_proxy*>(std::unique_ptr<T, Deleter>::get())); |
110 } | 110 } |
111 }; | 111 }; |
112 | 112 |
113 template <typename T> | 113 template <typename T> |
114 wl::Object<T> Bind(wl_registry* registry, uint32_t name, uint32_t version) { | 114 wl::Object<T> Bind(wl_registry* registry, uint32_t name, uint32_t version) { |
115 return wl::Object<T>(static_cast<T*>( | 115 return wl::Object<T>(static_cast<T*>( |
116 wl_registry_bind(registry, name, ObjectTraits<T>::interface, version))); | 116 wl_registry_bind(registry, name, ObjectTraits<T>::interface, version))); |
117 } | 117 } |
118 | 118 |
119 } // namespace wl | 119 } // namespace wl |
120 | 120 |
121 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_OBJECT_H_ | 121 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_OBJECT_H_ |
OLD | NEW |