Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chromeos/system/devicemode.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/lazy_instance.h" | |
| 9 #include "base/sys_info.h" | |
| 10 #include "chromeos/chromeos_switches.h" | |
| 11 | |
| 12 namespace chromeos { | |
| 13 namespace { | |
| 14 | |
| 15 class ChromeOSDeviceMode { | |
| 16 public: | |
| 17 ChromeOSDeviceMode() { | |
| 18 // Running as system compositor by default when running on ChromeOS. | |
| 19 is_running_as_system_compositor_ = base::SysInfo::IsRunningOnChromeOS(); | |
| 20 | |
| 21 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 22 if (command_line->HasSwitch(switches::kEnableSystemCompositorMode)) | |
| 23 is_running_as_system_compositor_ = true; | |
| 24 if (command_line->HasSwitch(switches::kDisableSystemCompositorMode)) | |
| 25 is_running_as_system_compositor_ = false; | |
| 26 } | |
| 27 | |
| 28 bool is_running_as_system_compositor() const { | |
| 29 return is_running_as_system_compositor_; | |
| 30 } | |
| 31 | |
| 32 private: | |
| 33 bool is_running_as_system_compositor_; | |
| 34 }; | |
| 35 | |
| 36 base::LazyInstance<ChromeOSDeviceMode>::Leaky g_chrome_os_device_mode = | |
| 37 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
| |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 bool IsRunningAsSystemCompositor() { | |
| 42 return g_chrome_os_device_mode.Get().is_running_as_system_compositor(); | |
| 43 } | |
| 44 | |
| 45 } // namespace chromeos | |
| OLD | NEW |