| 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/loader/PingLoader.h" | 33 #include "core/loader/PingLoader.h" |
| 34 | 34 |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/fetch/FetchContext.h" | 36 #include "core/fetch/FetchContext.h" |
| 37 #include "core/fetch/FetchInitiatorTypeNames.h" | 37 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 38 #include "core/fetch/ResourceFetcher.h" | 38 #include "core/fetch/ResourceFetcher.h" |
| 39 #include "core/fetch/UniqueIdentifier.h" | 39 #include "core/fetch/UniqueIdentifier.h" |
| 40 #include "core/frame/FrameConsole.h" | 40 #include "core/frame/FrameConsole.h" |
| 41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | 42 #include "core/inspector/InspectorInstrumentation.h" |
| 43 #include "core/inspector/InspectorTraceEvents.h" | |
| 44 #include "core/loader/FrameLoader.h" | 43 #include "core/loader/FrameLoader.h" |
| 45 #include "core/loader/FrameLoaderClient.h" | 44 #include "core/loader/FrameLoaderClient.h" |
| 46 #include "core/loader/MixedContentChecker.h" | 45 #include "core/loader/MixedContentChecker.h" |
| 47 #include "core/page/Page.h" | 46 #include "core/page/Page.h" |
| 48 #include "platform/exported/WrappedResourceRequest.h" | 47 #include "platform/exported/WrappedResourceRequest.h" |
| 49 #include "platform/network/ResourceError.h" | 48 #include "platform/network/ResourceError.h" |
| 50 #include "platform/network/ResourceRequest.h" | 49 #include "platform/network/ResourceRequest.h" |
| 51 #include "platform/network/ResourceResponse.h" | 50 #include "platform/network/ResourceResponse.h" |
| 52 #include "platform/weborigin/SecurityOrigin.h" | 51 #include "platform/weborigin/SecurityOrigin.h" |
| 53 #include "platform/weborigin/SecurityPolicy.h" | 52 #include "platform/weborigin/SecurityPolicy.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 133 } |
| 135 | 134 |
| 136 PingLoader::PingLoader(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) | 135 PingLoader::PingLoader(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) |
| 137 : LocalFrameLifecycleObserver(frame) | 136 : LocalFrameLifecycleObserver(frame) |
| 138 , m_timeout(this, &PingLoader::timeout) | 137 , m_timeout(this, &PingLoader::timeout) |
| 139 , m_url(request.url()) | 138 , m_url(request.url()) |
| 140 , m_identifier(createUniqueIdentifier()) | 139 , m_identifier(createUniqueIdentifier()) |
| 141 { | 140 { |
| 142 frame->loader().client()->didDispatchPingLoader(request.url()); | 141 frame->loader().client()->didDispatchPingLoader(request.url()); |
| 143 | 142 |
| 144 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(m_identifier, frame, requ
est)); | |
| 145 InspectorInstrumentation::willSendRequest(frame, m_identifier, frame->loader
().documentLoader(), request, ResourceResponse(), initiatorInfo); | 143 InspectorInstrumentation::willSendRequest(frame, m_identifier, frame->loader
().documentLoader(), request, ResourceResponse(), initiatorInfo); |
| 146 | 144 |
| 147 m_loader = adoptPtr(Platform::current()->createURLLoader()); | 145 m_loader = adoptPtr(Platform::current()->createURLLoader()); |
| 148 ASSERT(m_loader); | 146 ASSERT(m_loader); |
| 149 WrappedResourceRequest wrappedRequest(request); | 147 WrappedResourceRequest wrappedRequest(request); |
| 150 wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCr
edentials); | 148 wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCr
edentials); |
| 151 m_loader->loadAsynchronously(wrappedRequest, this); | 149 m_loader->loadAsynchronously(wrappedRequest, this); |
| 152 | 150 |
| 153 // 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 |
| 154 // 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
. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 166 if (m_loader) { | 164 if (m_loader) { |
| 167 m_loader->cancel(); | 165 m_loader->cancel(); |
| 168 m_loader = nullptr; | 166 m_loader = nullptr; |
| 169 } | 167 } |
| 170 deref(); | 168 deref(); |
| 171 } | 169 } |
| 172 | 170 |
| 173 void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& respons
e) | 171 void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& respons
e) |
| 174 { | 172 { |
| 175 if (LocalFrame* frame = this->frame()) { | 173 if (LocalFrame* frame = this->frame()) { |
| 176 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | |
| 177 const ResourceResponse& resourceResponse = response.toResourceResponse()
; | 174 const ResourceResponse& resourceResponse = response.toResourceResponse()
; |
| 178 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier
, 0, resourceResponse, 0); | 175 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier
, 0, resourceResponse, 0); |
| 179 didFailLoading(frame); | 176 didFailLoading(frame); |
| 180 } | 177 } |
| 181 dispose(); | 178 dispose(); |
| 182 } | 179 } |
| 183 | 180 |
| 184 void PingLoader::didReceiveData(WebURLLoader*, const char*, int, int) | 181 void PingLoader::didReceiveData(WebURLLoader*, const char*, int, int) |
| 185 { | 182 { |
| 186 if (LocalFrame* frame = this->frame()) { | 183 if (LocalFrame* frame = this->frame()) |
| 187 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | |
| 188 didFailLoading(frame); | 184 didFailLoading(frame); |
| 189 } | |
| 190 dispose(); | 185 dispose(); |
| 191 } | 186 } |
| 192 | 187 |
| 193 void PingLoader::didFinishLoading(WebURLLoader*, double, int64_t) | 188 void PingLoader::didFinishLoading(WebURLLoader*, double, int64_t) |
| 194 { | 189 { |
| 195 if (LocalFrame* frame = this->frame()) { | 190 if (LocalFrame* frame = this->frame()) |
| 196 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | |
| 197 didFailLoading(frame); | 191 didFailLoading(frame); |
| 198 } | |
| 199 dispose(); | 192 dispose(); |
| 200 } | 193 } |
| 201 | 194 |
| 202 void PingLoader::didFail(WebURLLoader*, const WebURLError& resourceError) | 195 void PingLoader::didFail(WebURLLoader*, const WebURLError& resourceError) |
| 203 { | 196 { |
| 204 if (LocalFrame* frame = this->frame()) { | 197 if (LocalFrame* frame = this->frame()) |
| 205 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | |
| 206 didFailLoading(frame); | 198 didFailLoading(frame); |
| 207 } | |
| 208 dispose(); | 199 dispose(); |
| 209 } | 200 } |
| 210 | 201 |
| 211 void PingLoader::timeout(Timer<PingLoader>*) | 202 void PingLoader::timeout(Timer<PingLoader>*) |
| 212 { | 203 { |
| 213 if (LocalFrame* frame = this->frame()) { | 204 if (LocalFrame* frame = this->frame()) |
| 214 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | |
| 215 didFailLoading(frame); | 205 didFailLoading(frame); |
| 216 } | |
| 217 dispose(); | 206 dispose(); |
| 218 } | 207 } |
| 219 | 208 |
| 220 void PingLoader::didFailLoading(LocalFrame* frame) | 209 void PingLoader::didFailLoading(LocalFrame* frame) |
| 221 { | 210 { |
| 222 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError:
:cancelledError(m_url)); | 211 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError:
:cancelledError(m_url)); |
| 223 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError(
m_url)); | 212 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError(
m_url)); |
| 224 } | 213 } |
| 225 | 214 |
| 226 DEFINE_TRACE(PingLoader) | 215 DEFINE_TRACE(PingLoader) |
| 227 { | 216 { |
| 228 LocalFrameLifecycleObserver::trace(visitor); | 217 LocalFrameLifecycleObserver::trace(visitor); |
| 229 } | 218 } |
| 230 | 219 |
| 231 } // namespace blink | 220 } // namespace blink |
| OLD | NEW |