~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/inspector/InspectorResource.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
5
 *
 
6
 * Redistribution and use in source and binary forms, with or without
 
7
 * modification, are permitted provided that the following conditions
 
8
 * are met:
 
9
 *
 
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.
 
18
 *
 
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.
 
29
 */
 
30
 
 
31
#ifndef InspectorResource_h
 
32
#define InspectorResource_h
 
33
 
 
34
#include "HTTPHeaderMap.h"
 
35
#include "KURL.h"
 
36
#include "ScriptObject.h"
 
37
#include "ScriptState.h"
 
38
#include "ScriptString.h"
 
39
 
 
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>
 
45
 
 
46
namespace WebCore {
 
47
 
 
48
    class CachedResource;
 
49
    class DocumentLoader;
 
50
    class InspectorFrontend;
 
51
    class Frame;
 
52
    class ResourceResponse;
 
53
 
 
54
    struct ResourceRequest;
 
55
 
 
56
    class InspectorResource : public RefCounted<InspectorResource> {
 
57
    public:
 
58
 
 
59
        // Keep these in sync with WebInspector.Resource.Type
 
60
        enum Type {
 
61
            Doc,
 
62
            Stylesheet,
 
63
            Image,
 
64
            Font,
 
65
            Script,
 
66
            XHR,
 
67
            Media,
 
68
            Other
 
69
        };
 
70
 
 
71
        static PassRefPtr<InspectorResource> create(long long identifier, DocumentLoader* loader)
 
72
        {
 
73
            return adoptRef(new InspectorResource(identifier, loader));
 
74
        }
 
75
 
 
76
        static PassRefPtr<InspectorResource> createCached(long long identifier, DocumentLoader*, const CachedResource*);
 
77
 
 
78
        ~InspectorResource();
 
79
 
 
80
        void createScriptObject(InspectorFrontend* frontend);
 
81
        void updateScriptObject(InspectorFrontend* frontend);
 
82
        void releaseScriptObject(InspectorFrontend* frontend, bool callRemoveResource);
 
83
 
 
84
        void updateRequest(const ResourceRequest&);
 
85
        void updateResponse(const ResourceResponse&);
 
86
 
 
87
        void setXMLHttpResponseText(const ScriptString& data);
 
88
 
 
89
        String sourceString() const;
 
90
        PassRefPtr<SharedBuffer> resourceData(String* textEncodingName) const;
 
91
 
 
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; }
 
103
 
 
104
        void startTiming();
 
105
        void markResponseReceivedTime();
 
106
        void endTiming();
 
107
 
 
108
        void markFailed();
 
109
        void addLength(int lengthReceived);
 
110
 
 
111
    private:
 
112
        enum ChangeType {
 
113
            NoChange = 0,
 
114
            RequestChange = 1,
 
115
            ResponseChange = 2,
 
116
            TypeChange = 4,
 
117
            LengthChange = 8,
 
118
            CompletionChange = 16,
 
119
            TimingChange = 32
 
120
        };
 
121
 
 
122
        class Changes {
 
123
        public:
 
124
            Changes() : m_change(NoChange) {}
 
125
 
 
126
            inline bool hasChange(ChangeType change) { return (m_change & change) || !(m_change + change); }
 
127
            inline void set(ChangeType change)
 
128
            {
 
129
                m_change = static_cast<ChangeType>(static_cast<unsigned>(m_change) | static_cast<unsigned>(change));            
 
130
            }
 
131
            inline void clear(ChangeType change)
 
132
            {
 
133
                m_change = static_cast<ChangeType>(static_cast<unsigned>(m_change) & ~static_cast<unsigned>(change));
 
134
            }
 
135
 
 
136
            inline void setAll() { m_change = static_cast<ChangeType>(63); }
 
137
            inline void clearAll() { m_change = NoChange; }
 
138
 
 
139
        private:
 
140
            ChangeType m_change;
 
141
        };
 
142
 
 
143
        InspectorResource(long long identifier, DocumentLoader*);
 
144
        Type type() const;
 
145
 
 
146
        long long m_identifier;
 
147
        RefPtr<DocumentLoader> m_loader;
 
148
        RefPtr<Frame> m_frame;
 
149
        KURL m_requestURL;
 
150
        HTTPHeaderMap m_requestHeaderFields;
 
151
        HTTPHeaderMap m_responseHeaderFields;
 
152
        String m_mimeType;
 
153
        String m_suggestedFilename;
 
154
        bool m_scriptObjectCreated;
 
155
        long long m_expectedContentLength;
 
156
        bool m_cached;
 
157
        bool m_finished;
 
158
        bool m_failed;
 
159
        int m_length;
 
160
        int m_responseStatusCode;
 
161
        double m_startTime;
 
162
        double m_responseReceivedTime;
 
163
        double m_endTime;
 
164
        ScriptString m_xmlHttpResponseText;
 
165
        Changes m_changes;
 
166
        bool m_isMainResource;
 
167
        String m_requestMethod;
 
168
        String m_requestFormData;
 
169
    };
 
170
 
 
171
} // namespace WebCore
 
172
 
 
173
#endif // InspectorResource_h