2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef InspectorResourceAgent_h
32 #define InspectorResourceAgent_h
34 #include "InspectorFrontend.h"
35 #include "PlatformString.h"
37 #include <wtf/PassRefPtr.h>
38 #include <wtf/Vector.h>
53 class InspectorClient;
54 class InspectorFrontend;
55 class InspectorObject;
56 class InspectorPageAgent;
58 class InstrumentingAgents;
60 class NetworkResourcesData;
63 class ResourceRequest;
64 class ResourceResponse;
67 #if ENABLE(WEB_SOCKETS)
68 class WebSocketHandshakeRequest;
69 class WebSocketHandshakeResponse;
72 typedef String ErrorString;
74 class InspectorResourceAgent : public RefCounted<InspectorResourceAgent> {
76 static PassRefPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* state)
78 return adoptRef(new InspectorResourceAgent(instrumentingAgents, pageAgent, client, state));
81 void setFrontend(InspectorFrontend*);
85 static PassRefPtr<InspectorResourceAgent> restore(Page*, InspectorState*, InspectorFrontend*);
87 ~InspectorResourceAgent();
89 void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
90 void markResourceAsCached(unsigned long identifier);
91 void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&);
92 void didReceiveData(unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
93 void didFinishLoading(unsigned long identifier, DocumentLoader*, double finishTime);
94 void didFailLoading(unsigned long identifier, DocumentLoader*, const ResourceError&);
95 void didLoadResourceFromMemoryCache(DocumentLoader*, CachedResource*);
96 void mainFrameNavigated(DocumentLoader*);
97 void setInitialScriptContent(unsigned long identifier, const String& sourceString);
98 void didReceiveScriptResponse(unsigned long identifier);
99 void setInitialXHRContent(unsigned long identifier, const String& sourceString);
100 void didReceiveXHRResponse(unsigned long identifier);
101 void willLoadXHRSynchronously();
102 void didLoadXHRSynchronously();
104 void applyUserAgentOverride(String* userAgent);
106 // FIXME: InspectorResourceAgent should now be aware of style recalculation.
107 void willRecalculateStyle();
108 void didRecalculateStyle();
109 void didScheduleStyleRecalculation(Document*);
111 PassRefPtr<InspectorObject> buildInitiatorObject(Document*);
113 #if ENABLE(WEB_SOCKETS)
114 void didCreateWebSocket(unsigned long identifier, const KURL& requestURL);
115 void willSendWebSocketHandshakeRequest(unsigned long identifier, const WebSocketHandshakeRequest&);
116 void didReceiveWebSocketHandshakeResponse(unsigned long identifier, const WebSocketHandshakeResponse&);
117 void didCloseWebSocket(unsigned long identifier);
120 // called from Internals for layout test purposes.
121 void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
123 // Called from frontend
124 void enable(ErrorString*);
125 void disable(ErrorString*);
126 void setUserAgentOverride(ErrorString*, const String& userAgent);
127 void setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject>);
128 void getResourceContent(ErrorString*, const String& requestId, String* content, bool* base64Encoded);
129 void clearCache(ErrorString*, const String* const optionalPreservedLoaderId);
131 void clearBrowserCache(ErrorString*);
132 void clearBrowserCookies(ErrorString*);
133 void setCacheDisabled(ErrorString*, bool cacheDisabled);
136 InspectorResourceAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorClient*, InspectorState*);
140 InstrumentingAgents* m_instrumentingAgents;
141 InspectorPageAgent* m_pageAgent;
142 InspectorClient* m_client;
143 InspectorState* m_state;
144 InspectorFrontend::Network* m_frontend;
145 String m_userAgentOverride;
146 OwnPtr<NetworkResourcesData> m_resourcesData;
147 bool m_loadingXHRSynchronously;
149 // FIXME: InspectorResourceAgent should now be aware of style recalculation.
150 RefPtr<InspectorObject> m_styleRecalculationInitiator;
151 bool m_isRecalculatingStyle;
154 } // namespace WebCore
156 #endif // ENABLE(INSPECTOR)
158 #endif // !defined(InspectorResourceAgent_h)