Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 * | 29 * |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 #include "core/loader/LinkLoader.h" | 33 #include "core/loader/LinkLoader.h" |
| 34 | 34 |
| 35 #include "FetchInitiatorTypeNames.h" | 35 #include "FetchInitiatorTypeNames.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/fetch/FetchRequest.h" | 37 #include "core/fetch/FetchRequest.h" |
| 38 #include "core/fetch/ResourceFetcher.h" | 38 #include "core/fetch/ResourceFetcher.h" |
| 39 #include "core/frame/Settings.h" | |
| 39 #include "core/html/LinkRelAttribute.h" | 40 #include "core/html/LinkRelAttribute.h" |
| 40 #include "core/loader/PrerenderHandle.h" | 41 #include "core/loader/PrerenderHandle.h" |
| 41 #include "core/frame/Settings.h" | 42 #include "platform/Prerender.h" |
| 42 #include "platform/network/DNS.h" | 43 #include "platform/network/DNS.h" |
| 43 | 44 |
| 44 namespace WebCore { | 45 namespace WebCore { |
| 45 | 46 |
| 47 static unsigned PrerenderRelTypesFromRelAttribute(const LinkRelAttribute& relAtt ribute) | |
|
abarth-chromium
2013/12/20 04:32:06
PrerenderRelTypesFromRelAttribute -> prerenderRelT
gavinp
2013/12/20 15:54:00
Done.
| |
| 48 { | |
| 49 unsigned result = 0; | |
| 50 if (relAttribute.isLinkPrerender()) | |
| 51 result |= PrerenderRelTypePrerender; | |
| 52 if (relAttribute.isLinkNext()) | |
| 53 result |= PrerenderRelTypeNext; | |
| 54 | |
| 55 return result; | |
| 56 } | |
| 57 | |
| 46 LinkLoader::LinkLoader(LinkLoaderClient* client) | 58 LinkLoader::LinkLoader(LinkLoaderClient* client) |
| 47 : m_client(client) | 59 : m_client(client) |
| 48 , m_linkLoadTimer(this, &LinkLoader::linkLoadTimerFired) | 60 , m_linkLoadTimer(this, &LinkLoader::linkLoadTimerFired) |
| 49 , m_linkLoadingErrorTimer(this, &LinkLoader::linkLoadingErrorTimerFired) | 61 , m_linkLoadingErrorTimer(this, &LinkLoader::linkLoadingErrorTimerFired) |
| 50 { | 62 { |
| 51 } | 63 } |
| 52 | 64 |
| 53 LinkLoader::~LinkLoader() | 65 LinkLoader::~LinkLoader() |
| 54 { | 66 { |
| 55 } | 67 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 | 122 |
| 111 // FIXME(crbug.com/323096): Should take care of import. | 123 // FIXME(crbug.com/323096): Should take care of import. |
| 112 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h ref.isValid() && document.frame()) { | 124 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h ref.isValid() && document.frame()) { |
| 113 if (!m_client->shouldLoadLink()) | 125 if (!m_client->shouldLoadLink()) |
| 114 return false; | 126 return false; |
| 115 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link Subresource : Resource::LinkPrefetch; | 127 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link Subresource : Resource::LinkPrefetch; |
| 116 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe tchInitiatorTypeNames::link); | 128 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe tchInitiatorTypeNames::link); |
| 117 setResource(document.fetcher()->fetchLinkResource(type, linkRequest)); | 129 setResource(document.fetcher()->fetchLinkResource(type, linkRequest)); |
| 118 } | 130 } |
| 119 | 131 |
| 120 if (relAttribute.isLinkPrerender()) { | 132 if (const unsigned prerenderRelTypes = PrerenderRelTypesFromRelAttribute(rel Attribute)) { |
| 121 if (!m_prerender) { | 133 if (!m_prerender) { |
| 122 m_prerender = PrerenderHandle::create(document, this, href); | 134 m_prerender = PrerenderHandle::create(document, this, href, prerende rRelTypes); |
| 123 } else if (m_prerender->url() != href) { | 135 } else if (m_prerender->url() != href) { |
| 124 m_prerender->cancel(); | 136 m_prerender->cancel(); |
| 125 m_prerender = PrerenderHandle::create(document, this, href); | 137 m_prerender = PrerenderHandle::create(document, this, href, prerende rRelTypes); |
| 126 } | 138 } |
| 127 } else if (m_prerender) { | 139 } else if (m_prerender) { |
| 128 m_prerender->cancel(); | 140 m_prerender->cancel(); |
| 129 m_prerender.clear(); | 141 m_prerender.clear(); |
| 130 } | 142 } |
| 131 return true; | 143 return true; |
| 132 } | 144 } |
| 133 | 145 |
| 134 void LinkLoader::released() | 146 void LinkLoader::released() |
| 135 { | 147 { |
| 136 // Only prerenders need treatment here; other links either use the Resource interface, or are notionally | 148 // Only prerenders need treatment here; other links either use the Resource interface, or are notionally |
| 137 // atomic (dns prefetch). | 149 // atomic (dns prefetch). |
| 138 if (m_prerender) { | 150 if (m_prerender) { |
| 139 m_prerender->cancel(); | 151 m_prerender->cancel(); |
| 140 m_prerender.clear(); | 152 m_prerender.clear(); |
| 141 } | 153 } |
| 142 } | 154 } |
| 143 | 155 |
| 144 } | 156 } |
| OLD | NEW |