device_perf_info.cc 787 B

1234567891011121314151617181920212223242526272829303132
  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 "gpu/config/device_perf_info.h"
  5. #include "base/no_destructor.h"
  6. #include "base/synchronization/lock.h"
  7. namespace gpu {
  8. namespace {
  9. // Global instance in browser process.
  10. absl::optional<DevicePerfInfo> g_device_perf_info;
  11. base::Lock& GetLock() {
  12. static base::NoDestructor<base::Lock> lock;
  13. return *lock;
  14. }
  15. } // namespace
  16. absl::optional<DevicePerfInfo> GetDevicePerfInfo() {
  17. base::AutoLock lock(GetLock());
  18. return g_device_perf_info;
  19. }
  20. void SetDevicePerfInfo(const DevicePerfInfo& device_perf_info) {
  21. base::AutoLock lock(GetLock());
  22. g_device_perf_info = device_perf_info;
  23. }
  24. } // namespace gpu