| 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 (!accept().isEmpty()) | 178 if (!m_resourceRequest.url().hasFragmentIdentifier()) |
| 179 m_resourceRequest.setHTTPAccept(accept()); | 179 return; |
| 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); |
| 180 } | 185 } |
| 181 | 186 |
| 182 Resource::~Resource() | 187 Resource::~Resource() |
| 183 { | 188 { |
| 184 ASSERT(canDelete()); | 189 ASSERT(canDelete()); |
| 185 RELEASE_ASSERT(!memoryCache()->contains(this)); | 190 RELEASE_ASSERT(!memoryCache()->contains(this)); |
| 186 RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this)); | 191 RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this)); |
| 187 assertAlive(); | 192 assertAlive(); |
| 188 | 193 |
| 189 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 194 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
| (...skipping 11 matching lines...) Expand all Loading... |
| 201 visitor->trace(m_loader); | 206 visitor->trace(m_loader); |
| 202 #if ENABLE(OILPAN) | 207 #if ENABLE(OILPAN) |
| 203 visitor->trace(m_cacheHandler); | 208 visitor->trace(m_cacheHandler); |
| 204 #endif | 209 #endif |
| 205 } | 210 } |
| 206 | 211 |
| 207 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio
ns) | 212 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio
ns) |
| 208 { | 213 { |
| 209 m_options = options; | 214 m_options = options; |
| 210 m_loading = true; | 215 m_loading = true; |
| 216 |
| 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. |
| 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 } |
| 211 m_status = Pending; | 229 m_status = Pending; |
| 212 | |
| 213 if (m_loader) { | 230 if (m_loader) { |
| 214 ASSERT(m_revalidatingRequest.isNull()); | 231 ASSERT(m_revalidatingRequest.isNull()); |
| 215 RELEASE_ASSERT(m_options.synchronousPolicy == RequestSynchronously); | 232 RELEASE_ASSERT(m_options.synchronousPolicy == RequestSynchronously); |
| 216 m_loader->changeToSynchronous(); | 233 m_loader->changeToSynchronous(); |
| 217 return; | 234 return; |
| 218 } | 235 } |
| 219 | 236 m_loader = ResourceLoader::create(fetcher, this, request, options); |
| 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); | |
| 223 m_loader->start(); | 237 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()) | |
| 227 request = requestCopy; | |
| 228 } | 238 } |
| 229 | 239 |
| 230 void Resource::checkNotify() | 240 void Resource::checkNotify() |
| 231 { | 241 { |
| 232 if (isLoading()) | 242 if (isLoading()) |
| 233 return; | 243 return; |
| 234 | 244 |
| 235 ResourceClientWalker<ResourceClient> w(m_clients); | 245 ResourceClientWalker<ResourceClient> w(m_clients); |
| 236 while (ResourceClient* c = w.next()) | 246 while (ResourceClient* c = w.next()) |
| 237 c->notifyFinished(this); | 247 c->notifyFinished(this); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 return "ImportResource"; | 1064 return "ImportResource"; |
| 1055 case Resource::Media: | 1065 case Resource::Media: |
| 1056 return "Media"; | 1066 return "Media"; |
| 1057 } | 1067 } |
| 1058 ASSERT_NOT_REACHED(); | 1068 ASSERT_NOT_REACHED(); |
| 1059 return "Unknown"; | 1069 return "Unknown"; |
| 1060 } | 1070 } |
| 1061 #endif // !LOG_DISABLED | 1071 #endif // !LOG_DISABLED |
| 1062 | 1072 |
| 1063 } // namespace blink | 1073 } // namespace blink |
| OLD | NEW |