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

Side by Side Diff: ui/ozone/platform/wayland/fake_server.cc

Issue 2713373002: Fix 'auto variable type must not deduce to a raw pointer type' errors in Ozone/Wayland code (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/demo/ozone_demo.cc ('k') | ui/ozone/platform/wayland/wayland_keyboard_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/ozone/platform/wayland/fake_server.h" 5 #include "ui/ozone/platform/wayland/fake_server.h"
6 6
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 #include <wayland-server.h> 8 #include <wayland-server.h>
9 #include <xdg-shell-unstable-v5-server-protocol.h> 9 #include <xdg-shell-unstable-v5-server-protocol.h>
10 10
(...skipping 11 matching lines...) Expand all
22 const uint32_t kSeatVersion = 4; 22 const uint32_t kSeatVersion = 4;
23 const uint32_t kXdgShellVersion = 1; 23 const uint32_t kXdgShellVersion = 1;
24 24
25 void DestroyResource(wl_client* client, wl_resource* resource) { 25 void DestroyResource(wl_client* client, wl_resource* resource) {
26 wl_resource_destroy(resource); 26 wl_resource_destroy(resource);
27 } 27 }
28 28
29 // wl_compositor 29 // wl_compositor
30 30
31 void CreateSurface(wl_client* client, wl_resource* resource, uint32_t id) { 31 void CreateSurface(wl_client* client, wl_resource* resource, uint32_t id) {
32 auto compositor = 32 auto* compositor =
33 static_cast<MockCompositor*>(wl_resource_get_user_data(resource)); 33 static_cast<MockCompositor*>(wl_resource_get_user_data(resource));
34 wl_resource* surface_resource = wl_resource_create( 34 wl_resource* surface_resource = wl_resource_create(
35 client, &wl_surface_interface, wl_resource_get_version(resource), id); 35 client, &wl_surface_interface, wl_resource_get_version(resource), id);
36 if (!surface_resource) { 36 if (!surface_resource) {
37 wl_client_post_no_memory(client); 37 wl_client_post_no_memory(client);
38 return; 38 return;
39 } 39 }
40 compositor->AddSurface(base::MakeUnique<MockSurface>(surface_resource)); 40 compositor->AddSurface(base::MakeUnique<MockSurface>(surface_resource));
41 } 41 }
42 42
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 wl_resource* resource, 89 wl_resource* resource,
90 int32_t version) { 90 int32_t version) {
91 static_cast<MockXdgShell*>(wl_resource_get_user_data(resource)) 91 static_cast<MockXdgShell*>(wl_resource_get_user_data(resource))
92 ->UseUnstableVersion(version); 92 ->UseUnstableVersion(version);
93 } 93 }
94 94
95 void GetXdgSurface(wl_client* client, 95 void GetXdgSurface(wl_client* client,
96 wl_resource* resource, 96 wl_resource* resource,
97 uint32_t id, 97 uint32_t id,
98 wl_resource* surface_resource) { 98 wl_resource* surface_resource) {
99 auto surface = 99 auto* surface =
100 static_cast<MockSurface*>(wl_resource_get_user_data(surface_resource)); 100 static_cast<MockSurface*>(wl_resource_get_user_data(surface_resource));
101 if (surface->xdg_surface) { 101 if (surface->xdg_surface) {
102 wl_resource_post_error(resource, XDG_SHELL_ERROR_ROLE, 102 wl_resource_post_error(resource, XDG_SHELL_ERROR_ROLE,
103 "surface already has a role"); 103 "surface already has a role");
104 return; 104 return;
105 } 105 }
106 wl_resource* xdg_surface_resource = wl_resource_create( 106 wl_resource* xdg_surface_resource = wl_resource_create(
107 client, &xdg_surface_interface, wl_resource_get_version(resource), id); 107 client, &xdg_surface_interface, wl_resource_get_version(resource), id);
108 if (!xdg_surface_resource) { 108 if (!xdg_surface_resource) {
109 wl_client_post_no_memory(client); 109 wl_client_post_no_memory(client);
(...skipping 10 matching lines...) Expand all
120 &DestroyResource, // destroy 120 &DestroyResource, // destroy
121 &UseUnstableVersion, // use_unstable_version 121 &UseUnstableVersion, // use_unstable_version
122 &GetXdgSurface, // get_xdg_surface 122 &GetXdgSurface, // get_xdg_surface
123 nullptr, // get_xdg_popup 123 nullptr, // get_xdg_popup
124 &Pong, // pong 124 &Pong, // pong
125 }; 125 };
126 126
127 // wl_seat 127 // wl_seat
128 128
129 void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) { 129 void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) {
130 auto seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource)); 130 auto* seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
131 wl_resource* pointer_resource = wl_resource_create( 131 wl_resource* pointer_resource = wl_resource_create(
132 client, &wl_pointer_interface, wl_resource_get_version(resource), id); 132 client, &wl_pointer_interface, wl_resource_get_version(resource), id);
133 if (!pointer_resource) { 133 if (!pointer_resource) {
134 wl_client_post_no_memory(client); 134 wl_client_post_no_memory(client);
135 return; 135 return;
136 } 136 }
137 seat->pointer.reset(new MockPointer(pointer_resource)); 137 seat->pointer.reset(new MockPointer(pointer_resource));
138 } 138 }
139 139
140 void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) { 140 void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) {
141 auto seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource)); 141 auto* seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
142 wl_resource* keyboard_resource = wl_resource_create( 142 wl_resource* keyboard_resource = wl_resource_create(
143 client, &wl_keyboard_interface, wl_resource_get_version(resource), id); 143 client, &wl_keyboard_interface, wl_resource_get_version(resource), id);
144 if (!keyboard_resource) { 144 if (!keyboard_resource) {
145 wl_client_post_no_memory(client); 145 wl_client_post_no_memory(client);
146 return; 146 return;
147 } 147 }
148 seat->keyboard.reset(new MockKeyboard(keyboard_resource)); 148 seat->keyboard.reset(new MockKeyboard(keyboard_resource));
149 } 149 }
150 150
151 const struct wl_seat_interface seat_impl = { 151 const struct wl_seat_interface seat_impl = {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 ServerObject::ServerObject(wl_resource* resource) : resource_(resource) {} 222 ServerObject::ServerObject(wl_resource* resource) : resource_(resource) {}
223 223
224 ServerObject::~ServerObject() { 224 ServerObject::~ServerObject() {
225 if (resource_) 225 if (resource_)
226 wl_resource_destroy(resource_); 226 wl_resource_destroy(resource_);
227 } 227 }
228 228
229 // static 229 // static
230 void ServerObject::OnResourceDestroyed(wl_resource* resource) { 230 void ServerObject::OnResourceDestroyed(wl_resource* resource) {
231 auto obj = static_cast<ServerObject*>(wl_resource_get_user_data(resource)); 231 auto* obj = static_cast<ServerObject*>(wl_resource_get_user_data(resource));
232 obj->resource_ = nullptr; 232 obj->resource_ = nullptr;
233 } 233 }
234 234
235 MockXdgSurface::MockXdgSurface(wl_resource* resource) : ServerObject(resource) { 235 MockXdgSurface::MockXdgSurface(wl_resource* resource) : ServerObject(resource) {
236 wl_resource_set_implementation(resource, &xdg_surface_impl, this, 236 wl_resource_set_implementation(resource, &xdg_surface_impl, this,
237 &ServerObject::OnResourceDestroyed); 237 &ServerObject::OnResourceDestroyed);
238 } 238 }
239 239
240 MockXdgSurface::~MockXdgSurface() {} 240 MockXdgSurface::~MockXdgSurface() {}
241 241
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool Global::Initialize(wl_display* display) { 285 bool Global::Initialize(wl_display* display) {
286 global_.reset(wl_global_create(display, interface_, version_, this, &Bind)); 286 global_.reset(wl_global_create(display, interface_, version_, this, &Bind));
287 return global_ != nullptr; 287 return global_ != nullptr;
288 } 288 }
289 289
290 // static 290 // static
291 void Global::Bind(wl_client* client, 291 void Global::Bind(wl_client* client,
292 void* data, 292 void* data,
293 uint32_t version, 293 uint32_t version,
294 uint32_t id) { 294 uint32_t id) {
295 auto global = static_cast<Global*>(data); 295 auto* global = static_cast<Global*>(data);
296 wl_resource* resource = wl_resource_create( 296 wl_resource* resource = wl_resource_create(
297 client, global->interface_, std::min(version, global->version_), id); 297 client, global->interface_, std::min(version, global->version_), id);
298 if (!resource) { 298 if (!resource) {
299 wl_client_post_no_memory(client); 299 wl_client_post_no_memory(client);
300 return; 300 return;
301 } 301 }
302 if (!global->resource_) 302 if (!global->resource_)
303 global->resource_ = resource; 303 global->resource_ = resource;
304 wl_resource_set_implementation(resource, global->implementation_, global, 304 wl_resource_set_implementation(resource, global->implementation_, global,
305 &Global::OnResourceDestroyed); 305 &Global::OnResourceDestroyed);
306 global->OnBind(); 306 global->OnBind();
307 } 307 }
308 308
309 // static 309 // static
310 void Global::OnResourceDestroyed(wl_resource* resource) { 310 void Global::OnResourceDestroyed(wl_resource* resource) {
311 auto global = static_cast<Global*>(wl_resource_get_user_data(resource)); 311 auto* global = static_cast<Global*>(wl_resource_get_user_data(resource));
312 if (global->resource_ == resource) 312 if (global->resource_ == resource)
313 global->resource_ = nullptr; 313 global->resource_ = nullptr;
314 } 314 }
315 315
316 MockCompositor::MockCompositor() 316 MockCompositor::MockCompositor()
317 : Global(&wl_compositor_interface, &compositor_impl, kCompositorVersion) {} 317 : Global(&wl_compositor_interface, &compositor_impl, kCompositorVersion) {}
318 318
319 MockCompositor::~MockCompositor() {} 319 MockCompositor::~MockCompositor() {}
320 320
321 void MockCompositor::AddSurface(std::unique_ptr<MockSurface> surface) { 321 void MockCompositor::AddSurface(std::unique_ptr<MockSurface> surface) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 } 429 }
430 430
431 void FakeServer::OnFileCanReadWithoutBlocking(int fd) { 431 void FakeServer::OnFileCanReadWithoutBlocking(int fd) {
432 wl_event_loop_dispatch(event_loop_, 0); 432 wl_event_loop_dispatch(event_loop_, 0);
433 wl_display_flush_clients(display_.get()); 433 wl_display_flush_clients(display_.get());
434 } 434 }
435 435
436 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {} 436 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {}
437 437
438 } // namespace wl 438 } // namespace wl
OLDNEW
« no previous file with comments | « ui/ozone/demo/ozone_demo.cc ('k') | ui/ozone/platform/wayland/wayland_keyboard_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698