| Index: chrome/browser/chrome_browser_main_extra_parts_exo.cc
|
| diff --git a/chrome/browser/chrome_browser_main_extra_parts_exo.cc b/chrome/browser/chrome_browser_main_extra_parts_exo.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f7af4c3cef14ba2022f35be2c1dd4993d90a7983
|
| --- /dev/null
|
| +++ b/chrome/browser/chrome_browser_main_extra_parts_exo.cc
|
| @@ -0,0 +1,68 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/chrome_browser_main_extra_parts_exo.h"
|
| +
|
| +#include "chrome/browser/ui/ash/ash_util.h"
|
| +#include "components/exo/display.h"
|
| +
|
| +#if defined(ENABLE_WAYLAND_SERVER)
|
| +#include "base/command_line.h"
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| +#include "components/exo/wayland/server.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +#endif
|
| +
|
| +#if defined(ENABLE_WAYLAND_SERVER)
|
| +class ChromeBrowserMainExtraPartsExo::WaylandWatcher
|
| + : public base::MessagePumpLibevent::Watcher {
|
| + public:
|
| + explicit WaylandWatcher(exo::wayland::Server* server) : server_(server) {
|
| + base::MessageLoopForUI::current()->WatchFileDescriptor(
|
| + server_->GetFileDescriptor(),
|
| + true, // persistent
|
| + base::MessagePumpLibevent::WATCH_READ, &controller_, this);
|
| + }
|
| +
|
| + // base::MessagePumpLibevent::Watcher:
|
| + void OnFileCanReadWithoutBlocking(int fd) override {
|
| + server_->Dispatch(base::TimeDelta());
|
| + server_->Flush();
|
| + }
|
| + void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); }
|
| +
|
| + private:
|
| + base::MessagePumpLibevent::FileDescriptorWatcher controller_;
|
| + exo::wayland::Server* const server_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WaylandWatcher);
|
| +};
|
| +#endif
|
| +
|
| +ChromeBrowserMainExtraPartsExo::ChromeBrowserMainExtraPartsExo()
|
| + : display_(new exo::Display) {}
|
| +
|
| +ChromeBrowserMainExtraPartsExo::~ChromeBrowserMainExtraPartsExo() {}
|
| +
|
| +void ChromeBrowserMainExtraPartsExo::PreProfileInit() {
|
| + if (!chrome::ShouldOpenAshOnStartup())
|
| + return;
|
| +
|
| +#if defined(ENABLE_WAYLAND_SERVER)
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableWaylandServer)) {
|
| + wayland_server_ = exo::wayland::Server::Create(display_.get());
|
| + wayland_watcher_ =
|
| + make_scoped_ptr(new WaylandWatcher(wayland_server_.get()));
|
| + }
|
| +#endif
|
| +}
|
| +
|
| +void ChromeBrowserMainExtraPartsExo::PostMainMessageLoopRun() {
|
| +#if defined(ENABLE_WAYLAND_SERVER)
|
| + wayland_watcher_.reset();
|
| + wayland_server_.reset();
|
| +#endif
|
| +}
|
|
|