| 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 if (memoryCache()->contains(resource.get())) | 748 if (memoryCache()->contains(resource.get())) |
| 749 memoryCache()->remove(resource.get()); | 749 memoryCache()->remove(resource.get()); |
| 750 return request.options().synchronousPolicy == RequestSynchronously ?
resource : 0; | 750 return request.options().synchronousPolicy == RequestSynchronously ?
resource : 0; |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 // FIXME: Temporarily leave main resource caching disabled for chromium, | 754 // FIXME: Temporarily leave main resource caching disabled for chromium, |
| 755 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main | 755 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main |
| 756 // resources, we should be sure to understand the implications for memory | 756 // resources, we should be sure to understand the implications for memory |
| 757 // use. | 757 // use. |
| 758 // | 758 // Remove main resource from cache to prevent reuse. |
| 759 // Ensure main resources aren't preloaded, and other main resource loads | |
| 760 // are removed from cache to prevent reuse. | |
| 761 if (type == Resource::MainResource) { | 759 if (type == Resource::MainResource) { |
| 762 ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); | 760 ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); |
| 763 ASSERT(policy != Revalidate); | 761 ASSERT(policy != Revalidate); |
| 764 memoryCache()->remove(resource.get()); | 762 memoryCache()->remove(resource.get()); |
| 765 if (request.forPreload()) | |
| 766 return 0; | |
| 767 } | 763 } |
| 768 | 764 |
| 769 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF
romCache : ResourceLoadingFromNetwork); | 765 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF
romCache : ResourceLoadingFromNetwork); |
| 770 | 766 |
| 771 ASSERT(resource->url() == url.string()); | 767 ASSERT(resource->url() == url.string()); |
| 772 m_documentResources.set(resource->url(), resource); | 768 m_documentResources.set(resource->url(), resource); |
| 773 return resource; | 769 return resource; |
| 774 } | 770 } |
| 775 | 771 |
| 776 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim
er) | 772 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim
er) |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 ASSERT(m_requestCount > -1); | 1186 ASSERT(m_requestCount > -1); |
| 1191 } | 1187 } |
| 1192 | 1188 |
| 1193 void ResourceFetcher::preload(Resource::Type type, FetchRequest& request, const
String& charset) | 1189 void ResourceFetcher::preload(Resource::Type type, FetchRequest& request, const
String& charset) |
| 1194 { | 1190 { |
| 1195 requestPreload(type, request, charset); | 1191 requestPreload(type, request, charset); |
| 1196 } | 1192 } |
| 1197 | 1193 |
| 1198 void ResourceFetcher::requestPreload(Resource::Type type, FetchRequest& request,
const String& charset) | 1194 void ResourceFetcher::requestPreload(Resource::Type type, FetchRequest& request,
const String& charset) |
| 1199 { | 1195 { |
| 1196 // Ensure main resources aren't preloaded, since the cache can't actually re
use the preload. |
| 1197 if (type == Resource::MainResource) |
| 1198 return; |
| 1199 |
| 1200 String encoding; | 1200 String encoding; |
| 1201 if (type == Resource::Script || type == Resource::CSSStyleSheet) | 1201 if (type == Resource::Script || type == Resource::CSSStyleSheet) |
| 1202 encoding = charset.isEmpty() ? m_document->charset().string() : charset; | 1202 encoding = charset.isEmpty() ? m_document->charset().string() : charset; |
| 1203 | 1203 |
| 1204 request.setCharset(encoding); | 1204 request.setCharset(encoding); |
| 1205 request.setForPreload(true); | 1205 request.setForPreload(true); |
| 1206 | 1206 |
| 1207 ResourcePtr<Resource> resource = requestResource(type, request); | 1207 ResourcePtr<Resource> resource = requestResource(type, request); |
| 1208 if (!resource || (m_preloads && m_preloads->contains(resource.get()))) | 1208 if (!resource || (m_preloads && m_preloads->contains(resource.get()))) |
| 1209 return; | 1209 return; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 } | 1492 } |
| 1493 } | 1493 } |
| 1494 | 1494 |
| 1495 void ResourceFetcher::trace(Visitor* visitor) | 1495 void ResourceFetcher::trace(Visitor* visitor) |
| 1496 { | 1496 { |
| 1497 visitor->trace(m_document); | 1497 visitor->trace(m_document); |
| 1498 ResourceLoaderHost::trace(visitor); | 1498 ResourceLoaderHost::trace(visitor); |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 } | 1501 } |
| OLD | NEW |