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

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

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address review comments Created 4 years, 10 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
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return Resource::Media; 180 return Resource::Media;
181 if (equalIgnoringCase(as, "font")) 181 if (equalIgnoringCase(as, "font"))
182 return Resource::Font; 182 return Resource::Font;
183 if (equalIgnoringCase(as, "track")) 183 if (equalIgnoringCase(as, "track"))
184 return Resource::TextTrack; 184 return Resource::TextTrack;
185 if (document && !as.isEmpty()) 185 if (document && !as.isEmpty())
186 document->addConsoleMessage(ConsoleMessage::create(OtherMessageSource, W arningMessageLevel, String("<link rel=preload> must have a valid `as` value"))); 186 document->addConsoleMessage(ConsoleMessage::create(OtherMessageSource, W arningMessageLevel, String("<link rel=preload> must have a valid `as` value")));
187 return Resource::LinkPreload; 187 return Resource::LinkPreload;
188 } 188 }
189 189
190 void LinkLoader::createLinkPreloadResourceClient(ResourcePtr<Resource> resource) 190 void LinkLoader::createLinkPreloadResourceClient(Resource* resource)
191 { 191 {
192 if (!resource) 192 if (!resource)
193 return; 193 return;
194 switch (resource->type()) { 194 switch (resource->type()) {
195 case Resource::Image: 195 case Resource::Image:
196 m_linkPreloadResourceClient = LinkPreloadImageResourceClient::create(thi s, toImageResource(resource.get())); 196 m_linkPreloadResourceClient = LinkPreloadImageResourceClient::create(thi s, toImageResource(resource));
197 break; 197 break;
198 case Resource::Script: 198 case Resource::Script:
199 m_linkPreloadResourceClient = LinkPreloadScriptResourceClient::create(th is, toScriptResource(resource.get())); 199 m_linkPreloadResourceClient = LinkPreloadScriptResourceClient::create(th is, toScriptResource(resource));
200 break; 200 break;
201 case Resource::CSSStyleSheet: 201 case Resource::CSSStyleSheet:
202 m_linkPreloadResourceClient = LinkPreloadStyleResourceClient::create(thi s, toCSSStyleSheetResource(resource.get())); 202 m_linkPreloadResourceClient = LinkPreloadStyleResourceClient::create(thi s, toCSSStyleSheetResource(resource));
203 break; 203 break;
204 case Resource::Font: 204 case Resource::Font:
205 m_linkPreloadResourceClient = LinkPreloadFontResourceClient::create(this , toFontResource(resource.get())); 205 m_linkPreloadResourceClient = LinkPreloadFontResourceClient::create(this , toFontResource(resource));
206 break; 206 break;
207 case Resource::Media: 207 case Resource::Media:
208 case Resource::TextTrack: 208 case Resource::TextTrack:
209 case Resource::Raw: 209 case Resource::Raw:
210 case Resource::LinkPreload: 210 case Resource::LinkPreload:
211 m_linkPreloadResourceClient = LinkPreloadRawResourceClient::create(this, toRawResource(resource.get())); 211 m_linkPreloadResourceClient = LinkPreloadRawResourceClient::create(this, toRawResource(resource));
212 break; 212 break;
213 default: 213 default:
214 ASSERT_NOT_REACHED(); 214 ASSERT_NOT_REACHED();
215 } 215 }
216 } 216 }
217 217
218 static ResourcePtr<Resource> preloadIfNeeded(const LinkRelAttribute& relAttribut e, const KURL& href, Document& document, const String& as, CrossOriginAttributeV alue crossOrigin, LinkCaller caller) 218 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute, const KUR L& href, Document& document, const String& as, CrossOriginAttributeValue crossOr igin, LinkCaller caller)
219 { 219 {
220 if (!document.loader() || !relAttribute.isLinkPreload()) 220 if (!document.loader() || !relAttribute.isLinkPreload())
221 return nullptr; 221 return nullptr;
222 222
223 UseCounter::count(document, UseCounter::LinkRelPreload); 223 UseCounter::count(document, UseCounter::LinkRelPreload);
224 ASSERT(RuntimeEnabledFeatures::linkPreloadEnabled()); 224 ASSERT(RuntimeEnabledFeatures::linkPreloadEnabled());
225 if (!href.isValid() || href.isEmpty()) { 225 if (!href.isValid() || href.isEmpty()) {
226 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, Wa rningMessageLevel, String("<link rel=preload> has an invalid `href` value"))); 226 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, Wa rningMessageLevel, String("<link rel=preload> has an invalid `href` value")));
227 return nullptr; 227 return nullptr;
228 } 228 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 DEFINE_TRACE(LinkLoader) 329 DEFINE_TRACE(LinkLoader)
330 { 330 {
331 visitor->trace(m_client); 331 visitor->trace(m_client);
332 visitor->trace(m_prerender); 332 visitor->trace(m_prerender);
333 visitor->trace(m_linkPreloadResourceClient); 333 visitor->trace(m_linkPreloadResourceClient);
334 ResourceOwner<Resource, ResourceClient>::trace(visitor); 334 ResourceOwner<Resource, ResourceClient>::trace(visitor);
335 } 335 }
336 336
337 } // namespace blink 337 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkLoader.h ('k') | third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698