screen_backlight.cc 720 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2020 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. #include "ash/public/cpp/screen_backlight.h"
  5. #include "base/check_op.h"
  6. namespace ash {
  7. namespace {
  8. ScreenBacklight* g_instance = nullptr;
  9. }
  10. template <>
  11. ScreenBacklight*&
  12. ScreenBacklight::ScopedResetterForTest::GetGlobalInstanceHolder() {
  13. return g_instance;
  14. }
  15. // static
  16. ScreenBacklight* ScreenBacklight::Get() {
  17. return g_instance;
  18. }
  19. ScreenBacklight::ScreenBacklight() {
  20. DCHECK_EQ(nullptr, g_instance);
  21. g_instance = this;
  22. }
  23. ScreenBacklight::~ScreenBacklight() {
  24. DCHECK_EQ(this, g_instance);
  25. g_instance = nullptr;
  26. }
  27. } // namespace ash