Run clang-modernize and let it add a bunch of missing overrides in WebCore/inspector
[WebKit-https.git] / Source / WebCore / inspector / InspectorWorkerAgent.h
1 /*
2  * Copyright (C) 2011 Google 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 are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef InspectorWorkerAgent_h
32 #define InspectorWorkerAgent_h
33
34 #include "InspectorWebAgentBase.h"
35 #include "InspectorWebBackendDispatchers.h"
36 #include <wtf/Forward.h>
37 #include <wtf/HashMap.h>
38
39 namespace Inspector {
40 class InspectorObject;
41 class InspectorWorkerFrontendDispatcher;
42 }
43
44 namespace WebCore {
45 class InstrumentingAgents;
46 class URL;
47 class WorkerGlobalScopeProxy;
48
49 typedef String ErrorString;
50
51 class InspectorWorkerAgent : public InspectorAgentBase, public Inspector::InspectorWorkerBackendDispatcherHandler {
52 public:
53     explicit InspectorWorkerAgent(InstrumentingAgents*);
54     ~InspectorWorkerAgent();
55
56     virtual void didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel*, Inspector::InspectorBackendDispatcher*) override;
57     virtual void willDestroyFrontendAndBackend() override;
58
59     // Called from InspectorInstrumentation
60     bool shouldPauseDedicatedWorkerOnStart() const;
61     void didStartWorkerGlobalScope(WorkerGlobalScopeProxy*, const URL&);
62     void workerGlobalScopeTerminated(WorkerGlobalScopeProxy*);
63
64     // Called from InspectorBackendDispatcher
65     virtual void enable(ErrorString*) override;
66     virtual void disable(ErrorString*) override;
67     virtual void canInspectWorkers(ErrorString*, bool*) override;
68     virtual void connectToWorker(ErrorString*, int workerId) override;
69     virtual void disconnectFromWorker(ErrorString*, int workerId) override;
70     virtual void sendMessageToWorker(ErrorString*, int workerId, const RefPtr<Inspector::InspectorObject>& message) override;
71     virtual void setAutoconnectToWorkers(ErrorString*, bool value) override;
72
73 private:
74     void createWorkerFrontendChannelsForExistingWorkers();
75     void createWorkerFrontendChannel(WorkerGlobalScopeProxy*, const String& url);
76     void destroyWorkerFrontendChannels();
77
78     std::unique_ptr<Inspector::InspectorWorkerFrontendDispatcher> m_frontendDispatcher;
79     RefPtr<Inspector::InspectorWorkerBackendDispatcher> m_backendDispatcher;
80     bool m_enabled;
81     bool m_shouldPauseDedicatedWorkerOnStart;
82
83     class WorkerFrontendChannel;
84     typedef HashMap<int, WorkerFrontendChannel*> WorkerChannels;
85     WorkerChannels m_idToChannel;
86     typedef HashMap<WorkerGlobalScopeProxy*, String> DedicatedWorkers;
87     DedicatedWorkers m_dedicatedWorkers;
88 };
89
90 } // namespace WebCore
91
92 #endif // !defined(InspectorWorkerAgent_h)