Index: ui/ozone/platform/drm/host/drm_native_display_delegate.h |
diff --git a/ui/ozone/platform/drm/host/drm_native_display_delegate.h b/ui/ozone/platform/drm/host/drm_native_display_delegate.h |
index d28ea68d346763812299f5a8e7237a88f07be747..f6269bcd96db958affcf3e1f60c46d4befe03014 100644 |
--- a/ui/ozone/platform/drm/host/drm_native_display_delegate.h |
+++ b/ui/ozone/platform/drm/host/drm_native_display_delegate.h |
@@ -6,13 +6,17 @@ |
#define UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ |
#include <map> |
+#include <queue> |
+#include <set> |
#include "base/files/file.h" |
#include "base/files/file_path.h" |
#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_vector.h" |
#include "base/observer_list.h" |
#include "ui/display/types/native_display_delegate.h" |
+#include "ui/events/ozone/device/device_event.h" |
#include "ui/events/ozone/device/device_event_observer.h" |
#include "ui/ozone/public/gpu_platform_support_host.h" |
@@ -76,11 +80,26 @@ class DrmNativeDisplayDelegate : public NativeDisplayDelegate, |
bool OnMessageReceived(const IPC::Message& message) override; |
private: |
+ struct DisplayEvent { |
+ DisplayEvent(DeviceEvent::ActionType action_type, |
+ const base::FilePath& path) |
+ : action_type(action_type), path(path) {} |
+ |
+ DeviceEvent::ActionType action_type; |
+ base::FilePath path; |
+ }; |
+ |
void OnUpdateNativeDisplays( |
const std::vector<DisplaySnapshot_Params>& displays); |
void OnDisplayConfigured(int64_t display_id, bool status); |
- void OnNewGraphicsDevice(const base::FilePath& path, base::File file); |
+ void ProcessEvent(); |
+ |
+ // Called as a result of finishing to process the display hotplug event. These |
+ // are responsible for dequing the event and scheduling the next event. |
+ void OnAddGraphicsDevice(const base::FilePath& path, base::File file); |
+ void OnUpdateGraphicsDevice(); |
+ void OnRemoveGraphicsDevice(const base::FilePath& path); |
void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state); |
void OnHDCPStateUpdated(int64_t display_id, bool status); |
@@ -112,6 +131,18 @@ class DrmNativeDisplayDelegate : public NativeDisplayDelegate, |
std::map<int64_t, SetHDCPStateCallback> set_hdcp_state_callback_map_; |
+ // Used to serialize display event processing. This is done since |
+ // opening/closing DRM devices cannot be done on the UI thread and are handled |
+ // on a worker thread. Thus, we need to queue events in order to process them |
+ // in the correct order. |
+ std::queue<DisplayEvent> event_queue_; |
+ |
+ // True if a display event is currently being processed on a worker thread. |
+ bool task_pending_; |
+ |
+ // Keeps track of all the active DRM devices. |
+ std::set<base::FilePath> drm_devices_; |
+ |
base::WeakPtrFactory<DrmNativeDisplayDelegate> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(DrmNativeDisplayDelegate); |