Changeset 261900 in webkit


Ignore:
Timestamp:
May 19, 2020 6:32:30 PM (4 years ago)
Author:
Simon Fraser
Message:

Use an ObjectIdentifier<> for DisplayLink observer IDs
https://bugs.webkit.org/show_bug.cgi?id=212112

Reviewed by Per Arne Vollan.

Replace unsigned observerID with DisplayLinkObserverID, which is a typesafe ObjectIdentifier<>.

Use PlatformDisplayID in more places.

  • Scripts/webkit/messages.py:
  • Shared/DisplayLinkObserverID.h: Copied from Source/WebKit/UIProcess/mac/DisplayLink.h.
  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::startDisplayLink):
(WebKit::WebProcessPool::stopDisplayLink):

  • UIProcess/WebProcessPool.h:
  • UIProcess/WebProcessProxy.h:
  • UIProcess/WebProcessProxy.messages.in:
  • UIProcess/mac/DisplayLink.cpp:

(WebKit::DisplayLink::addObserver):
(WebKit::DisplayLink::removeObserver):

  • UIProcess/mac/DisplayLink.h:
  • UIProcess/mac/WebProcessProxyMac.mm:

(WebKit::WebProcessProxy::startDisplayLink):
(WebKit::WebProcessProxy::stopDisplayLink):

  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/WebPage/mac/DrawingAreaMac.cpp:

(WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):

Location:
trunk/Source/WebKit
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r261898 r261900  
     12020-05-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Use an ObjectIdentifier<> for DisplayLink observer IDs
     4        https://bugs.webkit.org/show_bug.cgi?id=212112
     5
     6        Reviewed by Per Arne Vollan.
     7
     8        Replace unsigned observerID with DisplayLinkObserverID, which is a typesafe ObjectIdentifier<>.
     9
     10        Use PlatformDisplayID in more places.
     11
     12        * Scripts/webkit/messages.py:
     13        * Shared/DisplayLinkObserverID.h: Copied from Source/WebKit/UIProcess/mac/DisplayLink.h.
     14        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     15        (WebKit::WebProcessPool::startDisplayLink):
     16        (WebKit::WebProcessPool::stopDisplayLink):
     17        * UIProcess/WebProcessPool.h:
     18        * UIProcess/WebProcessProxy.h:
     19        * UIProcess/WebProcessProxy.messages.in:
     20        * UIProcess/mac/DisplayLink.cpp:
     21        (WebKit::DisplayLink::addObserver):
     22        (WebKit::DisplayLink::removeObserver):
     23        * UIProcess/mac/DisplayLink.h:
     24        * UIProcess/mac/WebProcessProxyMac.mm:
     25        (WebKit::WebProcessProxy::startDisplayLink):
     26        (WebKit::WebProcessProxy::stopDisplayLink):
     27        * WebKit.xcodeproj/project.pbxproj:
     28        * WebProcess/WebPage/mac/DrawingAreaMac.cpp:
     29        (WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
     30
    1312020-05-19  Alex Christensen  <achristensen@webkit.org>
    232
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r261776 r261900  
    229229        'WebKit::AudioMediaStreamTrackRendererIdentifier',
    230230        'WebKit::ContentWorldIdentifier',
     231        'WebKit::DisplayLinkObserverID',
    231232        'WebKit::GeolocationIdentifier',
    232233        'WebKit::ImageBufferBackendHandle',
  • trunk/Source/WebKit/Shared/DisplayLinkObserverID.h

    r261899 r261900  
    11/*
    2  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    29 
    30 #include <CoreVideo/CVDisplayLink.h>
    31 #include <WebCore/PlatformScreen.h>
    32 #include <wtf/HashMap.h>
    33 #include <wtf/Lock.h>
    34 
    35 namespace IPC {
    36 class Connection;
    37 }
     28#include <wtf/ObjectIdentifier.h>
    3829
    3930namespace WebKit {
    40    
    41 class DisplayLink {
    42     WTF_MAKE_FAST_ALLOCATED;
    43 public:
    44     explicit DisplayLink(WebCore::PlatformDisplayID);
    45     ~DisplayLink();
    46    
    47     void addObserver(IPC::Connection&, unsigned observerID);
    48     void removeObserver(IPC::Connection&, unsigned observerID);
    49     void removeObservers(IPC::Connection&);
    50     bool hasObservers() const;
    5131
    52     WebCore::PlatformDisplayID displayID() const { return m_displayID; }
    53 
    54 private:
    55     static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data);
    56    
    57     CVDisplayLinkRef m_displayLink { nullptr };
    58     Lock m_observersLock;
    59     HashMap<RefPtr<IPC::Connection>, Vector<unsigned>> m_observers;
    60     WebCore::PlatformDisplayID m_displayID;
    61 };
     32enum DisplayLinkObserverIDType { };
     33using DisplayLinkObserverID = ObjectIdentifier<DisplayLinkObserverIDType>;
    6234
    6335} // namespace WebKit
    64 
    65 #endif
    66 
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r261865 r261900  
    792792
    793793#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    794 void WebProcessPool::startDisplayLink(IPC::Connection& connection, unsigned observerID, uint32_t displayID)
     794void WebProcessPool::startDisplayLink(IPC::Connection& connection, DisplayLinkObserverID observerID, PlatformDisplayID displayID)
    795795{
    796796    for (auto& displayLink : m_displayLinks) {
     
    805805}
    806806
    807 void WebProcessPool::stopDisplayLink(IPC::Connection& connection, unsigned observerID, uint32_t displayID)
     807void WebProcessPool::stopDisplayLink(IPC::Connection& connection, DisplayLinkObserverID observerID, PlatformDisplayID displayID)
    808808{
    809809    for (auto& displayLink : m_displayLinks) {
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r261717 r261900  
    250250
    251251#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    252     void startDisplayLink(IPC::Connection&, unsigned observerID, uint32_t displayID);
    253     void stopDisplayLink(IPC::Connection&, unsigned observerID, uint32_t displayID);
     252    void startDisplayLink(IPC::Connection&, DisplayLinkObserverID, WebCore::PlatformDisplayID);
     253    void stopDisplayLink(IPC::Connection&, DisplayLinkObserverID, WebCore::PlatformDisplayID);
    254254    void stopDisplayLinks(IPC::Connection&);
    255255#endif
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r261288 r261900  
    2929#include "AuxiliaryProcessProxy.h"
    3030#include "BackgroundProcessResponsivenessTimer.h"
     31#include "DisplayLinkObserverID.h"
    3132#include "MessageReceiverMap.h"
    3233#include "NetworkProcessProxy.h"
     
    7576struct SecurityOriginData;
    7677enum class ThirdPartyCookieBlockingMode : uint8_t;
     78using PlatformDisplayID = uint32_t;
    7779}
    7880
     
    282284
    283285#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    284     void startDisplayLink(unsigned observerID, uint32_t displayID);
    285     void stopDisplayLink(unsigned observerID, uint32_t displayID);
     286    void startDisplayLink(DisplayLinkObserverID, WebCore::PlatformDisplayID);
     287    void stopDisplayLink(DisplayLinkObserverID, WebCore::PlatformDisplayID);
    286288#endif
    287289
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in

    r260856 r261900  
    6767
    6868#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    69     StartDisplayLink(unsigned observerID, uint32_t displayID)
    70     StopDisplayLink(unsigned observerID, uint32_t displayID)
     69    StartDisplayLink(WebKit::DisplayLinkObserverID observerID, uint32_t displayID)
     70    StopDisplayLink(WebKit::DisplayLinkObserverID observerID, uint32_t displayID)
    7171#endif
    7272
  • trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp

    r260614 r261900  
    6262}
    6363
    64 void DisplayLink::addObserver(IPC::Connection& connection, unsigned observerID)
     64void DisplayLink::addObserver(IPC::Connection& connection, DisplayLinkObserverID observerID)
    6565{
    6666    ASSERT(RunLoop::isMain());
     
    7070        LockHolder locker(m_observersLock);
    7171        m_observers.ensure(&connection, [] {
    72             return Vector<unsigned> { };
     72            return Vector<DisplayLinkObserverID> { };
    7373        }).iterator->value.append(observerID);
    7474    }
     
    8181}
    8282
    83 void DisplayLink::removeObserver(IPC::Connection& connection, unsigned observerID)
     83void DisplayLink::removeObserver(IPC::Connection& connection, DisplayLinkObserverID observerID)
    8484{
    8585    ASSERT(RunLoop::isMain());
  • trunk/Source/WebKit/UIProcess/mac/DisplayLink.h

    r241232 r261900  
    2828#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    2929
     30#include "DisplayLinkObserverID.h"
    3031#include <CoreVideo/CVDisplayLink.h>
    3132#include <WebCore/PlatformScreen.h>
     
    4546    ~DisplayLink();
    4647   
    47     void addObserver(IPC::Connection&, unsigned observerID);
    48     void removeObserver(IPC::Connection&, unsigned observerID);
     48    void addObserver(IPC::Connection&, DisplayLinkObserverID);
     49    void removeObserver(IPC::Connection&, DisplayLinkObserverID);
    4950    void removeObservers(IPC::Connection&);
    5051    bool hasObservers() const;
     
    5758    CVDisplayLinkRef m_displayLink { nullptr };
    5859    Lock m_observersLock;
    59     HashMap<RefPtr<IPC::Connection>, Vector<unsigned>> m_observers;
     60    HashMap<RefPtr<IPC::Connection>, Vector<DisplayLinkObserverID>> m_observers;
    6061    WebCore::PlatformDisplayID m_displayID;
    6162};
  • trunk/Source/WebKit/UIProcess/mac/WebProcessProxyMac.mm

    r261153 r261900  
    6161
    6262#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    63 void WebProcessProxy::startDisplayLink(unsigned observerID, uint32_t displayID)
     63void WebProcessProxy::startDisplayLink(DisplayLinkObserverID observerID, WebCore::PlatformDisplayID displayID)
    6464{
    6565    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     
    6868}
    6969
    70 void WebProcessProxy::stopDisplayLink(unsigned observerID, uint32_t displayID)
     70void WebProcessProxy::stopDisplayLink(DisplayLinkObserverID observerID, WebCore::PlatformDisplayID displayID)
    7171{
    7272    ASSERT(connection());
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r261658 r261900  
    113113                0F08CF541D63C14000B48DF1 /* WKFormSelectPopover.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */; };
    114114                0F174AA3142A4CB70039250F /* APIGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F174AA2142A4CB60039250F /* APIGeometry.h */; };
     115                0F189CAC24749F2F00E58D81 /* DisplayLinkObserverID.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F189CAB24749F2F00E58D81 /* DisplayLinkObserverID.h */; };
    115116                0F3C725B196F604E00AEDD0C /* WKInspectorHighlightView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */; };
    116117                0F45A331239D89A100294ABF /* WKWebViewPrivateForTestingIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F45A32F239D89A000294ABF /* WKWebViewPrivateForTestingIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    22012202                0F174AA2142A4CB60039250F /* APIGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIGeometry.h; sourceTree = "<group>"; };
    22022203                0F174AA6142AAC610039250F /* WKGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKGeometry.cpp; sourceTree = "<group>"; };
     2204                0F189CAB24749F2F00E58D81 /* DisplayLinkObserverID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayLinkObserverID.h; sourceTree = "<group>"; };
    22032205                0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorHighlightView.mm; sourceTree = "<group>"; };
    22042206                0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKInspectorHighlightView.h; sourceTree = "<group>"; };
     
    60326034                                99036AE823A970870000B06A /* DebuggableInfoData.cpp */,
    60336035                                99036AE723A970870000B06A /* DebuggableInfoData.h */,
     6036                                0F189CAB24749F2F00E58D81 /* DisplayLinkObserverID.h */,
    60346037                                2D7FD190223C730F007887F1 /* DocumentEditingContext.h */,
    60356038                                2D7FD191223C7310007887F1 /* DocumentEditingContext.mm */,
     
    1078310786                                83891B6C1A68C30B0030F386 /* DiagnosticLoggingClient.h in Headers */,
    1078410787                                C18173612058424700DFDA65 /* DisplayLink.h in Headers */,
     10788                                0F189CAC24749F2F00E58D81 /* DisplayLinkObserverID.h in Headers */,
    1078510789                                5C1427021C23F84C00D41183 /* Download.h in Headers */,
    1078610790                                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */,
  • trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp

    r261333 r261900  
    5656    bool hasRequestedRefreshCallback() const override { return m_hasSentMessage; }
    5757
     58    DisplayLinkObserverID m_observerID;
     59    std::unique_ptr<RunLoopObserver> m_runLoopObserver;
    5860    bool m_hasSentMessage { false };
    59     unsigned m_observerID;
    60     static unsigned m_counterID;
    61     std::unique_ptr<RunLoopObserver> m_runLoopObserver;
    6261    bool m_firstCallbackInCurrentRunloop { false };
    6362};
    6463
    65 unsigned DisplayRefreshMonitorMac::m_counterID = 0;
    66 
    6764DisplayRefreshMonitorMac::DisplayRefreshMonitorMac(PlatformDisplayID displayID)
    6865    : DisplayRefreshMonitor(displayID)
    69     , m_observerID(++m_counterID)
     66    , m_observerID(DisplayLinkObserverID::generate())
    7067{
    7168}
Note: See TracChangeset for help on using the changeset viewer.