| 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 if (requestURL.isValid() && canRequest(Resource::Image, requestURL,
request.options(), request.forPreload(), request.originRestriction())) | 284 if (requestURL.isValid() && canRequest(Resource::Image, requestURL,
request.options(), request.forPreload(), request.originRestriction())) |
| 285 PingLoader::loadImage(f, requestURL); | 285 PingLoader::loadImage(f, requestURL); |
| 286 return 0; | 286 return 0; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (request.resourceRequest().url().protocolIsData()) | 290 if (request.resourceRequest().url().protocolIsData()) |
| 291 preCacheDataURIImage(request); | 291 preCacheDataURIImage(request); |
| 292 | 292 |
| 293 request.setDefer(clientDefersImage(request.resourceRequest().url()) ? FetchR
equest::DeferredByClient : FetchRequest::NoDefer); | 293 request.setDefer(clientDefersImage(request.resourceRequest().url()) ? FetchR
equest::DeferredByClient : FetchRequest::NoDefer); |
| 294 return toImageResource(requestResource(Resource::Image, request)); | 294 ResourcePtr<Resource> resource = requestResource(Resource::Image, request); |
| 295 return resource && resource->type() == Resource::Image ? toImageResource(res
ource) : 0; |
| 295 } | 296 } |
| 296 | 297 |
| 297 void ResourceFetcher::preCacheDataURIImage(const FetchRequest& request) | 298 void ResourceFetcher::preCacheDataURIImage(const FetchRequest& request) |
| 298 { | 299 { |
| 299 const KURL& url = request.resourceRequest().url(); | 300 const KURL& url = request.resourceRequest().url(); |
| 300 ASSERT(url.protocolIsData()); | 301 ASSERT(url.protocolIsData()); |
| 301 | 302 |
| 302 if (memoryCache()->resourceForURL(url)) | 303 if (memoryCache()->resourceForURL(url)) |
| 303 return; | 304 return; |
| 304 | 305 |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 if (type == Resource::MainResource) | 1199 if (type == Resource::MainResource) |
| 1199 return; | 1200 return; |
| 1200 | 1201 |
| 1201 String encoding; | 1202 String encoding; |
| 1202 if (type == Resource::Script || type == Resource::CSSStyleSheet) | 1203 if (type == Resource::Script || type == Resource::CSSStyleSheet) |
| 1203 encoding = charset.isEmpty() ? m_document->charset().string() : charset; | 1204 encoding = charset.isEmpty() ? m_document->charset().string() : charset; |
| 1204 | 1205 |
| 1205 request.setCharset(encoding); | 1206 request.setCharset(encoding); |
| 1206 request.setForPreload(true); | 1207 request.setForPreload(true); |
| 1207 | 1208 |
| 1208 ResourcePtr<Resource> resource = requestResource(type, request); | 1209 ResourcePtr<Resource> resource; |
| 1210 // Loading images involves several special cases, so use dedicated fetch met
hod instead. |
| 1211 if (type == Resource::Image) |
| 1212 resource = fetchImage(request); |
| 1213 if (!resource) |
| 1214 resource = requestResource(type, request); |
| 1209 if (!resource || (m_preloads && m_preloads->contains(resource.get()))) | 1215 if (!resource || (m_preloads && m_preloads->contains(resource.get()))) |
| 1210 return; | 1216 return; |
| 1211 TRACE_EVENT_ASYNC_STEP_INTO0("net", "Resource", resource.get(), "Preload"); | 1217 TRACE_EVENT_ASYNC_STEP_INTO0("net", "Resource", resource.get(), "Preload"); |
| 1212 resource->increasePreloadCount(); | 1218 resource->increasePreloadCount(); |
| 1213 | 1219 |
| 1214 if (!m_preloads) | 1220 if (!m_preloads) |
| 1215 m_preloads = adoptPtr(new ListHashSet<Resource*>); | 1221 m_preloads = adoptPtr(new ListHashSet<Resource*>); |
| 1216 m_preloads->add(resource.get()); | 1222 m_preloads->add(resource.get()); |
| 1217 | 1223 |
| 1218 #if PRELOAD_DEBUG | 1224 #if PRELOAD_DEBUG |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 } | 1495 } |
| 1490 } | 1496 } |
| 1491 | 1497 |
| 1492 void ResourceFetcher::trace(Visitor* visitor) | 1498 void ResourceFetcher::trace(Visitor* visitor) |
| 1493 { | 1499 { |
| 1494 visitor->trace(m_document); | 1500 visitor->trace(m_document); |
| 1495 ResourceLoaderHost::trace(visitor); | 1501 ResourceLoaderHost::trace(visitor); |
| 1496 } | 1502 } |
| 1497 | 1503 |
| 1498 } | 1504 } |
| OLD | NEW |