chromium/ui/events/platform/wayland/wayland_event_watcher.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/events/platform/wayland/wayland_event_watcher.h"

#include <wayland-client-core.h>

#include <cstring>

#include "base/check.h"
#include "base/environment.h"
#include "base/logging.h"
#include "base/nix/xdg_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/current_thread.h"
#include "base/threading/thread.h"
#include "components/crash/core/common/crash_key.h"
#include "third_party/re2/src/re2/re2.h"

namespace ui {

namespace {

// Formats the |message| by removing '@' char followed by any digits until the
// next char. Also removes new line, tab and carriage-return.
void FormatErrorMessage(std::string* message) {}

std::optional<std::string>& GetErrorLog() {}

void wayland_log(const char* fmt, va_list argp) {}

std::string GetWaylandProtocolError(int err, wl_display* display) {}

void RecordCrashKeys(const std::string& error_string) {}

}  // namespace

// A dedicated thread for watching wl_display's file descriptor. The reason why
// watching happens on a separate thread is that the thread mustn't be blocked.
// Otherwise, if Chromium is used with Wayland EGL, a deadlock may happen. The
// deadlock happened when the thread that had been watching the file descriptor
// (it used to be the browser's UI thread) called wl_display_prepare_read, and
// then started to wait until the thread, which was used by the gpu service,
// completed a buffer swap and shutdowned itself (for example, a menu window is
// in the process of closing). However, that gpu thread hanged as it called
// Wayland EGL that also called wl_display_prepare_read internally and started
// to wait until the previous caller of the wl_display_prepare_read (that's by
// the design of the wayland-client library). This situation causes a deadlock
// as the first caller of the wl_display_prepare_read is unable to complete
// reading as it waits for another thread to complete, and that another thread
// is also unable to complete reading as it waits until the first caller reads
// the display's file descriptor. For more details, see the implementation of
// the wl_display_prepare_read in third_party/wayland/src/src/wayland-client.c.
class WaylandEventWatcherThread : public base::Thread {};

WaylandEventWatcher::WaylandEventWatcher(wl_display* display,
                                         wl_event_queue* event_queue,
                                         bool use_threaded_polling)
    :{}

WaylandEventWatcher::~WaylandEventWatcher() {}

void WaylandEventWatcher::SetShutdownCb(
    base::OnceCallback<void()> shutdown_cb) {}

void WaylandEventWatcher::StartProcessingEvents() {}

void WaylandEventWatcher::StartProcessingEventsInternal() {}

void WaylandEventWatcher::StartProcessingEventsThread() {}

void WaylandEventWatcher::RoundTripQueue() {}

void WaylandEventWatcher::StopProcessingEvents() {}

void WaylandEventWatcher::StopProcessingEventsInternal() {}

void WaylandEventWatcher::Flush() {}

bool WaylandEventWatcher::WlDisplayPrepareToRead() {}

void WaylandEventWatcher::WlDisplayReadEvents() {}

void WaylandEventWatcher::WlDisplayCancelRead() {}

void WaylandEventWatcher::WlDisplayDispatchPendingQueue() {}

void WaylandEventWatcher::WlDisplayDispatchPendingQueueInternal(
    base::WaitableEvent* event) {}

void WaylandEventWatcher::WlDisplayCheckForErrors() {}

}  // namespace ui