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

Unified Diff: chromeos/system/devicemode.cc

Issue 2585633004: ozone: Allow ozone evdev/kvm features to be enabled without running on ChromeOS. (Closed)
Patch Set: only add //chromeos to deps if is_chromeos Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/system/devicemode.cc
diff --git a/chromeos/system/devicemode.cc b/chromeos/system/devicemode.cc
new file mode 100644
index 0000000000000000000000000000000000000000..74e96d943a39a08fd5bee4aa023d43a1f2ac8f25
--- /dev/null
+++ b/chromeos/system/devicemode.cc
@@ -0,0 +1,45 @@
+// Copyright 2017 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 "chromeos/system/devicemode.h"
+
+#include "base/command_line.h"
+#include "base/lazy_instance.h"
+#include "base/sys_info.h"
+#include "chromeos/chromeos_switches.h"
+
+namespace chromeos {
+namespace {
+
+class ChromeOSDeviceMode {
+ public:
+ ChromeOSDeviceMode() {
+ // Running as system compositor by default when running on ChromeOS.
+ is_running_as_system_compositor_ = base::SysInfo::IsRunningOnChromeOS();
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableSystemCompositorMode))
+ is_running_as_system_compositor_ = true;
+ if (command_line->HasSwitch(switches::kDisableSystemCompositorMode))
+ is_running_as_system_compositor_ = false;
+ }
+
+ bool is_running_as_system_compositor() const {
+ return is_running_as_system_compositor_;
+ }
+
+ private:
+ bool is_running_as_system_compositor_;
+};
+
+base::LazyInstance<ChromeOSDeviceMode>::Leaky g_chrome_os_device_mode =
+ LAZY_INSTANCE_INITIALIZER;
oshima 2017/01/05 22:43:57 Do you need lazy instance? Since this never chang
reveman 2017/01/06 08:15:14 Done. I assume it's OK to rely on the compiler's t
oshima 2017/01/09 19:09:12 CommandLine isn't thread safe, so the original cod
reveman 2017/01/09 22:51:50 CommandLine::HasSwitch is const so should be threa
+
+} // namespace
+
+bool IsRunningAsSystemCompositor() {
+ return g_chrome_os_device_mode.Get().is_running_as_system_compositor();
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698