Remove "virtual" from all lines that have both "virtual" and "override".
[WebKit-https.git] / Source / WebCore / inspector / InspectorNetworkAgent.h
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  * Copyright (C) 2015 Apple Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef InspectorNetworkAgent_h
33 #define InspectorNetworkAgent_h
34
35 #include "InspectorWebAgentBase.h"
36 #include <inspector/InspectorBackendDispatchers.h>
37 #include <inspector/InspectorFrontendDispatchers.h>
38 #include <wtf/HashSet.h>
39 #include <wtf/text/WTFString.h>
40
41 namespace Inspector {
42 class InspectorObject;
43 }
44
45 namespace WebCore {
46
47 class CachedResource;
48 class Document;
49 class DocumentLoader;
50 class InspectorPageAgent;
51 class NetworkResourcesData;
52 class ResourceError;
53 class ResourceLoader;
54 class ResourceRequest;
55 class ResourceResponse;
56 class ThreadableLoaderClient;
57 class URL;
58
59 #if ENABLE(WEB_SOCKETS)
60 struct WebSocketFrame;
61 #endif
62
63 typedef String ErrorString;
64
65 class InspectorNetworkAgent final : public InspectorAgentBase, public Inspector::NetworkBackendDispatcherHandler {
66     WTF_MAKE_FAST_ALLOCATED;
67 public:
68     InspectorNetworkAgent(WebAgentContext&, InspectorPageAgent*);
69     virtual ~InspectorNetworkAgent();
70
71     void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
72     void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
73
74     // InspectorInstrumentation callbacks.
75     void willRecalculateStyle();
76     void didRecalculateStyle();
77     void willSendRequest(unsigned long identifier, DocumentLoader&, ResourceRequest&, const ResourceResponse& redirectResponse);
78     void markResourceAsCached(unsigned long identifier);
79     void didReceiveResponse(unsigned long identifier, DocumentLoader&, const ResourceResponse&, ResourceLoader*);
80     void didReceiveData(unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
81     void didFinishLoading(unsigned long identifier, DocumentLoader&, double finishTime);
82     void didFailLoading(unsigned long identifier, DocumentLoader&, const ResourceError&);
83     void didLoadResourceFromMemoryCache(DocumentLoader&, CachedResource&);
84     void didFinishXHRLoading(ThreadableLoaderClient*, unsigned long identifier, const String& sourceString);
85     void didReceiveXHRResponse(unsigned long identifier);
86     void willLoadXHRSynchronously();
87     void didLoadXHRSynchronously();
88     void didReceiveScriptResponse(unsigned long identifier);
89     void willDestroyCachedResource(CachedResource&);
90 #if ENABLE(WEB_SOCKETS)
91     void didCreateWebSocket(unsigned long identifier, const URL& requestURL);
92     void willSendWebSocketHandshakeRequest(unsigned long identifier, const ResourceRequest&);
93     void didReceiveWebSocketHandshakeResponse(unsigned long identifier, const ResourceResponse&);
94     void didCloseWebSocket(unsigned long identifier);
95     void didReceiveWebSocketFrame(unsigned long identifier, const WebSocketFrame&);
96     void didSendWebSocketFrame(unsigned long identifier, const WebSocketFrame&);
97     void didReceiveWebSocketFrameError(unsigned long identifier, const String&);
98 #endif
99     void mainFrameNavigated(DocumentLoader&);
100     void setInitialScriptContent(unsigned long identifier, const String& sourceString);
101     void didScheduleStyleRecalculation(Document&);
102
103     RefPtr<Inspector::Protocol::Network::Initiator> buildInitiatorObject(Document*);
104
105     // Called from frontend.
106     void enable(ErrorString&) override;
107     void disable(ErrorString&) override;
108     void setExtraHTTPHeaders(ErrorString&, const Inspector::InspectorObject& headers) override;
109     void getResponseBody(ErrorString&, const String& requestId, String* content, bool* base64Encoded) override;
110     void setCacheDisabled(ErrorString&, bool cacheDisabled) override;
111     void loadResource(ErrorString&, const String& frameId, const String& url, Ref<LoadResourceCallback>&&) override;
112
113 private:
114     void enable();
115
116     double timestamp();
117
118     std::unique_ptr<Inspector::NetworkFrontendDispatcher> m_frontendDispatcher;
119     RefPtr<Inspector::NetworkBackendDispatcher> m_backendDispatcher;
120     InspectorPageAgent* m_pageAgent { nullptr };
121
122     // FIXME: InspectorNetworkAgent should not be aware of style recalculation.
123     RefPtr<Inspector::Protocol::Network::Initiator> m_styleRecalculationInitiator;
124     bool m_isRecalculatingStyle { false };
125
126     std::unique_ptr<NetworkResourcesData> m_resourcesData;
127     bool m_enabled { false };
128     bool m_cacheDisabled { false };
129     bool m_loadingXHRSynchronously { false };
130     HashMap<String, String> m_extraRequestHeaders;
131     HashSet<unsigned long> m_hiddenRequestIdentifiers;
132 };
133
134 } // namespace WebCore
135
136 #endif // !defined(InspectorNetworkAgent_h)