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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 resource->setDataBufferingPolicy(BufferData); | 316 resource->setDataBufferingPolicy(BufferData); |
317 if (data->size()) | 317 if (data->size()) |
318 resource->setResourceBuffer(data); | 318 resource->setResourceBuffer(data); |
319 resource->setIdentifier(createUniqueIdentifier()); | 319 resource->setIdentifier(createUniqueIdentifier()); |
320 resource->setCacheIdentifier(cacheIdentifier); | 320 resource->setCacheIdentifier(cacheIdentifier); |
321 resource->finish(); | 321 resource->finish(); |
322 memoryCache()->add(resource.get()); | 322 memoryCache()->add(resource.get()); |
323 return resource; | 323 return resource; |
324 } | 324 } |
325 | 325 |
326 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking(Resource* resource
) | 326 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking(Resource* resource
, const FetchRequest& request) |
327 { | 327 { |
328 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue
to not-block even after being preloaded and discovered. | 328 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue
to not-block even after being preloaded and discovered. |
329 if (resource && resource->loader() && resource->isNonBlockingResourceType()
&& resource->avoidBlockingOnLoad()) { | 329 if (resource && resource->loader() && resource->isNonBlockingResourceType()
&& resource->avoidBlockingOnLoad() && !request.forPreload()) { |
330 if (m_nonBlockingLoaders) | 330 if (m_nonBlockingLoaders) |
331 m_nonBlockingLoaders->remove(resource->loader()); | 331 m_nonBlockingLoaders->remove(resource->loader()); |
332 if (!m_loaders) | 332 if (!m_loaders) |
333 m_loaders = ResourceLoaderSet::create(); | 333 m_loaders = ResourceLoaderSet::create(); |
334 m_loaders->add(resource->loader()); | 334 m_loaders->add(resource->loader()); |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 ResourcePtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, co
nst ResourceFactory& factory, const SubstituteData& substituteData) | 338 ResourcePtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, co
nst ResourceFactory& factory, const SubstituteData& substituteData) |
339 { | 339 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 | 374 |
375 bool isStaticData = request.resourceRequest().url().protocolIsData() || subs
tituteData.isValid(); | 375 bool isStaticData = request.resourceRequest().url().protocolIsData() || subs
tituteData.isValid(); |
376 ResourcePtr<Resource> resource; | 376 ResourcePtr<Resource> resource; |
377 if (isStaticData) | 377 if (isStaticData) |
378 resource = preCacheData(request, factory, substituteData); | 378 resource = preCacheData(request, factory, substituteData); |
379 if (!resource) | 379 if (!resource) |
380 resource = memoryCache()->resourceForURL(url, getCacheIdentifier()); | 380 resource = memoryCache()->resourceForURL(url, getCacheIdentifier()); |
381 | 381 |
382 // See if we can use an existing resource from the cache. If so, we need to
move it to be load blocking. | 382 // See if we can use an existing resource from the cache. If so, we need to
move it to be load blocking. |
383 moveCachedNonBlockingResourceToBlocking(resource.get()); | 383 moveCachedNonBlockingResourceToBlocking(resource.get(), request); |
384 | 384 |
385 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type()
, request, resource.get(), isStaticData); | 385 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type()
, request, resource.get(), isStaticData); |
386 switch (policy) { | 386 switch (policy) { |
387 case Reload: | 387 case Reload: |
388 memoryCache()->remove(resource.get()); | 388 memoryCache()->remove(resource.get()); |
389 // Fall through | 389 // Fall through |
390 case Load: | 390 case Load: |
391 resource = createResourceForLoading(request, request.charset(), factory)
; | 391 resource = createResourceForLoading(request, request.charset(), factory)
; |
392 break; | 392 break; |
393 case Revalidate: | 393 case Revalidate: |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 visitor->trace(m_loaders); | 1154 visitor->trace(m_loaders); |
1155 visitor->trace(m_nonBlockingLoaders); | 1155 visitor->trace(m_nonBlockingLoaders); |
1156 #if ENABLE(OILPAN) | 1156 #if ENABLE(OILPAN) |
1157 visitor->trace(m_documentResources); | 1157 visitor->trace(m_documentResources); |
1158 visitor->trace(m_preloads); | 1158 visitor->trace(m_preloads); |
1159 visitor->trace(m_resourceTimingInfoMap); | 1159 visitor->trace(m_resourceTimingInfoMap); |
1160 #endif | 1160 #endif |
1161 } | 1161 } |
1162 | 1162 |
1163 } | 1163 } |
OLD | NEW |