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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/scoped_file.h" 12 #include "base/files/scoped_file.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 16
16 namespace wl { 17 namespace wl {
17 namespace { 18 namespace {
18 19
19 const uint32_t kCompositorVersion = 4; 20 const uint32_t kCompositorVersion = 4;
20 const uint32_t kSeatVersion = 4; 21 const uint32_t kSeatVersion = 4;
21 const uint32_t kXdgShellVersion = 1; 22 const uint32_t kXdgShellVersion = 1;
22 23
23 void DestroyResource(wl_client* client, wl_resource* resource) { 24 void DestroyResource(wl_client* client, wl_resource* resource) {
24 wl_resource_destroy(resource); 25 wl_resource_destroy(resource);
25 } 26 }
26 27
27 // wl_compositor 28 // wl_compositor
28 29
29 void CreateSurface(wl_client* client, wl_resource* resource, uint32_t id) { 30 void CreateSurface(wl_client* client, wl_resource* resource, uint32_t id) {
30 auto compositor = 31 auto compositor =
31 static_cast<MockCompositor*>(wl_resource_get_user_data(resource)); 32 static_cast<MockCompositor*>(wl_resource_get_user_data(resource));
32 wl_resource* surface_resource = wl_resource_create( 33 wl_resource* surface_resource = wl_resource_create(
33 client, &wl_surface_interface, wl_resource_get_version(resource), id); 34 client, &wl_surface_interface, wl_resource_get_version(resource), id);
34 if (!surface_resource) { 35 if (!surface_resource) {
35 wl_client_post_no_memory(client); 36 wl_client_post_no_memory(client);
36 return; 37 return;
37 } 38 }
38 compositor->AddSurface(make_scoped_ptr(new MockSurface(surface_resource))); 39 compositor->AddSurface(base::WrapUnique(new MockSurface(surface_resource)));
39 } 40 }
40 41
41 const struct wl_compositor_interface compositor_impl = { 42 const struct wl_compositor_interface compositor_impl = {
42 &CreateSurface, // create_surface 43 &CreateSurface, // create_surface
43 nullptr, // create_region 44 nullptr, // create_region
44 }; 45 };
45 46
46 // wl_surface 47 // wl_surface
47 48
48 void Attach(wl_client* client, 49 void Attach(wl_client* client,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 auto global = static_cast<Global*>(wl_resource_get_user_data(resource)); 285 auto global = static_cast<Global*>(wl_resource_get_user_data(resource));
285 if (global->resource_ == resource) 286 if (global->resource_ == resource)
286 global->resource_ = nullptr; 287 global->resource_ = nullptr;
287 } 288 }
288 289
289 MockCompositor::MockCompositor() 290 MockCompositor::MockCompositor()
290 : Global(&wl_compositor_interface, &compositor_impl, kCompositorVersion) {} 291 : Global(&wl_compositor_interface, &compositor_impl, kCompositorVersion) {}
291 292
292 MockCompositor::~MockCompositor() {} 293 MockCompositor::~MockCompositor() {}
293 294
294 void MockCompositor::AddSurface(scoped_ptr<MockSurface> surface) { 295 void MockCompositor::AddSurface(std::unique_ptr<MockSurface> surface) {
295 surfaces_.push_back(std::move(surface)); 296 surfaces_.push_back(std::move(surface));
296 } 297 }
297 298
298 MockSeat::MockSeat() : Global(&wl_seat_interface, &seat_impl, kSeatVersion) {} 299 MockSeat::MockSeat() : Global(&wl_seat_interface, &seat_impl, kSeatVersion) {}
299 300
300 MockSeat::~MockSeat() {} 301 MockSeat::~MockSeat() {}
301 302
302 MockXdgShell::MockXdgShell() 303 MockXdgShell::MockXdgShell()
303 : Global(&xdg_shell_interface, &xdg_shell_impl, kXdgShellVersion) {} 304 : Global(&xdg_shell_interface, &xdg_shell_impl, kXdgShellVersion) {}
304 305
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 wl_display_flush_clients(display_.get()); 367 wl_display_flush_clients(display_.get());
367 resume_event_.Signal(); 368 resume_event_.Signal();
368 } 369 }
369 370
370 void FakeServer::DoPause() { 371 void FakeServer::DoPause() {
371 base::RunLoop().RunUntilIdle(); 372 base::RunLoop().RunUntilIdle();
372 pause_event_.Signal(); 373 pause_event_.Signal();
373 resume_event_.Wait(); 374 resume_event_.Wait();
374 } 375 }
375 376
376 scoped_ptr<base::MessagePump> FakeServer::CreateMessagePump() { 377 std::unique_ptr<base::MessagePump> FakeServer::CreateMessagePump() {
377 auto pump = make_scoped_ptr(new base::MessagePumpLibevent); 378 auto pump = base::WrapUnique(new base::MessagePumpLibevent);
378 pump->WatchFileDescriptor(wl_event_loop_get_fd(event_loop_), true, 379 pump->WatchFileDescriptor(wl_event_loop_get_fd(event_loop_), true,
379 base::MessagePumpLibevent::WATCH_READ, &controller_, 380 base::MessagePumpLibevent::WATCH_READ, &controller_,
380 this); 381 this);
381 return std::move(pump); 382 return std::move(pump);
382 } 383 }
383 384
384 void FakeServer::OnFileCanReadWithoutBlocking(int fd) { 385 void FakeServer::OnFileCanReadWithoutBlocking(int fd) {
385 wl_event_loop_dispatch(event_loop_, 0); 386 wl_event_loop_dispatch(event_loop_, 0);
386 wl_display_flush_clients(display_.get()); 387 wl_display_flush_clients(display_.get());
387 } 388 }
388 389
389 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {} 390 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {}
390 391
391 } // namespace wl 392 } // namespace wl
OLDNEW
« no previous file with comments | « ui/ozone/platform/wayland/fake_server.h ('k') | ui/ozone/platform/wayland/ozone_platform_wayland.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698