OLD | NEW |
---|---|
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 #endif | 168 #endif |
169 { | 169 { |
170 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum. | 170 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum. |
171 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); | 171 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); |
172 memoryCache()->registerLiveResource(*this); | 172 memoryCache()->registerLiveResource(*this); |
173 | 173 |
174 // Currently we support the metadata caching only for HTTP family. | 174 // Currently we support the metadata caching only for HTTP family. |
175 if (m_resourceRequest.url().protocolIsInHTTPFamily()) | 175 if (m_resourceRequest.url().protocolIsInHTTPFamily()) |
176 m_cacheHandler = CacheHandler::create(this); | 176 m_cacheHandler = CacheHandler::create(this); |
177 | 177 |
178 if (!m_resourceRequest.url().hasFragmentIdentifier()) | 178 if (!accept().isEmpty()) |
179 return; | 179 m_resourceRequest.setHTTPAccept(accept()); |
180 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR equest.url()); | |
181 if (urlForCache.hasFragmentIdentifier()) | |
182 return; | |
183 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier( ); | |
184 m_resourceRequest.setURL(urlForCache); | |
185 } | 180 } |
186 | 181 |
187 Resource::~Resource() | 182 Resource::~Resource() |
188 { | 183 { |
189 ASSERT(canDelete()); | 184 ASSERT(canDelete()); |
190 RELEASE_ASSERT(!memoryCache()->contains(this)); | 185 RELEASE_ASSERT(!memoryCache()->contains(this)); |
191 RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this)); | 186 RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this)); |
192 assertAlive(); | 187 assertAlive(); |
193 | 188 |
194 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 189 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
(...skipping 11 matching lines...) Expand all Loading... | |
206 visitor->trace(m_loader); | 201 visitor->trace(m_loader); |
207 #if ENABLE(OILPAN) | 202 #if ENABLE(OILPAN) |
208 visitor->trace(m_cacheHandler); | 203 visitor->trace(m_cacheHandler); |
209 #endif | 204 #endif |
210 } | 205 } |
211 | 206 |
212 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio ns) | 207 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio ns) |
213 { | 208 { |
214 m_options = options; | 209 m_options = options; |
215 m_loading = true; | 210 m_loading = true; |
211 m_status = Pending; | |
216 | 212 |
217 ResourceRequest request(m_revalidatingRequest.isNull() ? m_resourceRequest : m_revalidatingRequest); | |
218 if (!accept().isEmpty()) | |
219 request.setHTTPAccept(accept()); | |
220 | |
221 // FIXME: It's unfortunate that the cache layer and below get to know anythi ng about fragment identifiers. | |
Nate Chapin
2015/11/04 22:13:09
I remember adding this hack :(
It's relatively st
| |
222 // We should look into removing the expectation of that knowledge from the p latform network stacks. | |
223 if (!m_fragmentIdentifierForRequest.isNull()) { | |
224 KURL url = request.url(); | |
225 url.setFragmentIdentifier(m_fragmentIdentifierForRequest); | |
226 request.setURL(url); | |
227 m_fragmentIdentifierForRequest = String(); | |
228 } | |
229 m_status = Pending; | |
230 if (m_loader) { | 213 if (m_loader) { |
231 ASSERT(m_revalidatingRequest.isNull()); | 214 ASSERT(m_revalidatingRequest.isNull()); |
232 RELEASE_ASSERT(m_options.synchronousPolicy == RequestSynchronously); | 215 RELEASE_ASSERT(m_options.synchronousPolicy == RequestSynchronously); |
233 m_loader->changeToSynchronous(); | 216 m_loader->changeToSynchronous(); |
234 return; | 217 return; |
235 } | 218 } |
236 m_loader = ResourceLoader::create(fetcher, this, request, options); | 219 |
220 ResourceRequest& request(m_revalidatingRequest.isNull() ? m_resourceRequest : m_revalidatingRequest); | |
221 ResourceRequest requestCopy(m_revalidatingRequest.isNull() ? m_resourceReque st : m_revalidatingRequest); | |
222 m_loader = ResourceLoader::create(fetcher, this, requestCopy, options); | |
237 m_loader->start(); | 223 m_loader->start(); |
224 | |
225 // Headers might have been modified during load start. Copy them over so lon g as the url didn't change. | |
226 if (request.url() == requestCopy.url()) | |
Nate Chapin
2015/11/04 22:13:09
This is a little goofy, and requires passing a non
| |
227 request = requestCopy; | |
238 } | 228 } |
239 | 229 |
240 void Resource::checkNotify() | 230 void Resource::checkNotify() |
241 { | 231 { |
242 if (isLoading()) | 232 if (isLoading()) |
243 return; | 233 return; |
244 | 234 |
245 ResourceClientWalker<ResourceClient> w(m_clients); | 235 ResourceClientWalker<ResourceClient> w(m_clients); |
246 while (ResourceClient* c = w.next()) | 236 while (ResourceClient* c = w.next()) |
247 c->notifyFinished(this); | 237 c->notifyFinished(this); |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 return "ImportResource"; | 1054 return "ImportResource"; |
1065 case Resource::Media: | 1055 case Resource::Media: |
1066 return "Media"; | 1056 return "Media"; |
1067 } | 1057 } |
1068 ASSERT_NOT_REACHED(); | 1058 ASSERT_NOT_REACHED(); |
1069 return "Unknown"; | 1059 return "Unknown"; |
1070 } | 1060 } |
1071 #endif // !LOG_DISABLED | 1061 #endif // !LOG_DISABLED |
1072 | 1062 |
1073 } // namespace blink | 1063 } // namespace blink |
OLD | NEW |