~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WebKit/UIProcess/GPU/GPUProcessProxy.h

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#pragma once
 
27
 
 
28
#if ENABLE(GPU_PROCESS)
 
29
 
 
30
#include "AuxiliaryProcessProxy.h"
 
31
#include "GPUProcessProxyMessagesReplies.h"
 
32
#include "ProcessLauncher.h"
 
33
#include "ProcessThrottler.h"
 
34
#include "ProcessThrottlerClient.h"
 
35
#include "WebPageProxyIdentifier.h"
 
36
#include "WebProcessProxyMessagesReplies.h"
 
37
#include <memory>
 
38
#include <pal/SessionID.h>
 
39
 
 
40
namespace WebKit {
 
41
 
 
42
class WebProcessProxy;
 
43
class WebsiteDataStore;
 
44
struct GPUProcessCreationParameters;
 
45
 
 
46
class GPUProcessProxy final : public AuxiliaryProcessProxy, private ProcessThrottlerClient, public CanMakeWeakPtr<GPUProcessProxy> {
 
47
    WTF_MAKE_FAST_ALLOCATED;
 
48
    WTF_MAKE_NONCOPYABLE(GPUProcessProxy);
 
49
    friend LazyNeverDestroyed<GPUProcessProxy>;
 
50
public:
 
51
    static GPUProcessProxy& singleton();
 
52
    static GPUProcessProxy* singletonIfCreated() { return m_singleton; }
 
53
 
 
54
    void getGPUProcessConnection(WebProcessProxy&, Messages::WebProcessProxy::GetGPUProcessConnectionDelayedReply&&);
 
55
 
 
56
    ProcessThrottler& throttler() { return m_throttler; }
 
57
    void updateProcessAssertion();
 
58
 
 
59
    // ProcessThrottlerClient
 
60
    void sendProcessDidResume() final { }
 
61
 
 
62
#if ENABLE(MEDIA_STREAM)
 
63
    void setUseMockCaptureDevices(bool);
 
64
#endif
 
65
 
 
66
    void removeSession(PAL::SessionID);
 
67
 
 
68
private:
 
69
    explicit GPUProcessProxy();
 
70
    ~GPUProcessProxy();
 
71
 
 
72
    void addSession(const WebsiteDataStore&);
 
73
 
 
74
    // AuxiliaryProcessProxy
 
75
    ASCIILiteral processName() const final { return "GPU"_s; }
 
76
 
 
77
    void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
 
78
    void connectionWillOpen(IPC::Connection&) override;
 
79
    void processWillShutDown(IPC::Connection&) override;
 
80
 
 
81
    void gpuProcessCrashed();
 
82
 
 
83
    // ProcessThrottlerClient
 
84
    void sendPrepareToSuspend(IsSuspensionImminent, CompletionHandler<void()>&&) final { }
 
85
    void didSetAssertionState(AssertionState) final { }
 
86
 
 
87
    // ProcessLauncher::Client
 
88
    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
 
89
 
 
90
    typedef uint64_t ConnectionRequestIdentifier;
 
91
    void openGPUProcessConnection(ConnectionRequestIdentifier, WebProcessProxy&);
 
92
 
 
93
    // IPC::Connection::Client
 
94
    void didClose(IPC::Connection&) override;
 
95
    void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
 
96
 
 
97
    static GPUProcessProxy* m_singleton;
 
98
 
 
99
    struct ConnectionRequest {
 
100
        WeakPtr<WebProcessProxy> webProcess;
 
101
        Messages::WebProcessProxy::GetGPUProcessConnectionDelayedReply reply;
 
102
    };
 
103
    ConnectionRequestIdentifier m_connectionRequestIdentifier { 0 };
 
104
    HashMap<ConnectionRequestIdentifier, ConnectionRequest> m_connectionRequests;
 
105
 
 
106
    ProcessThrottler m_throttler;
 
107
    ProcessThrottler::ActivityVariant m_activityFromWebProcesses;
 
108
#if ENABLE(MEDIA_STREAM)
 
109
    bool m_useMockCaptureDevices { false };
 
110
#endif
 
111
    HashSet<PAL::SessionID> m_sessionIDs;
 
112
};
 
113
 
 
114
} // namespace WebKit
 
115
 
 
116
#endif // ENABLE(GPU_PROCESS)