https://bugs.webkit.org/show_bug.cgi?id=122942
Reviewed by Darin Adler.
There's no need to store new PingLoader objects into an OwnPtr just to leak them out a few lines later
into an unused variable. New objects are created through a new helper method and then left unmanaged as
they're guaranteed to destroy themselves when they receive a response of any kind.
* loader/PingLoader.cpp:
(WebCore::PingLoader::loadImage): Call the new createPingLoader method to spawn the PingLoader.
(WebCore::PingLoader::sendPing): Ditto.
(WebCore::PingLoader::sendViolationReport): Ditto.
(WebCore::PingLoader::createPingLoader): A helper method that creates a new PingLoader object
* loader/PingLoader.h: Declare the new PingLoader::createPingLoader method.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158558
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-11-03 Zan Dobersek <zdobersek@igalia.com>
+
+ PingLoader objects unnecessarily pass through OwnPtr
+ https://bugs.webkit.org/show_bug.cgi?id=122942
+
+ Reviewed by Darin Adler.
+
+ There's no need to store new PingLoader objects into an OwnPtr just to leak them out a few lines later
+ into an unused variable. New objects are created through a new helper method and then left unmanaged as
+ they're guaranteed to destroy themselves when they receive a response of any kind.
+
+ * loader/PingLoader.cpp:
+ (WebCore::PingLoader::loadImage): Call the new createPingLoader method to spawn the PingLoader.
+ (WebCore::PingLoader::sendPing): Ditto.
+ (WebCore::PingLoader::sendViolationReport): Ditto.
+ (WebCore::PingLoader::createPingLoader): A helper method that creates a new PingLoader object
+ * loader/PingLoader.h: Declare the new PingLoader::createPingLoader method.
+
2013-11-03 Andreas Kling <akling@apple.com>
HTMLOptionsCollection is always rooted at a HTMLSelectElement.
2013-11-03 Andreas Kling <akling@apple.com>
HTMLOptionsCollection is always rooted at a HTMLSelectElement.
#include "ResourceResponse.h"
#include "SecurityOrigin.h"
#include "SecurityPolicy.h"
#include "ResourceResponse.h"
#include "SecurityOrigin.h"
#include "SecurityPolicy.h"
#include <wtf/text/CString.h>
namespace WebCore {
#include <wtf/text/CString.h>
namespace WebCore {
if (!referrer.isEmpty())
request.setHTTPReferrer(referrer);
frame->loader().addExtraFieldsToSubresourceRequest(request);
if (!referrer.isEmpty())
request.setHTTPReferrer(referrer);
frame->loader().addExtraFieldsToSubresourceRequest(request);
- OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
- // Leak the ping loader, since it will kill itself as soon as it receives a response.
- PingLoader* leakedPingLoader = pingLoader.leakPtr();
- UNUSED_PARAM(leakedPingLoader);
+ createPingLoader(frame, request);
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
request.setHTTPReferrer(referrer);
}
}
request.setHTTPReferrer(referrer);
}
}
- OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
- // Leak the ping loader, since it will kill itself as soon as it receives a response.
- PingLoader* leakedPingLoader = pingLoader.leakPtr();
- UNUSED_PARAM(leakedPingLoader);
+ createPingLoader(frame, request);
}
void PingLoader::sendViolationReport(Frame* frame, const URL& reportURL, PassRefPtr<FormData> report)
}
void PingLoader::sendViolationReport(Frame* frame, const URL& reportURL, PassRefPtr<FormData> report)
String referrer = SecurityPolicy::generateReferrerHeader(frame->document()->referrerPolicy(), reportURL, frame->loader().outgoingReferrer());
if (!referrer.isEmpty())
request.setHTTPReferrer(referrer);
String referrer = SecurityPolicy::generateReferrerHeader(frame->document()->referrerPolicy(), reportURL, frame->loader().outgoingReferrer());
if (!referrer.isEmpty())
request.setHTTPReferrer(referrer);
- OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
- // Leak the ping loader, since it will kill itself as soon as it receives a response.
- PingLoader* leakedPingLoader = pingLoader.leakPtr();
- UNUSED_PARAM(leakedPingLoader);
+ createPingLoader(frame, request);
+}
+
+void PingLoader::createPingLoader(Frame* frame, ResourceRequest& request)
+{
+ // No need to free the PingLoader object or manage it via a smart pointer - it will kill itself as soon as it receives a response.
+ new PingLoader(frame, request);
}
PingLoader::PingLoader(Frame* frame, ResourceRequest& request)
}
PingLoader::PingLoader(Frame* frame, ResourceRequest& request)
virtual ~PingLoader();
private:
virtual ~PingLoader();
private:
+ static void createPingLoader(Frame*, ResourceRequest&);
PingLoader(Frame*, ResourceRequest&);
virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE { delete this; }
PingLoader(Frame*, ResourceRequest&);
virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE { delete this; }