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 | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 rights reserved. | 6 rights reserved. |
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
8 | 8 |
9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 bool is_static_data = is_data_url || substitute_data.IsValid() || archive_; | 597 bool is_static_data = is_data_url || substitute_data.IsValid() || archive_; |
598 if (is_static_data) { | 598 if (is_static_data) { |
599 resource = ResourceForStaticData(params, factory, substitute_data); | 599 resource = ResourceForStaticData(params, factory, substitute_data); |
600 // Abort the request if the archive doesn't contain the resource, except in | 600 // Abort the request if the archive doesn't contain the resource, except in |
601 // the case of data URLs which might have resources such as fonts that need | 601 // the case of data URLs which might have resources such as fonts that need |
602 // to be decoded only on demand. These data URLs are allowed to be | 602 // to be decoded only on demand. These data URLs are allowed to be |
603 // processed using the normal ResourceFetcher machinery. | 603 // processed using the normal ResourceFetcher machinery. |
604 if (!resource && !is_data_url && archive_) | 604 if (!resource && !is_data_url && archive_) |
605 return nullptr; | 605 return nullptr; |
606 } | 606 } |
607 if (!resource) { | 607 if (!resource && IsMainThread()) { |
608 resource = | 608 resource = |
609 GetMemoryCache()->ResourceForURL(params.Url(), GetCacheIdentifier()); | 609 GetMemoryCache()->ResourceForURL(params.Url(), GetCacheIdentifier()); |
610 } | 610 } |
611 | 611 |
612 // If we got a preloaded resource from the cache for a non-preload request, | 612 // If we got a preloaded resource from the cache for a non-preload request, |
613 // we may need to make it block the onload event. | 613 // we may need to make it block the onload event. |
614 MakePreloadedResourceBlockOnloadIfNeeded(resource, params); | 614 MakePreloadedResourceBlockOnloadIfNeeded(resource, params); |
615 | 615 |
616 const RevalidationPolicy policy = DetermineRevalidationPolicy( | 616 const RevalidationPolicy policy = DetermineRevalidationPolicy( |
617 factory.GetType(), params, resource, is_static_data); | 617 factory.GetType(), params, resource, is_static_data); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 revalidating_request.SetHTTPHeaderField(HTTPNames::If_None_Match, e_tag); | 744 revalidating_request.SetHTTPHeaderField(HTTPNames::If_None_Match, e_tag); |
745 | 745 |
746 resource->SetRevalidatingRequest(revalidating_request); | 746 resource->SetRevalidatingRequest(revalidating_request); |
747 } | 747 } |
748 | 748 |
749 Resource* ResourceFetcher::CreateResourceForLoading( | 749 Resource* ResourceFetcher::CreateResourceForLoading( |
750 FetchParameters& params, | 750 FetchParameters& params, |
751 const String& charset, | 751 const String& charset, |
752 const ResourceFactory& factory) { | 752 const ResourceFactory& factory) { |
753 const String cache_identifier = GetCacheIdentifier(); | 753 const String cache_identifier = GetCacheIdentifier(); |
754 DCHECK(!GetMemoryCache()->ResourceForURL(params.GetResourceRequest().Url(), | 754 DCHECK(!IsMainThread() || |
| 755 !GetMemoryCache()->ResourceForURL(params.GetResourceRequest().Url(), |
755 cache_identifier)); | 756 cache_identifier)); |
756 | 757 |
757 RESOURCE_LOADING_DVLOG(1) << "Loading Resource for " | 758 RESOURCE_LOADING_DVLOG(1) << "Loading Resource for " |
758 << params.GetResourceRequest().Url().ElidedString(); | 759 << params.GetResourceRequest().Url().ElidedString(); |
759 | 760 |
760 Resource* resource = | 761 Resource* resource = |
761 factory.Create(params.GetResourceRequest(), params.Options(), charset); | 762 factory.Create(params.GetResourceRequest(), params.Options(), charset); |
762 resource->SetLinkPreload(params.IsLinkPreload()); | 763 resource->SetLinkPreload(params.IsLinkPreload()); |
763 if (params.IsSpeculativePreload()) { | 764 if (params.IsSpeculativePreload()) { |
764 resource->SetPreloadDiscoveryTime(params.PreloadDiscoveryTime()); | 765 resource->SetPreloadDiscoveryTime(params.PreloadDiscoveryTime()); |
765 } | 766 } |
766 resource->SetCacheIdentifier(cache_identifier); | 767 resource->SetCacheIdentifier(cache_identifier); |
767 | 768 |
768 // - Don't add main resource to cache to prevent reuse. | 769 // - Don't add main resource to cache to prevent reuse. |
769 // - Don't add the resource if its body will not be stored. | 770 // - Don't add the resource if its body will not be stored. |
770 if (factory.GetType() != Resource::kMainResource && | 771 if (IsMainThread() && factory.GetType() != Resource::kMainResource && |
771 params.Options().data_buffering_policy != kDoNotBufferData) { | 772 params.Options().data_buffering_policy != kDoNotBufferData) { |
772 GetMemoryCache()->Add(resource); | 773 GetMemoryCache()->Add(resource); |
773 } | 774 } |
774 return resource; | 775 return resource; |
775 } | 776 } |
776 | 777 |
777 void ResourceFetcher::StorePerformanceTimingInitiatorInformation( | 778 void ResourceFetcher::StorePerformanceTimingInitiatorInformation( |
778 Resource* resource) { | 779 Resource* resource) { |
779 const AtomicString& fetch_initiator = resource->Options().initiator_info.name; | 780 const AtomicString& fetch_initiator = resource->Options().initiator_info.name; |
780 if (fetch_initiator == FetchInitiatorTypeNames::internal) | 781 if (fetch_initiator == FetchInitiatorTypeNames::internal) |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 ResourceRequest request(resource->GetResourceRequest()); | 1270 ResourceRequest request(resource->GetResourceRequest()); |
1270 ResourceLoader* loader = nullptr; | 1271 ResourceLoader* loader = nullptr; |
1271 | 1272 |
1272 { | 1273 { |
1273 // Forbids JavaScript/addClient/removeClient/revalidation until start() | 1274 // Forbids JavaScript/addClient/removeClient/revalidation until start() |
1274 // to prevent unintended state transitions. | 1275 // to prevent unintended state transitions. |
1275 Resource::ProhibitAddRemoveClientInScope | 1276 Resource::ProhibitAddRemoveClientInScope |
1276 prohibit_add_remove_client_in_scope(resource); | 1277 prohibit_add_remove_client_in_scope(resource); |
1277 Resource::RevalidationStartForbiddenScope | 1278 Resource::RevalidationStartForbiddenScope |
1278 revalidation_start_forbidden_scope(resource); | 1279 revalidation_start_forbidden_scope(resource); |
1279 ScriptForbiddenScope script_forbidden_scope; | 1280 ScriptForbiddenIfMainThreadScope script_forbidden_scope; |
1280 | 1281 |
1281 if (!Context().ShouldLoadNewResource(resource->GetType())) { | 1282 if (!Context().ShouldLoadNewResource(resource->GetType()) && |
| 1283 IsMainThread()) { |
1282 GetMemoryCache()->Remove(resource); | 1284 GetMemoryCache()->Remove(resource); |
1283 return false; | 1285 return false; |
1284 } | 1286 } |
1285 | 1287 |
1286 ResourceResponse response; | 1288 ResourceResponse response; |
1287 | 1289 |
1288 blink::probe::PlatformSendRequest probe(&Context(), resource->Identifier(), | 1290 blink::probe::PlatformSendRequest probe(&Context(), resource->Identifier(), |
1289 request, response, | 1291 request, response, |
1290 resource->Options().initiator_info); | 1292 resource->Options().initiator_info); |
1291 | 1293 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 visitor->Trace(context_); | 1560 visitor->Trace(context_); |
1559 visitor->Trace(archive_); | 1561 visitor->Trace(archive_); |
1560 visitor->Trace(loaders_); | 1562 visitor->Trace(loaders_); |
1561 visitor->Trace(non_blocking_loaders_); | 1563 visitor->Trace(non_blocking_loaders_); |
1562 visitor->Trace(document_resources_); | 1564 visitor->Trace(document_resources_); |
1563 visitor->Trace(preloads_); | 1565 visitor->Trace(preloads_); |
1564 visitor->Trace(resource_timing_info_map_); | 1566 visitor->Trace(resource_timing_info_map_); |
1565 } | 1567 } |
1566 | 1568 |
1567 } // namespace blink | 1569 } // namespace blink |
OLD | NEW |