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 28 matching lines...) Expand all Loading... |
39 #include "core/fetch/ImageResource.h" | 39 #include "core/fetch/ImageResource.h" |
40 #include "core/fetch/MemoryCache.h" | 40 #include "core/fetch/MemoryCache.h" |
41 #include "core/fetch/RawResource.h" | 41 #include "core/fetch/RawResource.h" |
42 #include "core/fetch/ResourceLoader.h" | 42 #include "core/fetch/ResourceLoader.h" |
43 #include "core/fetch/ResourceLoaderSet.h" | 43 #include "core/fetch/ResourceLoaderSet.h" |
44 #include "core/fetch/ScriptResource.h" | 44 #include "core/fetch/ScriptResource.h" |
45 #include "core/fetch/SubstituteData.h" | 45 #include "core/fetch/SubstituteData.h" |
46 #include "core/fetch/UniqueIdentifier.h" | 46 #include "core/fetch/UniqueIdentifier.h" |
47 #include "core/fetch/XSLStyleSheetResource.h" | 47 #include "core/fetch/XSLStyleSheetResource.h" |
48 #include "core/frame/FrameHost.h" | 48 #include "core/frame/FrameHost.h" |
| 49 #include "core/frame/FrameView.h" |
49 #include "core/frame/LocalDOMWindow.h" | 50 #include "core/frame/LocalDOMWindow.h" |
50 #include "core/frame/LocalFrame.h" | 51 #include "core/frame/LocalFrame.h" |
51 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
52 #include "core/frame/csp/ContentSecurityPolicy.h" | 53 #include "core/frame/csp/ContentSecurityPolicy.h" |
53 #include "core/html/HTMLElement.h" | 54 #include "core/html/HTMLElement.h" |
54 #include "core/html/HTMLFrameOwnerElement.h" | 55 #include "core/html/HTMLFrameOwnerElement.h" |
55 #include "core/html/imports/HTMLImportsController.h" | 56 #include "core/html/imports/HTMLImportsController.h" |
56 #include "core/inspector/ConsoleMessage.h" | 57 #include "core/inspector/ConsoleMessage.h" |
57 #include "core/inspector/InspectorInstrumentation.h" | 58 #include "core/inspector/InspectorInstrumentation.h" |
58 #include "core/loader/DocumentLoader.h" | 59 #include "core/loader/DocumentLoader.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 m_validatedURLs.add(request.resourceRequest().url()); | 714 m_validatedURLs.add(request.resourceRequest().url()); |
714 } | 715 } |
715 | 716 |
716 ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc
hRequest& request) | 717 ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc
hRequest& request) |
717 { | 718 { |
718 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || type
== Resource::Raw); | 719 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || type
== Resource::Raw); |
719 | 720 |
720 TRACE_EVENT0("blink", "ResourceFetcher::requestResource"); | 721 TRACE_EVENT0("blink", "ResourceFetcher::requestResource"); |
721 | 722 |
722 upgradeInsecureRequest(request); | 723 upgradeInsecureRequest(request); |
| 724 addClientHintsIfNeccessary(request); |
723 | 725 |
724 KURL url = request.resourceRequest().url(); | 726 KURL url = request.resourceRequest().url(); |
725 | 727 |
726 WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource '%s', charset '%s
', priority=%d, forPreload=%u, type=%s", url.elidedString().latin1().data(), req
uest.charset().latin1().data(), request.priority(), request.forPreload(), Resour
ceTypeName(type)); | 728 WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource '%s', charset '%s
', priority=%d, forPreload=%u, type=%s", url.elidedString().latin1().data(), req
uest.charset().latin1().data(), request.priority(), request.forPreload(), Resour
ceTypeName(type)); |
727 | 729 |
728 // If only the fragment identifiers differ, it is the same resource. | 730 // If only the fragment identifiers differ, it is the same resource. |
729 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); | 731 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); |
730 | 732 |
731 if (!url.isValid()) | 733 if (!url.isValid()) |
732 return nullptr; | 734 return nullptr; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 || url.host() == m_document->securityOrigin()->host()) | 928 || url.host() == m_document->securityOrigin()->host()) |
927 { | 929 { |
928 url.setProtocol("https"); | 930 url.setProtocol("https"); |
929 if (url.port() == 80) | 931 if (url.port() == 80) |
930 url.setPort(443); | 932 url.setPort(443); |
931 fetchRequest.mutableResourceRequest().setURL(url); | 933 fetchRequest.mutableResourceRequest().setURL(url); |
932 } | 934 } |
933 } | 935 } |
934 } | 936 } |
935 | 937 |
| 938 void ResourceFetcher::addClientHintsIfNeccessary(FetchRequest& fetchRequest) |
| 939 { |
| 940 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document || !frame()
) |
| 941 return; |
| 942 |
| 943 if (frame()->shouldSendDPRHint()) |
| 944 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt
ring(String::number(m_document->devicePixelRatio()))); |
| 945 |
| 946 // FIXME: Send the RW hint based on the actual resource width, when we have
it. |
| 947 if (frame()->shouldSendRWHint() && frame()->view()) |
| 948 fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicStr
ing(String::number(frame()->view()->viewportWidth()))); |
| 949 } |
| 950 |
936 ResourcePtr<Resource> ResourceFetcher::createResourceForRevalidation(const Fetch
Request& request, Resource* resource) | 951 ResourcePtr<Resource> ResourceFetcher::createResourceForRevalidation(const Fetch
Request& request, Resource* resource) |
937 { | 952 { |
938 ASSERT(resource); | 953 ASSERT(resource); |
939 ASSERT(memoryCache()->contains(resource)); | 954 ASSERT(memoryCache()->contains(resource)); |
940 ASSERT(resource->isLoaded()); | 955 ASSERT(resource->isLoaded()); |
941 ASSERT(resource->canUseCacheValidator()); | 956 ASSERT(resource->canUseCacheValidator()); |
942 ASSERT(!resource->resourceToRevalidate()); | 957 ASSERT(!resource->resourceToRevalidate()); |
943 ASSERT(!isControlledByServiceWorker()); | 958 ASSERT(!isControlledByServiceWorker()); |
944 | 959 |
945 ResourceRequest revalidatingRequest(resource->resourceRequest()); | 960 ResourceRequest revalidatingRequest(resource->resourceRequest()); |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 ResourceLoaderHost::trace(visitor); | 1667 ResourceLoaderHost::trace(visitor); |
1653 } | 1668 } |
1654 | 1669 |
1655 ResourceFetcher* ResourceFetcher::toResourceFetcher(ResourceLoaderHost* host) | 1670 ResourceFetcher* ResourceFetcher::toResourceFetcher(ResourceLoaderHost* host) |
1656 { | 1671 { |
1657 ASSERT(host->objectType() == ResourceLoaderHost::ResourceFetcherType); | 1672 ASSERT(host->objectType() == ResourceLoaderHost::ResourceFetcherType); |
1658 return static_cast<ResourceFetcher*>(host); | 1673 return static_cast<ResourceFetcher*>(host); |
1659 } | 1674 } |
1660 | 1675 |
1661 } | 1676 } |
OLD | NEW |