OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 FetchInitiatorInfo initiatorInfo; | 118 FetchInitiatorInfo initiatorInfo; |
119 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; | 119 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; |
120 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo
rtURL)->isSameSchemeHostPort(frame->document()->getSecurityOrigin()) ? AllowStor
edCredentials : DoNotAllowStoredCredentials); | 120 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo
rtURL)->isSameSchemeHostPort(frame->document()->getSecurityOrigin()) ? AllowStor
edCredentials : DoNotAllowStoredCredentials); |
121 } | 121 } |
122 | 122 |
123 void PingLoader::start(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) | 123 void PingLoader::start(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) |
124 { | 124 { |
125 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url())) | 125 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url())) |
126 return; | 126 return; |
127 | 127 |
128 // Leak the ping loader, since it will kill itself as soon as it receives a
response. | 128 // The loader keeps itself alive until it receives a response and disposes i
tself. |
129 RawPtr<PingLoader> loader = new PingLoader(frame, request, initiatorInfo, cr
edentialsAllowed); | 129 PingLoader* loader = new PingLoader(frame, request, initiatorInfo, credentia
lsAllowed); |
130 loader->ref(); | 130 ASSERT_UNUSED(loader, loader); |
131 } | 131 } |
132 | 132 |
133 PingLoader::PingLoader(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) | 133 PingLoader::PingLoader(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) |
134 : LocalFrameLifecycleObserver(frame) | 134 : LocalFrameLifecycleObserver(frame) |
135 , m_timeout(this, &PingLoader::timeout) | 135 , m_timeout(this, &PingLoader::timeout) |
136 , m_url(request.url()) | 136 , m_url(request.url()) |
137 , m_identifier(createUniqueIdentifier()) | 137 , m_identifier(createUniqueIdentifier()) |
| 138 , m_keepAlive(this) |
138 { | 139 { |
139 frame->loader().client()->didDispatchPingLoader(request.url()); | 140 frame->loader().client()->didDispatchPingLoader(request.url()); |
140 | 141 |
141 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(m_identifier, frame, requ
est)); | 142 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(m_identifier, frame, requ
est)); |
142 InspectorInstrumentation::willSendRequest(frame, m_identifier, frame->loader
().documentLoader(), request, ResourceResponse(), initiatorInfo); | 143 InspectorInstrumentation::willSendRequest(frame, m_identifier, frame->loader
().documentLoader(), request, ResourceResponse(), initiatorInfo); |
143 | 144 |
144 m_loader = adoptPtr(Platform::current()->createURLLoader()); | 145 m_loader = adoptPtr(Platform::current()->createURLLoader()); |
145 ASSERT(m_loader); | 146 ASSERT(m_loader); |
146 WrappedResourceRequest wrappedRequest(request); | 147 WrappedResourceRequest wrappedRequest(request); |
147 wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCr
edentials); | 148 wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCr
edentials); |
148 m_loader->loadAsynchronously(wrappedRequest, this); | 149 m_loader->loadAsynchronously(wrappedRequest, this); |
149 | 150 |
150 // If the server never responds, FrameLoader won't be able to cancel this lo
ad and | 151 // If the server never responds, FrameLoader won't be able to cancel this lo
ad and |
151 // we'll sit here waiting forever. Set a very generous timeout, just in case
. | 152 // we'll sit here waiting forever. Set a very generous timeout, just in case
. |
152 m_timeout.startOneShot(60000, BLINK_FROM_HERE); | 153 m_timeout.startOneShot(60000, BLINK_FROM_HERE); |
153 } | 154 } |
154 | 155 |
155 PingLoader::~PingLoader() | 156 PingLoader::~PingLoader() |
156 { | 157 { |
157 if (m_loader) | 158 if (m_loader) |
158 m_loader->cancel(); | 159 m_loader->cancel(); |
159 } | 160 } |
160 | 161 |
161 void PingLoader::dispose() | 162 void PingLoader::dispose() |
162 { | 163 { |
163 if (m_loader) { | 164 if (m_loader) { |
164 m_loader->cancel(); | 165 m_loader->cancel(); |
165 m_loader = nullptr; | 166 m_loader = nullptr; |
166 } | 167 } |
167 deref(); | 168 m_keepAlive.clear(); |
168 } | 169 } |
169 | 170 |
170 void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& respons
e) | 171 void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& respons
e) |
171 { | 172 { |
172 if (LocalFrame* frame = this->frame()) { | 173 if (LocalFrame* frame = this->frame()) { |
173 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | 174 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; |
174 const ResourceResponse& resourceResponse = response.toResourceResponse()
; | 175 const ResourceResponse& resourceResponse = response.toResourceResponse()
; |
175 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier
, 0, resourceResponse, 0); | 176 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier
, 0, resourceResponse, 0); |
176 didFailLoading(frame); | 177 didFailLoading(frame); |
177 } | 178 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError:
:cancelledError(m_url)); | 220 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError:
:cancelledError(m_url)); |
220 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError(
m_url)); | 221 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError(
m_url)); |
221 } | 222 } |
222 | 223 |
223 DEFINE_TRACE(PingLoader) | 224 DEFINE_TRACE(PingLoader) |
224 { | 225 { |
225 LocalFrameLifecycleObserver::trace(visitor); | 226 LocalFrameLifecycleObserver::trace(visitor); |
226 } | 227 } |
227 | 228 |
228 } // namespace blink | 229 } // namespace blink |
OLD | NEW |