Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/core/loader/LinkLoader.cpp

Issue 23833004: Have LinkLoader::loadLink() take a Document reference in parameter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/LinkLoader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void LinkLoader::didSendLoadForPrerender() 97 void LinkLoader::didSendLoadForPrerender()
98 { 98 {
99 m_client->didSendLoadForLinkPrerender(); 99 m_client->didSendLoadForLinkPrerender();
100 } 100 }
101 101
102 void LinkLoader::didSendDOMContentLoadedForPrerender() 102 void LinkLoader::didSendDOMContentLoadedForPrerender()
103 { 103 {
104 m_client->didSendDOMContentLoadedForLinkPrerender(); 104 m_client->didSendDOMContentLoadedForLinkPrerender();
105 } 105 }
106 106
107 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty pe, const KURL& href, Document* document) 107 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty pe, const KURL& href, Document& document)
108 { 108 {
109 if (relAttribute.isDNSPrefetch()) { 109 if (relAttribute.isDNSPrefetch()) {
110 Settings* settings = document->settings(); 110 Settings* settings = document.settings();
111 // FIXME: The href attribute of the link element can be in "//hostname" form, and we shouldn't attempt 111 // FIXME: The href attribute of the link element can be in "//hostname" form, and we shouldn't attempt
112 // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=4885 7>. 112 // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=4885 7>.
113 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && ! href.isEmpty()) 113 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && ! href.isEmpty())
114 prefetchDNS(href.host()); 114 prefetchDNS(href.host());
115 } 115 }
116 116
117 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h ref.isValid() && document->frame()) { 117 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h ref.isValid() && document.frame()) {
118 if (!m_client->shouldLoadLink()) 118 if (!m_client->shouldLoadLink())
119 return false; 119 return false;
120 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link Subresource : Resource::LinkPrefetch; 120 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link Subresource : Resource::LinkPrefetch;
121 FetchRequest linkRequest(ResourceRequest(document->completeURL(href)), F etchInitiatorTypeNames::link); 121 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe tchInitiatorTypeNames::link);
122 if (m_cachedLinkResource) { 122 if (m_cachedLinkResource) {
123 m_cachedLinkResource->removeClient(this); 123 m_cachedLinkResource->removeClient(this);
124 m_cachedLinkResource = 0; 124 m_cachedLinkResource = 0;
125 } 125 }
126 m_cachedLinkResource = document->fetcher()->fetchLinkResource(type, link Request); 126 m_cachedLinkResource = document.fetcher()->fetchLinkResource(type, linkR equest);
127 if (m_cachedLinkResource) 127 if (m_cachedLinkResource)
128 m_cachedLinkResource->addClient(this); 128 m_cachedLinkResource->addClient(this);
129 } 129 }
130 130
131 if (relAttribute.isLinkPrerender()) { 131 if (relAttribute.isLinkPrerender()) {
132 if (!m_prerenderHandle) { 132 if (!m_prerenderHandle) {
133 m_prerenderHandle = document->prerenderer()->render(this, href); 133 m_prerenderHandle = document.prerenderer()->render(this, href);
134 } else if (m_prerenderHandle->url() != href) { 134 } else if (m_prerenderHandle->url() != href) {
135 m_prerenderHandle->cancel(); 135 m_prerenderHandle->cancel();
136 m_prerenderHandle = document->prerenderer()->render(this, href); 136 m_prerenderHandle = document.prerenderer()->render(this, href);
137 } 137 }
138 } else if (m_prerenderHandle) { 138 } else if (m_prerenderHandle) {
139 m_prerenderHandle->cancel(); 139 m_prerenderHandle->cancel();
140 m_prerenderHandle = 0; 140 m_prerenderHandle = 0;
141 } 141 }
142 return true; 142 return true;
143 } 143 }
144 144
145 void LinkLoader::released() 145 void LinkLoader::released()
146 { 146 {
147 // Only prerenders need treatment here; other links either use the Resource interface, or are notionally 147 // Only prerenders need treatment here; other links either use the Resource interface, or are notionally
148 // atomic (dns prefetch). 148 // atomic (dns prefetch).
149 if (m_prerenderHandle) { 149 if (m_prerenderHandle) {
150 m_prerenderHandle->cancel(); 150 m_prerenderHandle->cancel();
151 m_prerenderHandle->removeClient(); 151 m_prerenderHandle->removeClient();
152 m_prerenderHandle.clear(); 152 m_prerenderHandle.clear();
153 } 153 }
154 } 154 }
155 155
156 } 156 }
OLDNEW
« no previous file with comments | « Source/core/loader/LinkLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698