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

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

Issue 34273002: Remove UnusedParam.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years 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/html/track/InbandTextTrack.cpp ('k') | Source/core/page/ChromeClient.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 29 matching lines...) Expand all
40 #include "core/loader/UniqueIdentifier.h" 40 #include "core/loader/UniqueIdentifier.h"
41 #include "platform/exported/WrappedResourceRequest.h" 41 #include "platform/exported/WrappedResourceRequest.h"
42 #include "platform/network/FormData.h" 42 #include "platform/network/FormData.h"
43 #include "platform/network/ResourceRequest.h" 43 #include "platform/network/ResourceRequest.h"
44 #include "platform/network/ResourceResponse.h" 44 #include "platform/network/ResourceResponse.h"
45 #include "platform/weborigin/SecurityOrigin.h" 45 #include "platform/weborigin/SecurityOrigin.h"
46 #include "platform/weborigin/SecurityPolicy.h" 46 #include "platform/weborigin/SecurityPolicy.h"
47 #include "public/platform/Platform.h" 47 #include "public/platform/Platform.h"
48 #include "public/platform/WebURLLoader.h" 48 #include "public/platform/WebURLLoader.h"
49 #include "wtf/OwnPtr.h" 49 #include "wtf/OwnPtr.h"
50 #include "wtf/UnusedParam.h"
51 50
52 namespace WebCore { 51 namespace WebCore {
53 52
54 void PingLoader::loadImage(Frame* frame, const KURL& url) 53 void PingLoader::loadImage(Frame* frame, const KURL& url)
55 { 54 {
56 if (!frame->document()->securityOrigin()->canDisplay(url)) { 55 if (!frame->document()->securityOrigin()->canDisplay(url)) {
57 FrameLoader::reportLocalLoadFailed(frame, url.string()); 56 FrameLoader::reportLocalLoadFailed(frame, url.string());
58 return; 57 return;
59 } 58 }
60 59
61 ResourceRequest request(url); 60 ResourceRequest request(url);
62 request.setTargetType(ResourceRequest::TargetIsPing); 61 request.setTargetType(ResourceRequest::TargetIsPing);
63 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 62 request.setHTTPHeaderField("Cache-Control", "max-age=0");
64 String referrer = SecurityPolicy::generateReferrerHeader(frame->document()-> referrerPolicy(), request.url(), frame->loader().outgoingReferrer()); 63 String referrer = SecurityPolicy::generateReferrerHeader(frame->document()-> referrerPolicy(), request.url(), frame->loader().outgoingReferrer());
65 if (!referrer.isEmpty()) 64 if (!referrer.isEmpty())
66 request.setHTTPReferrer(referrer); 65 request.setHTTPReferrer(referrer);
67 frame->loader().addExtraFieldsToRequest(request); 66 frame->loader().addExtraFieldsToRequest(request);
68 OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request)); 67 OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
69 68
70 // Leak the ping loader, since it will kill itself as soon as it receives a response. 69 // Leak the ping loader, since it will kill itself as soon as it receives a response.
71 PingLoader* leakedPingLoader = pingLoader.leakPtr(); 70 PingLoader* ALLOW_UNUSED leakedPingLoader = pingLoader.leakPtr();
72 UNUSED_PARAM(leakedPingLoader);
73 } 71 }
74 72
75 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing 73 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing
76 void PingLoader::sendPing(Frame* frame, const KURL& pingURL, const KURL& destina tionURL) 74 void PingLoader::sendPing(Frame* frame, const KURL& pingURL, const KURL& destina tionURL)
77 { 75 {
78 ResourceRequest request(pingURL); 76 ResourceRequest request(pingURL);
79 request.setTargetType(ResourceRequest::TargetIsPing); 77 request.setTargetType(ResourceRequest::TargetIsPing);
80 request.setHTTPMethod("POST"); 78 request.setHTTPMethod("POST");
81 request.setHTTPContentType("text/ping"); 79 request.setHTTPContentType("text/ping");
82 request.setHTTPBody(FormData::create("PING")); 80 request.setHTTPBody(FormData::create("PING"));
83 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 81 request.setHTTPHeaderField("Cache-Control", "max-age=0");
84 frame->loader().addExtraFieldsToRequest(request); 82 frame->loader().addExtraFieldsToRequest(request);
85 83
86 SecurityOrigin* sourceOrigin = frame->document()->securityOrigin(); 84 SecurityOrigin* sourceOrigin = frame->document()->securityOrigin();
87 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL); 85 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL);
88 FrameLoader::addHTTPOriginIfNeeded(request, sourceOrigin->toString()); 86 FrameLoader::addHTTPOriginIfNeeded(request, sourceOrigin->toString());
89 request.setHTTPHeaderField("Ping-To", destinationURL.string()); 87 request.setHTTPHeaderField("Ping-To", destinationURL.string());
90 if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->loader().outgoingRef errer())) { 88 if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->loader().outgoingRef errer())) {
91 request.setHTTPHeaderField("Ping-From", frame->document()->url().string( )); 89 request.setHTTPHeaderField("Ping-From", frame->document()->url().string( ));
92 if (!sourceOrigin->isSameSchemeHostPort(pingOrigin.get())) { 90 if (!sourceOrigin->isSameSchemeHostPort(pingOrigin.get())) {
93 String referrer = SecurityPolicy::generateReferrerHeader(frame->docu ment()->referrerPolicy(), pingURL, frame->loader().outgoingReferrer()); 91 String referrer = SecurityPolicy::generateReferrerHeader(frame->docu ment()->referrerPolicy(), pingURL, frame->loader().outgoingReferrer());
94 if (!referrer.isEmpty()) 92 if (!referrer.isEmpty())
95 request.setHTTPReferrer(referrer); 93 request.setHTTPReferrer(referrer);
96 } 94 }
97 } 95 }
98 OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request)); 96 OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
99 97
100 // Leak the ping loader, since it will kill itself as soon as it receives a response. 98 // Leak the ping loader, since it will kill itself as soon as it receives a response.
101 PingLoader* leakedPingLoader = pingLoader.leakPtr(); 99 PingLoader* ALLOW_UNUSED leakedPingLoader = pingLoader.leakPtr();
102 UNUSED_PARAM(leakedPingLoader);
103 } 100 }
104 101
105 void PingLoader::sendViolationReport(Frame* frame, const KURL& reportURL, PassRe fPtr<FormData> report, ViolationReportType type) 102 void PingLoader::sendViolationReport(Frame* frame, const KURL& reportURL, PassRe fPtr<FormData> report, ViolationReportType type)
106 { 103 {
107 ResourceRequest request(reportURL); 104 ResourceRequest request(reportURL);
108 request.setTargetType(ResourceRequest::TargetIsSubresource); 105 request.setTargetType(ResourceRequest::TargetIsSubresource);
109 request.setHTTPMethod("POST"); 106 request.setHTTPMethod("POST");
110 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a pplication/csp-report" : "application/json"); 107 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a pplication/csp-report" : "application/json");
111 request.setHTTPBody(report); 108 request.setHTTPBody(report);
112 frame->loader().addExtraFieldsToRequest(request); 109 frame->loader().addExtraFieldsToRequest(request);
113 110
114 String referrer = SecurityPolicy::generateReferrerHeader(frame->document()-> referrerPolicy(), reportURL, frame->loader().outgoingReferrer()); 111 String referrer = SecurityPolicy::generateReferrerHeader(frame->document()-> referrerPolicy(), reportURL, frame->loader().outgoingReferrer());
115 if (!referrer.isEmpty()) 112 if (!referrer.isEmpty())
116 request.setHTTPReferrer(referrer); 113 request.setHTTPReferrer(referrer);
117 OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request, Secu rityOrigin::create(reportURL)->isSameSchemeHostPort(frame->document()->securityO rigin()) ? AllowStoredCredentials : DoNotAllowStoredCredentials)); 114 OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request, Secu rityOrigin::create(reportURL)->isSameSchemeHostPort(frame->document()->securityO rigin()) ? AllowStoredCredentials : DoNotAllowStoredCredentials));
118 115
119 // Leak the ping loader, since it will kill itself as soon as it receives a response. 116 // Leak the ping loader, since it will kill itself as soon as it receives a response.
120 PingLoader* leakedPingLoader = pingLoader.leakPtr(); 117 PingLoader* ALLOW_UNUSED leakedPingLoader = pingLoader.leakPtr();
121 UNUSED_PARAM(leakedPingLoader);
122 } 118 }
123 119
124 PingLoader::PingLoader(Frame* frame, ResourceRequest& request, StoredCredentials credentialsAllowed) 120 PingLoader::PingLoader(Frame* frame, ResourceRequest& request, StoredCredentials credentialsAllowed)
125 : m_timeout(this, &PingLoader::timeout) 121 : m_timeout(this, &PingLoader::timeout)
126 { 122 {
127 frame->loader().client()->didDispatchPingLoader(request.url()); 123 frame->loader().client()->didDispatchPingLoader(request.url());
128 124
129 unsigned long identifier = createUniqueIdentifier(); 125 unsigned long identifier = createUniqueIdentifier();
130 m_loader = adoptPtr(blink::Platform::current()->createURLLoader()); 126 m_loader = adoptPtr(blink::Platform::current()->createURLLoader());
131 ASSERT(m_loader); 127 ASSERT(m_loader);
132 blink::WrappedResourceRequest wrappedRequest(request); 128 blink::WrappedResourceRequest wrappedRequest(request);
133 wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCr edentials); 129 wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCr edentials);
134 m_loader->loadAsynchronously(wrappedRequest, this); 130 m_loader->loadAsynchronously(wrappedRequest, this);
135 131
136 InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame-> loader().activeDocumentLoader(), request, ResourceResponse()); 132 InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame-> loader().activeDocumentLoader(), request, ResourceResponse());
137 133
138 // If the server never responds, FrameLoader won't be able to cancel this lo ad and 134 // If the server never responds, FrameLoader won't be able to cancel this lo ad and
139 // we'll sit here waiting forever. Set a very generous timeout, just in case . 135 // we'll sit here waiting forever. Set a very generous timeout, just in case .
140 m_timeout.startOneShot(60000); 136 m_timeout.startOneShot(60000);
141 } 137 }
142 138
143 PingLoader::~PingLoader() 139 PingLoader::~PingLoader()
144 { 140 {
145 if (m_loader) 141 if (m_loader)
146 m_loader->cancel(); 142 m_loader->cancel();
147 } 143 }
148 144
149 } 145 }
OLDNEW
« no previous file with comments | « Source/core/html/track/InbandTextTrack.cpp ('k') | Source/core/page/ChromeClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698