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

Unified Diff: chrome/browser/chrome_browser_main_extra_parts_exo.cc

Issue 1412093006: components: Add Exosphere component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove some ifdefs Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..9cecfbd30bccbe8f276489eef488d06268d68c34
--- /dev/null
+++ b/chrome/browser/chrome_browser_main_extra_parts_exo.cc
@@ -0,0 +1,59 @@
+// 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 "base/command_line.h"
+#include "base/message_loop/message_loop.h"
+#include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/common/chrome_switches.h"
+#include "components/exo/display.h"
+#include "components/exo/wayland/server.h"
+#include "content/public/browser/browser_thread.h"
+
+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);
+};
+
+ChromeBrowserMainExtraPartsExo::ChromeBrowserMainExtraPartsExo()
+ : display_(new exo::Display) {}
+
+ChromeBrowserMainExtraPartsExo::~ChromeBrowserMainExtraPartsExo() {}
+
+void ChromeBrowserMainExtraPartsExo::PreProfileInit() {
+ if (!chrome::ShouldOpenAshOnStartup())
+ return;
+
+ 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()));
+ }
+}
+
+void ChromeBrowserMainExtraPartsExo::PostMainMessageLoopRun() {
+ wayland_watcher_.reset();
+ wayland_server_.reset();
+}
« no previous file with comments | « chrome/browser/chrome_browser_main_extra_parts_exo.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698