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

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

Issue 232053005: Implement navigator.sendBeacon() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Revert CSP checking on redirects Created 6 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 | « Source/core/loader/PingLoader.h ('k') | Source/modules/beacon/NavigatorBeacon.h » ('j') | 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) 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 25 matching lines...) Expand all
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/fetch/FetchContext.h" 37 #include "core/fetch/FetchContext.h"
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/inspector/InspectorInstrumentation.h" 39 #include "core/inspector/InspectorInstrumentation.h"
40 #include "core/inspector/InspectorTraceEvents.h" 40 #include "core/inspector/InspectorTraceEvents.h"
41 #include "core/loader/FrameLoader.h" 41 #include "core/loader/FrameLoader.h"
42 #include "core/loader/FrameLoaderClient.h" 42 #include "core/loader/FrameLoaderClient.h"
43 #include "core/loader/UniqueIdentifier.h" 43 #include "core/loader/UniqueIdentifier.h"
44 #include "core/page/Page.h" 44 #include "core/page/Page.h"
45 #include "platform/exported/WrappedResourceRequest.h" 45 #include "platform/exported/WrappedResourceRequest.h"
46 #include "platform/network/FormData.h"
47 #include "platform/network/ResourceError.h" 46 #include "platform/network/ResourceError.h"
48 #include "platform/network/ResourceRequest.h" 47 #include "platform/network/ResourceRequest.h"
49 #include "platform/network/ResourceResponse.h" 48 #include "platform/network/ResourceResponse.h"
50 #include "platform/weborigin/SecurityOrigin.h" 49 #include "platform/weborigin/SecurityOrigin.h"
51 #include "platform/weborigin/SecurityPolicy.h" 50 #include "platform/weborigin/SecurityPolicy.h"
52 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
53 #include "public/platform/WebURLLoader.h" 52 #include "public/platform/WebURLLoader.h"
54 #include "public/platform/WebURLResponse.h" 53 #include "public/platform/WebURLResponse.h"
55 #include "wtf/OwnPtr.h" 54 #include "wtf/OwnPtr.h"
56 55
(...skipping 10 matching lines...) Expand all
67 request.setTargetType(ResourceRequest::TargetIsPing); 66 request.setTargetType(ResourceRequest::TargetIsPing);
68 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 67 request.setHTTPHeaderField("Cache-Control", "max-age=0");
69 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource); 68 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource);
70 69
71 FetchInitiatorInfo initiatorInfo; 70 FetchInitiatorInfo initiatorInfo;
72 initiatorInfo.name = FetchInitiatorTypeNames::ping; 71 initiatorInfo.name = FetchInitiatorTypeNames::ping;
73 PingLoader::start(frame, request, initiatorInfo); 72 PingLoader::start(frame, request, initiatorInfo);
74 } 73 }
75 74
76 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing 75 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing
77 void PingLoader::sendPing(LocalFrame* frame, const KURL& pingURL, const KURL& de stinationURL) 76 void PingLoader::sendLinkAuditPing(LocalFrame* frame, const KURL& pingURL, const KURL& destinationURL)
78 { 77 {
79 ResourceRequest request(pingURL); 78 ResourceRequest request(pingURL);
80 request.setTargetType(ResourceRequest::TargetIsPing); 79 request.setTargetType(ResourceRequest::TargetIsPing);
81 request.setHTTPMethod("POST"); 80 request.setHTTPMethod("POST");
82 request.setHTTPContentType("text/ping"); 81 request.setHTTPContentType("text/ping");
83 request.setHTTPBody(FormData::create("PING")); 82 request.setHTTPBody(FormData::create("PING"));
84 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 83 request.setHTTPHeaderField("Cache-Control", "max-age=0");
85 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource); 84 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource);
86 85
87 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL); 86 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void PingLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebURLRes ponse&) 156 void PingLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebURLRes ponse&)
158 { 157 {
159 if (Page* page = this->page()) { 158 if (Page* page = this->page()) {
160 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) ); 159 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) );
161 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 160 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
162 InspectorInstrumentation::didFailLoading(page->mainFrame(), m_identifier , ResourceError::cancelledError(m_url)); 161 InspectorInstrumentation::didFailLoading(page->mainFrame(), m_identifier , ResourceError::cancelledError(m_url));
163 } 162 }
164 delete this; 163 delete this;
165 } 164 }
166 165
167 void PingLoader::didReceiveData(blink::WebURLLoader*, const char* data, int data Length, int encodedDataLength) 166 void PingLoader::didReceiveData(blink::WebURLLoader*, const char*, int, int)
168 { 167 {
169 if (Page* page = this->page()) { 168 if (Page* page = this->page()) {
170 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) ); 169 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) );
171 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 170 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
172 InspectorInstrumentation::didFailLoading(page->mainFrame(), m_identifier , ResourceError::cancelledError(m_url)); 171 InspectorInstrumentation::didFailLoading(page->mainFrame(), m_identifier , ResourceError::cancelledError(m_url));
173 } 172 }
174 delete this; 173 delete this;
175 } 174 }
176 175
177 void PingLoader::didFinishLoading(blink::WebURLLoader*, double, int64_t) 176 void PingLoader::didFinishLoading(blink::WebURLLoader*, double, int64_t)
(...skipping 20 matching lines...) Expand all
198 { 197 {
199 if (Page* page = this->page()) { 198 if (Page* page = this->page()) {
200 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) ); 199 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) );
201 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 200 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
202 InspectorInstrumentation::didFailLoading(page->mainFrame(), m_identifier , ResourceError::cancelledError(m_url)); 201 InspectorInstrumentation::didFailLoading(page->mainFrame(), m_identifier , ResourceError::cancelledError(m_url));
203 } 202 }
204 delete this; 203 delete this;
205 } 204 }
206 205
207 } 206 }
OLDNEW
« no previous file with comments | « Source/core/loader/PingLoader.h ('k') | Source/modules/beacon/NavigatorBeacon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698