1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44

media / mojo / services / media_foundation_gpu_info_monitor.h [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_MOJO_SERVICES_MEDIA_FOUNDATION_GPU_INFO_MONITOR_H_
#define MEDIA_MOJO_SERVICES_MEDIA_FOUNDATION_GPU_INFO_MONITOR_H_

#include "base/callback_list.h"
#include "base/functional/callback.h"
#include "base/win/windows_types.h"
#include "gpu/config/gpu_info.h"
#include "media/mojo/services/media_mojo_export.h"

namespace media {

// A singleton class keeps track of GPUInfo and manages notifications.
class MEDIA_MOJO_EXPORT MediaFoundationGpuInfoMonitor {
 public:
  static MediaFoundationGpuInfoMonitor* GetInstance();

  MediaFoundationGpuInfoMonitor();
  MediaFoundationGpuInfoMonitor(const MediaFoundationGpuInfoMonitor&) = delete;
  MediaFoundationGpuInfoMonitor operator=(
      const MediaFoundationGpuInfoMonitor&) = delete;
  ~MediaFoundationGpuInfoMonitor();

  // Updates GpuInfo in `this` and notify observers if needed.
  void UpdateGpuInfo(const gpu::GPUInfo& gpu_info);

  CHROME_LUID gpu_luid() const { return gpu_luid_; }

  // Adds an observer to get notified on GPU LUID changes.
  using LuidObservers = base::RepeatingCallbackList<void(const CHROME_LUID&)>;
  base::CallbackListSubscription AddLuidObserver(
      LuidObservers::CallbackType cb);

 private:
  CHROME_LUID gpu_luid_;
  LuidObservers luid_observers_;
};

}  // namespace media

#endif  // MEDIA_MOJO_SERVICES_MEDIA_FOUNDATION_GPU_INFO_MONITOR_H_