2
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3
* Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4
* Copyright (C) 2009 Google Inc. All rights reserved.
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16
* its contributors may be used to endorse or promote products derived
17
* from this software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
#ifndef InspectorResource_h
32
#define InspectorResource_h
34
#include "HTTPHeaderMap.h"
36
#include "ScriptObject.h"
37
#include "ScriptState.h"
38
#include "ScriptString.h"
40
#include <wtf/CurrentTime.h>
41
#include <wtf/OwnPtr.h>
42
#include <wtf/PassRefPtr.h>
43
#include <wtf/RefCounted.h>
44
#include <wtf/RefPtr.h>
50
class InspectorFrontend;
52
class ResourceResponse;
54
struct ResourceRequest;
56
class InspectorResource : public RefCounted<InspectorResource> {
59
// Keep these in sync with WebInspector.Resource.Type
71
static PassRefPtr<InspectorResource> create(long long identifier, DocumentLoader* loader)
73
return adoptRef(new InspectorResource(identifier, loader));
76
static PassRefPtr<InspectorResource> createCached(long long identifier, DocumentLoader*, const CachedResource*);
80
void createScriptObject(InspectorFrontend* frontend);
81
void updateScriptObject(InspectorFrontend* frontend);
82
void releaseScriptObject(InspectorFrontend* frontend, bool callRemoveResource);
84
void updateRequest(const ResourceRequest&);
85
void updateResponse(const ResourceResponse&);
87
void setXMLHttpResponseText(const ScriptString& data);
89
String sourceString() const;
90
PassRefPtr<SharedBuffer> resourceData(String* textEncodingName) const;
92
bool isSameLoader(DocumentLoader* loader) const { return loader == m_loader; }
93
void markMainResource() { m_isMainResource = true; }
94
long long identifier() const { return m_identifier; }
95
String requestURL() const { return m_requestURL.string(); }
96
Frame* frame() const { return m_frame.get(); }
97
const String& mimeType() const { return m_mimeType; }
98
const HTTPHeaderMap& requestHeaderFields() const { return m_requestHeaderFields; }
99
const HTTPHeaderMap& responseHeaderFields() const { return m_responseHeaderFields; }
100
int responseStatusCode() const { return m_responseStatusCode; }
101
String requestMethod() const { return m_requestMethod; }
102
String requestFormData() const { return m_requestFormData; }
105
void markResponseReceivedTime();
109
void addLength(int lengthReceived);
118
CompletionChange = 16,
124
Changes() : m_change(NoChange) {}
126
inline bool hasChange(ChangeType change) { return (m_change & change) || !(m_change + change); }
127
inline void set(ChangeType change)
129
m_change = static_cast<ChangeType>(static_cast<unsigned>(m_change) | static_cast<unsigned>(change));
131
inline void clear(ChangeType change)
133
m_change = static_cast<ChangeType>(static_cast<unsigned>(m_change) & ~static_cast<unsigned>(change));
136
inline void setAll() { m_change = static_cast<ChangeType>(63); }
137
inline void clearAll() { m_change = NoChange; }
143
InspectorResource(long long identifier, DocumentLoader*);
146
long long m_identifier;
147
RefPtr<DocumentLoader> m_loader;
148
RefPtr<Frame> m_frame;
150
HTTPHeaderMap m_requestHeaderFields;
151
HTTPHeaderMap m_responseHeaderFields;
153
String m_suggestedFilename;
154
bool m_scriptObjectCreated;
155
long long m_expectedContentLength;
160
int m_responseStatusCode;
162
double m_responseReceivedTime;
164
ScriptString m_xmlHttpResponseText;
166
bool m_isMainResource;
167
String m_requestMethod;
168
String m_requestFormData;
171
} // namespace WebCore
173
#endif // InspectorResource_h