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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return 0; | 68 return 0; |
69 } | 69 } |
70 | 70 |
71 void FrameFetchContext::reportLocalLoadFailed(const KURL& url) | 71 void FrameFetchContext::reportLocalLoadFailed(const KURL& url) |
72 { | 72 { |
73 FrameLoader::reportLocalLoadFailed(frame(), url.elidedString()); | 73 FrameLoader::reportLocalLoadFailed(frame(), url.elidedString()); |
74 } | 74 } |
75 | 75 |
76 void FrameFetchContext::addAdditionalRequestHeaders(Document* document, Resource
Request& request, FetchResourceType type) | 76 void FrameFetchContext::addAdditionalRequestHeaders(Document* document, Resource
Request& request, FetchResourceType type) |
77 { | 77 { |
| 78 if (!frame()) |
| 79 return; |
| 80 |
78 bool isMainResource = type == FetchMainResource; | 81 bool isMainResource = type == FetchMainResource; |
79 if (!isMainResource) { | 82 if (!isMainResource) { |
80 String outgoingOrigin; | 83 String outgoingOrigin; |
81 if (!request.didSetHTTPReferrer()) { | 84 if (!request.didSetHTTPReferrer()) { |
82 outgoingOrigin = document->outgoingOrigin(); | 85 outgoingOrigin = document->outgoingOrigin(); |
83 request.setHTTPReferrer(SecurityPolicy::generateReferrer(document->r
eferrerPolicy(), request.url(), document->outgoingReferrer())); | 86 request.setHTTPReferrer(SecurityPolicy::generateReferrer(document->r
eferrerPolicy(), request.url(), document->outgoingReferrer())); |
84 } else { | 87 } else { |
85 RELEASE_ASSERT(SecurityPolicy::generateReferrer(request.referrerPoli
cy(), request.url(), request.httpReferrer()).referrer == request.httpReferrer())
; | 88 RELEASE_ASSERT(SecurityPolicy::generateReferrer(request.referrerPoli
cy(), request.url(), request.httpReferrer()).referrer == request.httpReferrer())
; |
86 outgoingOrigin = SecurityOrigin::createFromString(request.httpReferr
er())->toString(); | 89 outgoingOrigin = SecurityOrigin::createFromString(request.httpReferr
er())->toString(); |
87 } | 90 } |
88 | 91 |
89 request.addHTTPOriginIfNeeded(AtomicString(outgoingOrigin)); | 92 request.addHTTPOriginIfNeeded(AtomicString(outgoingOrigin)); |
90 } | 93 } |
91 | 94 |
92 // The remaining modifications are only necessary for HTTP and HTTPS. | 95 // The remaining modifications are only necessary for HTTP and HTTPS. |
93 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) | 96 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) |
94 return; | 97 return; |
95 | 98 |
96 frame()->loader().applyUserAgent(request); | 99 frame()->loader().applyUserAgent(request); |
97 } | 100 } |
98 | 101 |
99 void FrameFetchContext::setFirstPartyForCookies(ResourceRequest& request) | 102 void FrameFetchContext::setFirstPartyForCookies(ResourceRequest& request) |
100 { | 103 { |
| 104 if (!frame()) |
| 105 return; |
| 106 |
101 if (frame()->tree().top()->isLocalFrame()) | 107 if (frame()->tree().top()->isLocalFrame()) |
102 request.setFirstPartyForCookies(toLocalFrame(frame()->tree().top())->doc
ument()->firstPartyForCookies()); | 108 request.setFirstPartyForCookies(toLocalFrame(frame()->tree().top())->doc
ument()->firstPartyForCookies()); |
103 } | 109 } |
104 | 110 |
105 CachePolicy FrameFetchContext::cachePolicy(Document* document) const | 111 CachePolicy FrameFetchContext::cachePolicy(Document* document) const |
106 { | 112 { |
107 if (!frame()) | 113 if (!frame()) |
108 return CachePolicyVerify; | 114 return CachePolicyVerify; |
109 | 115 |
110 if (document && document->loadEventFinished()) | 116 if (document && document->loadEventFinished()) |
(...skipping 24 matching lines...) Expand all Loading... |
135 // |loader| can be null if the resource is loaded from imported document. | 141 // |loader| can be null if the resource is loaded from imported document. |
136 // This means inspector, which uses DocumentLoader as an grouping entity, | 142 // This means inspector, which uses DocumentLoader as an grouping entity, |
137 // cannot see imported documents. | 143 // cannot see imported documents. |
138 inline DocumentLoader* FrameFetchContext::ensureLoader(DocumentLoader* loader) | 144 inline DocumentLoader* FrameFetchContext::ensureLoader(DocumentLoader* loader) |
139 { | 145 { |
140 return loader ? loader : frame()->loader().documentLoader(); | 146 return loader ? loader : frame()->loader().documentLoader(); |
141 } | 147 } |
142 | 148 |
143 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) | 149 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) |
144 { | 150 { |
| 151 if (!frame()) |
| 152 return; |
| 153 |
145 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); | 154 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); |
146 } | 155 } |
147 | 156 |
148 void FrameFetchContext::dispatchWillSendRequest(DocumentLoader* loader, unsigned
long identifier, ResourceRequest& request, const ResourceResponse& redirectResp
onse, const FetchInitiatorInfo& initiatorInfo) | 157 void FrameFetchContext::dispatchWillSendRequest(DocumentLoader* loader, unsigned
long identifier, ResourceRequest& request, const ResourceResponse& redirectResp
onse, const FetchInitiatorInfo& initiatorInfo) |
149 { | 158 { |
| 159 if (!frame()) |
| 160 return; |
| 161 |
150 frame()->loader().applyUserAgent(request); | 162 frame()->loader().applyUserAgent(request); |
151 frame()->loader().client()->dispatchWillSendRequest(loader, identifier, requ
est, redirectResponse); | 163 frame()->loader().client()->dispatchWillSendRequest(loader, identifier, requ
est, redirectResponse); |
152 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceSendRequest", "data", InspectorSendRequestEvent::data(identifier, frame(), req
uest)); | 164 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceSendRequest", "data", InspectorSendRequestEvent::data(identifier, frame(), req
uest)); |
153 InspectorInstrumentation::willSendRequest(frame(), identifier, ensureLoader(
loader), request, redirectResponse, initiatorInfo); | 165 InspectorInstrumentation::willSendRequest(frame(), identifier, ensureLoader(
loader), request, redirectResponse, initiatorInfo); |
154 } | 166 } |
155 | 167 |
156 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(const ResourceReq
uest& request, const ResourceResponse& response) | 168 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(const ResourceReq
uest& request, const ResourceResponse& response) |
157 { | 169 { |
| 170 if (!frame()) |
| 171 return; |
| 172 |
158 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(request,
response); | 173 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(request,
response); |
159 } | 174 } |
160 | 175 |
161 void FrameFetchContext::dispatchDidReceiveResponse(DocumentLoader* loader, unsig
ned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader) | 176 void FrameFetchContext::dispatchDidReceiveResponse(DocumentLoader* loader, unsig
ned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader) |
162 { | 177 { |
| 178 if (!frame()) |
| 179 return; |
| 180 |
163 frame()->loader().progress().incrementProgress(identifier, r); | 181 frame()->loader().progress().incrementProgress(identifier, r); |
164 frame()->loader().client()->dispatchDidReceiveResponse(loader, identifier, r
); | 182 frame()->loader().client()->dispatchDidReceiveResponse(loader, identifier, r
); |
165 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, fram
e(), r)); | 183 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, fram
e(), r)); |
166 DocumentLoader* documentLoader = ensureLoader(loader); | 184 DocumentLoader* documentLoader = ensureLoader(loader); |
167 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do
cumentLoader, r, resourceLoader); | 185 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do
cumentLoader, r, resourceLoader); |
168 // It is essential that inspector gets resource response BEFORE console. | 186 // It is essential that inspector gets resource response BEFORE console. |
169 frame()->console().reportResourceResponseReceived(documentLoader, identifier
, r); | 187 frame()->console().reportResourceResponseReceived(documentLoader, identifier
, r); |
170 } | 188 } |
171 | 189 |
172 void FrameFetchContext::dispatchDidReceiveData(DocumentLoader*, unsigned long id
entifier, const char* data, int dataLength, int encodedDataLength) | 190 void FrameFetchContext::dispatchDidReceiveData(DocumentLoader*, unsigned long id
entifier, const char* data, int dataLength, int encodedDataLength) |
173 { | 191 { |
| 192 if (!frame()) |
| 193 return; |
| 194 |
174 frame()->loader().progress().incrementProgress(identifier, dataLength); | 195 frame()->loader().progress().incrementProgress(identifier, dataLength); |
175 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceivedData", "data", InspectorReceiveDataEvent::data(identifier, frame(), en
codedDataLength)); | 196 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceivedData", "data", InspectorReceiveDataEvent::data(identifier, frame(), en
codedDataLength)); |
176 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng
th, encodedDataLength); | 197 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng
th, encodedDataLength); |
177 } | 198 } |
178 | 199 |
179 void FrameFetchContext::dispatchDidDownloadData(DocumentLoader*, unsigned long i
dentifier, int dataLength, int encodedDataLength) | 200 void FrameFetchContext::dispatchDidDownloadData(DocumentLoader*, unsigned long i
dentifier, int dataLength, int encodedDataLength) |
180 { | 201 { |
| 202 if (!frame()) |
| 203 return; |
| 204 |
181 frame()->loader().progress().incrementProgress(identifier, dataLength); | 205 frame()->loader().progress().incrementProgress(identifier, dataLength); |
182 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceivedData", "data", InspectorReceiveDataEvent::data(identifier, frame(), en
codedDataLength)); | 206 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceivedData", "data", InspectorReceiveDataEvent::data(identifier, frame(), en
codedDataLength)); |
183 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength,
encodedDataLength); | 207 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength,
encodedDataLength); |
184 } | 208 } |
185 | 209 |
186 void FrameFetchContext::dispatchDidFinishLoading(DocumentLoader* loader, unsigne
d long identifier, double finishTime, int64_t encodedDataLength) | 210 void FrameFetchContext::dispatchDidFinishLoading(DocumentLoader* loader, unsigne
d long identifier, double finishTime, int64_t encodedDataLength) |
187 { | 211 { |
| 212 if (!frame()) |
| 213 return; |
| 214 |
188 frame()->loader().progress().completeProgress(identifier); | 215 frame()->loader().progress().completeProgress(identifier); |
189 frame()->loader().client()->dispatchDidFinishLoading(loader, identifier); | 216 frame()->loader().client()->dispatchDidFinishLoading(loader, identifier); |
190 | 217 |
191 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceFinish", "data", InspectorResourceFinishEvent::data(identifier, finishTime, fa
lse)); | 218 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceFinish", "data", InspectorResourceFinishEvent::data(identifier, finishTime, fa
lse)); |
192 InspectorInstrumentation::didFinishLoading(frame(), identifier, ensureLoader
(loader), finishTime, encodedDataLength); | 219 InspectorInstrumentation::didFinishLoading(frame(), identifier, ensureLoader
(loader), finishTime, encodedDataLength); |
193 } | 220 } |
194 | 221 |
195 void FrameFetchContext::dispatchDidFail(DocumentLoader* loader, unsigned long id
entifier, const ResourceError& error, bool isInternalRequest) | 222 void FrameFetchContext::dispatchDidFail(DocumentLoader* loader, unsigned long id
entifier, const ResourceError& error, bool isInternalRequest) |
196 { | 223 { |
197 if (!frame()) | 224 if (!frame()) |
(...skipping 19 matching lines...) Expand all Loading... |
217 dispatchDidFinishLoading(ensureLoader(loader), identifier, 0, 0); | 244 dispatchDidFinishLoading(ensureLoader(loader), identifier, 0, 0); |
218 } | 245 } |
219 | 246 |
220 DEFINE_TRACE(FrameFetchContext) | 247 DEFINE_TRACE(FrameFetchContext) |
221 { | 248 { |
222 visitor->trace(m_document); | 249 visitor->trace(m_document); |
223 FetchContext::trace(visitor); | 250 FetchContext::trace(visitor); |
224 } | 251 } |
225 | 252 |
226 } // namespace blink | 253 } // namespace blink |
OLD | NEW |