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

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

Issue 1107003002: Check the nullable Document::settings() before accessing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « LayoutTests/fast/dom/HTMLLinkElement/link-preload-settings-no-crash-expected.txt ('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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo urce, DebugMessageLevel, String("DNS prefetch triggered for " + href.host()))); 125 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo urce, DebugMessageLevel, String("DNS prefetch triggered for " + href.host())));
126 prefetchDNS(href.host()); 126 prefetchDNS(href.host());
127 } 127 }
128 } 128 }
129 } 129 }
130 130
131 static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document) 131 static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document)
132 { 132 {
133 if (relAttribute.isPreconnect() && href.isValid()) { 133 if (relAttribute.isPreconnect() && href.isValid()) {
134 ASSERT(RuntimeEnabledFeatures::linkPreconnectEnabled()); 134 ASSERT(RuntimeEnabledFeatures::linkPreconnectEnabled());
135 if (document.settings()->logDnsPrefetchAndPreconnect()) 135 Settings* settings = document.settings();
136 if (settings && settings->logDnsPrefetchAndPreconnect())
136 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , DebugMessageLevel, String("Preconnect triggered for " + href.host()))); 137 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , DebugMessageLevel, String("Preconnect triggered for " + href.host())));
137 preconnect(href); 138 preconnect(href);
138 } 139 }
139 } 140 }
140 141
141 // TODO(yoav): Replace Resource:Type here with some way that conveys priority bu t not context. 142 // TODO(yoav): Replace Resource:Type here with some way that conveys priority bu t not context.
142 static bool getTypeFromAsAttribute(const String& as, Resource::Type& type) 143 static bool getTypeFromAsAttribute(const String& as, Resource::Type& type)
143 { 144 {
144 if (as.isEmpty()) 145 if (as.isEmpty())
145 return false; 146 return false;
(...skipping 10 matching lines...) Expand all
156 if (!href.isValid() || href.isEmpty()) { 157 if (!href.isValid() || href.isEmpty()) {
157 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , WarningMessageLevel, String("<link rel=preload> has an invalid `href` value")) ); 158 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , WarningMessageLevel, String("<link rel=preload> has an invalid `href` value")) );
158 return; 159 return;
159 } 160 }
160 Resource::Type type; 161 Resource::Type type;
161 if (!getTypeFromAsAttribute(as, type)) { 162 if (!getTypeFromAsAttribute(as, type)) {
162 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , WarningMessageLevel, String("<link rel=preload> must have a valid `as` value") )); 163 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , WarningMessageLevel, String("<link rel=preload> must have a valid `as` value") ));
163 return; 164 return;
164 } 165 }
165 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe tchInitiatorTypeNames::link); 166 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe tchInitiatorTypeNames::link);
166 if (document.settings()->logPreload()) 167 Settings* settings = document.settings();
168 if (settings && settings->logPreload())
167 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , DebugMessageLevel, String("Preload triggered for " + href.host() + href.path() ))); 169 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource , DebugMessageLevel, String("Preload triggered for " + href.host() + href.path() )));
168 setResource(document.fetcher()->fetchLinkPreloadResource(type, linkReque st)); 170 setResource(document.fetcher()->fetchLinkPreloadResource(type, linkReque st));
169 } 171 }
170 } 172 }
171 173
172 bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen t) 174 bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen t)
173 { 175 {
174 if (!document) 176 if (!document)
175 return false; 177 return false;
176 LinkHeaderSet headerSet(headerValue); 178 LinkHeaderSet headerSet(headerValue);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 m_prerender.clear(); 236 m_prerender.clear();
235 } 237 }
236 } 238 }
237 239
238 DEFINE_TRACE(LinkLoader) 240 DEFINE_TRACE(LinkLoader)
239 { 241 {
240 visitor->trace(m_prerender); 242 visitor->trace(m_prerender);
241 } 243 }
242 244
243 } 245 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/HTMLLinkElement/link-preload-settings-no-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698