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

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCache.cpp

  • 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:
39
39
ApplicationCache::ApplicationCache()
40
40
    : m_group(0)
41
41
    , m_manifest(0)
 
42
    , m_estimatedSizeInStorage(0)
42
43
    , m_storageID(0)
43
44
{
44
45
}
51
52
    
52
53
void ApplicationCache::setGroup(ApplicationCacheGroup* group)
53
54
{
54
 
    ASSERT(!m_group);
 
55
    ASSERT(!m_group || group == m_group);
55
56
    m_group = group;
56
57
}
57
58
 
 
59
bool ApplicationCache::isComplete() const
 
60
{
 
61
    return !m_group->cacheIsBeingUpdated(this);
 
62
}
 
63
 
58
64
void ApplicationCache::setManifestResource(PassRefPtr<ApplicationCacheResource> manifest)
59
65
{
60
66
    ASSERT(manifest);
76
82
    
77
83
    if (m_storageID) {
78
84
        ASSERT(!resource->storageID());
 
85
        ASSERT(resource->type() & ApplicationCacheResource::Master);
79
86
        
80
87
        // Add the resource to the storage.
81
88
        cacheStorage().store(resource.get(), this);
82
89
    }
83
 
    
 
90
 
 
91
    m_estimatedSizeInStorage += resource->estimatedSizeInStorage();
 
92
 
84
93
    m_resources.set(url, resource);
85
94
}
86
95
 
94
103
    unsigned type = it->second->type();
95
104
 
96
105
    m_resources.remove(it);
97
 
    
 
106
 
 
107
    m_estimatedSizeInStorage -= it->second->estimatedSizeInStorage();
 
108
 
98
109
    return type;
99
110
}    
100
111
    
101
112
ApplicationCacheResource* ApplicationCache::resourceForURL(const String& url)
102
113
{
 
114
    ASSERT(!KURL(ParsedURLString, url).hasFragmentIdentifier());
103
115
    return m_resources.get(url).get();
104
116
}    
105
117
 
106
118
bool ApplicationCache::requestIsHTTPOrHTTPSGet(const ResourceRequest& request)
107
119
{
108
 
    if (!request.url().protocolIs("http") && !request.url().protocolIs("https"))
 
120
    if (!request.url().protocolInHTTPFamily())
109
121
        return false;
110
122
    
111
123
    if (!equalIgnoringCase(request.httpMethod(), "GET"))
119
131
    // We only care about HTTP/HTTPS GET requests.
120
132
    if (!requestIsHTTPOrHTTPSGet(request))
121
133
        return false;
122
 
    
123
 
    return resourceForURL(request.url());
124
 
}
125
 
 
126
 
unsigned ApplicationCache::numDynamicEntries() const
127
 
{
128
 
    // FIXME: Implement
129
 
    return 0;
130
 
}
131
 
    
132
 
String ApplicationCache::dynamicEntry(unsigned) const
133
 
{
134
 
    // FIXME: Implement
135
 
    return String();
136
 
}
137
 
    
138
 
bool ApplicationCache::addDynamicEntry(const String& url)
139
 
{
140
 
    if (!equalIgnoringCase(m_group->manifestURL().protocol(), KURL(url).protocol()))
141
 
        return false;
142
 
 
143
 
    // FIXME: Implement
144
 
    return true;
145
 
}
146
 
    
147
 
void ApplicationCache::removeDynamicEntry(const String&)
148
 
{
149
 
    // FIXME: Implement
 
134
 
 
135
    KURL url(request.url());
 
136
    if (url.hasFragmentIdentifier())
 
137
        url.removeFragmentIdentifier();
 
138
 
 
139
    return resourceForURL(url);
150
140
}
151
141
 
152
142
void ApplicationCache::setOnlineWhitelist(const Vector<KURL>& onlineWhitelist)
157
147
 
158
148
bool ApplicationCache::isURLInOnlineWhitelist(const KURL& url)
159
149
{
 
150
    if (m_allowAllNetworkRequests)
 
151
        return true;
 
152
 
160
153
    size_t whitelistSize = m_onlineWhitelist.size();
161
154
    for (size_t i = 0; i < whitelistSize; ++i) {
162
155
        if (protocolHostAndPortAreEqual(url, m_onlineWhitelist[i]) && url.string().startsWith(m_onlineWhitelist[i].string()))