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

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

Issue 2431123003: Revert of Use FileDescriptorWatcher in wl::FakeServer. (patchset #1 id:1 of https://codereview.chro… (Closed)
Patch Set: Created 4 years, 2 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/platform/wayland/fake_server.h ('k') | no next file » | 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return false; 360 return false;
361 if (!xdg_shell_.Initialize(display_.get())) 361 if (!xdg_shell_.Initialize(display_.get()))
362 return false; 362 return false;
363 363
364 client_ = wl_client_create(display_.get(), server_fd.get()); 364 client_ = wl_client_create(display_.get(), server_fd.get());
365 if (!client_) 365 if (!client_)
366 return false; 366 return false;
367 (void)server_fd.release(); 367 (void)server_fd.release();
368 368
369 base::Thread::Options options; 369 base::Thread::Options options;
370 options.message_loop_type = MessageLoop::TYPE_IO; 370 options.message_pump_factory =
371 base::Bind(&FakeServer::CreateMessagePump, base::Unretained(this));
371 if (!base::Thread::StartWithOptions(options)) 372 if (!base::Thread::StartWithOptions(options))
372 return false; 373 return false;
373 task_runner()->PostTask(FROM_HERE,
374 base::Bind(&FakeServer::StartWatchingFileDescriptor,
375 base::Unretained(this)));
376 374
377 setenv("WAYLAND_SOCKET", base::UintToString(client_fd.release()).c_str(), 1); 375 setenv("WAYLAND_SOCKET", base::UintToString(client_fd.release()).c_str(), 1);
378 376
379 return true; 377 return true;
380 } 378 }
381 379
382 void FakeServer::Pause() { 380 void FakeServer::Pause() {
383 task_runner()->PostTask( 381 task_runner()->PostTask(
384 FROM_HERE, base::Bind(&FakeServer::DoPause, base::Unretained(this))); 382 FROM_HERE, base::Bind(&FakeServer::DoPause, base::Unretained(this)));
385 pause_event_.Wait(); 383 pause_event_.Wait();
386 } 384 }
387 385
388 void FakeServer::Resume() { 386 void FakeServer::Resume() {
389 if (display_) 387 if (display_)
390 wl_display_flush_clients(display_.get()); 388 wl_display_flush_clients(display_.get());
391 resume_event_.Signal(); 389 resume_event_.Signal();
392 } 390 }
393 391
394 void FakeServer::DoPause() { 392 void FakeServer::DoPause() {
395 base::RunLoop().RunUntilIdle(); 393 base::RunLoop().RunUntilIdle();
396 pause_event_.Signal(); 394 pause_event_.Signal();
397 resume_event_.Wait(); 395 resume_event_.Wait();
398 } 396 }
399 397
400 void FakeServer::StartWatchingFileDescriptor() { 398 std::unique_ptr<base::MessagePump> FakeServer::CreateMessagePump() {
401 controller_ = base::FileDescriptorWatcher::WatchReadable( 399 auto pump = base::WrapUnique(new base::MessagePumpLibevent);
402 wl_event_loop_get_fd(event_loop_), 400 pump->WatchFileDescriptor(wl_event_loop_get_fd(event_loop_), true,
403 base::Bind(&FakeServer::OnFileCanReadWithoutBlocking, 401 base::MessagePumpLibevent::WATCH_READ, &controller_,
404 base::Unretained(this))); 402 this);
403 return std::move(pump);
405 } 404 }
406 405
407 void FakeServer::OnFileCanReadWithoutBlocking() { 406 void FakeServer::OnFileCanReadWithoutBlocking(int fd) {
408 wl_event_loop_dispatch(event_loop_, 0); 407 wl_event_loop_dispatch(event_loop_, 0);
409 wl_display_flush_clients(display_.get()); 408 wl_display_flush_clients(display_.get());
410 } 409 }
411 410
411 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {}
412 412
413 } // namespace wl 413 } // namespace wl
OLDNEW
« no previous file with comments | « ui/ozone/platform/wayland/fake_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698