OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/loader/FrameFetchContext.h" | 32 #include "core/loader/FrameFetchContext.h" |
33 | 33 |
34 #include "bindings/core/v8/ScriptController.h" | 34 #include "bindings/core/v8/ScriptController.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/fetch/ClientHintsPreferences.h" | 36 #include "core/fetch/ClientHintsPreferences.h" |
| 37 #include "core/fetch/UniqueIdentifier.h" |
37 #include "core/frame/FrameConsole.h" | 38 #include "core/frame/FrameConsole.h" |
38 #include "core/frame/FrameHost.h" | 39 #include "core/frame/FrameHost.h" |
39 #include "core/frame/FrameView.h" | 40 #include "core/frame/FrameView.h" |
40 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
41 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
42 #include "core/html/HTMLFrameOwnerElement.h" | 43 #include "core/html/HTMLFrameOwnerElement.h" |
43 #include "core/html/imports/HTMLImportsController.h" | 44 #include "core/html/imports/HTMLImportsController.h" |
44 #include "core/inspector/ConsoleMessage.h" | 45 #include "core/inspector/ConsoleMessage.h" |
45 #include "core/inspector/InspectorInstrumentation.h" | 46 #include "core/inspector/InspectorInstrumentation.h" |
46 #include "core/inspector/InspectorTraceEvents.h" | 47 #include "core/inspector/InspectorTraceEvents.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 215 } |
215 | 216 |
216 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) | 217 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) |
217 { | 218 { |
218 frame()->loader().applyUserAgent(request); | 219 frame()->loader().applyUserAgent(request); |
219 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); | 220 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); |
220 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ
est)); | 221 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ
est)); |
221 InspectorInstrumentation::willSendRequest(frame(), identifier, ensureLoaderF
orNotifications(), request, redirectResponse, initiatorInfo); | 222 InspectorInstrumentation::willSendRequest(frame(), identifier, ensureLoaderF
orNotifications(), request, redirectResponse, initiatorInfo); |
222 } | 223 } |
223 | 224 |
224 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(const ResourceReq
uest& request, const ResourceResponse& response) | |
225 { | |
226 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(request,
response); | |
227 } | |
228 | |
229 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con
st ResourceResponse& response, ResourceLoader* resourceLoader) | 225 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con
st ResourceResponse& response, ResourceLoader* resourceLoader) |
230 { | 226 { |
231 MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddre
ss()); | 227 MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddre
ss()); |
232 LinkLoader::loadLinkFromHeader(response.httpHeaderField("Link"), frame()->do
cument(), NetworkHintsInterfaceImpl()); | 228 LinkLoader::loadLinkFromHeader(response.httpHeaderField("Link"), frame()->do
cument(), NetworkHintsInterfaceImpl()); |
233 if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { | 229 if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { |
234 ResourceFetcher* fetcher = nullptr; | 230 ResourceFetcher* fetcher = nullptr; |
235 if (frame()->document()) | 231 if (frame()->document()) |
236 fetcher = frame()->document()->fetcher(); | 232 fetcher = frame()->document()->fetcher(); |
237 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe
ader(response.httpHeaderField("accept-ch"), fetcher); | 233 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe
ader(response.httpHeaderField("accept-ch"), fetcher); |
238 } | 234 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 { | 269 { |
274 frame()->loader().progress().completeProgress(identifier); | 270 frame()->loader().progress().completeProgress(identifier); |
275 frame()->loader().client()->dispatchDidFinishLoading(m_documentLoader, ident
ifier); | 271 frame()->loader().client()->dispatchDidFinishLoading(m_documentLoader, ident
ifier); |
276 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOP
E_THREAD, "data", InspectorResourceFinishEvent::data(identifier, 0, true)); | 272 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOP
E_THREAD, "data", InspectorResourceFinishEvent::data(identifier, 0, true)); |
277 InspectorInstrumentation::didFailLoading(frame(), identifier, error); | 273 InspectorInstrumentation::didFailLoading(frame(), identifier, error); |
278 // Notification to FrameConsole should come AFTER InspectorInstrumentation c
all, DevTools front-end relies on this. | 274 // Notification to FrameConsole should come AFTER InspectorInstrumentation c
all, DevTools front-end relies on this. |
279 if (!isInternalRequest) | 275 if (!isInternalRequest) |
280 frame()->console().didFailLoading(identifier, error); | 276 frame()->console().didFailLoading(identifier, error); |
281 } | 277 } |
282 | 278 |
283 void FrameFetchContext::sendRemainingDelegateMessages(unsigned long identifier,
const ResourceResponse& response, int dataLength) | 279 |
| 280 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(const Resource* r
esource) |
284 { | 281 { |
| 282 ResourceRequest request(resource->url()); |
| 283 unsigned long identifier = createUniqueIdentifier(); |
| 284 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(request,
resource->response()); |
| 285 dispatchWillSendRequest(identifier, request, ResourceResponse(), resource->o
ptions().initiatorInfo); |
| 286 |
285 InspectorInstrumentation::markResourceAsCached(frame(), identifier); | 287 InspectorInstrumentation::markResourceAsCached(frame(), identifier); |
286 if (!response.isNull()) | 288 if (!resource->response().isNull()) |
287 dispatchDidReceiveResponse(identifier, response); | 289 dispatchDidReceiveResponse(identifier, resource->response()); |
288 | 290 |
289 if (dataLength > 0) | 291 if (resource->encodedSize() > 0) |
290 dispatchDidReceiveData(identifier, 0, dataLength, 0); | 292 dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0); |
291 | 293 |
292 dispatchDidFinishLoading(identifier, 0, 0); | 294 dispatchDidFinishLoading(identifier, 0, 0); |
293 } | 295 } |
294 | 296 |
295 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const | 297 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const |
296 { | 298 { |
297 if (!m_documentLoader) | 299 if (!m_documentLoader) |
298 return true; | 300 return true; |
299 if (type == Resource::MainResource) | 301 if (type == Resource::MainResource) |
300 return m_documentLoader == frame()->loader().provisionalDocumentLoader()
; | 302 return m_documentLoader == frame()->loader().provisionalDocumentLoader()
; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 677 |
676 | 678 |
677 DEFINE_TRACE(FrameFetchContext) | 679 DEFINE_TRACE(FrameFetchContext) |
678 { | 680 { |
679 visitor->trace(m_document); | 681 visitor->trace(m_document); |
680 visitor->trace(m_documentLoader); | 682 visitor->trace(m_documentLoader); |
681 FetchContext::trace(visitor); | 683 FetchContext::trace(visitor); |
682 } | 684 } |
683 | 685 |
684 } // namespace blink | 686 } // namespace blink |
OLD | NEW |