summaryrefslogtreecommitdiff
path: root/Source/WebCore/loader/PingLoader.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/loader/PingLoader.h')
-rw-r--r--Source/WebCore/loader/PingLoader.h53
1 files changed, 16 insertions, 37 deletions
diff --git a/Source/WebCore/loader/PingLoader.h b/Source/WebCore/loader/PingLoader.h
index 295e2f4f2..b29e8da8f 100644
--- a/Source/WebCore/loader/PingLoader.h
+++ b/Source/WebCore/loader/PingLoader.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,53 +30,31 @@
*
*/
-#ifndef PingLoader_h
-#define PingLoader_h
+#pragma once
-#include "ResourceHandleClient.h"
-#include "Timer.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
namespace WebCore {
class FormData;
class Frame;
class URL;
-class ResourceError;
-class ResourceHandle;
-class ResourceResponse;
+class ResourceRequest;
-// This class triggers asynchronous loads independent of Frame staying alive (i.e., auditing pingbacks).
-// Since nothing depends on resources loaded through this class, we just want
-// to allow the load to live long enough to ensure the message was actually sent.
-// Therefore, as soon as a callback is received from the ResourceHandle, this class
-// will cancel the load and delete itself.
-class PingLoader : private ResourceHandleClient {
- WTF_MAKE_NONCOPYABLE(PingLoader); WTF_MAKE_FAST_ALLOCATED;
-public:
- static void loadImage(Frame*, const URL& url);
- static void sendPing(Frame*, const URL& pingURL, const URL& destinationURL);
- static void sendViolationReport(Frame*, const URL& reportURL, PassRefPtr<FormData> report);
+enum class ViolationReportType {
+ ContentSecurityPolicy,
+ XSSAuditor,
+};
- virtual ~PingLoader();
+class PingLoader {
+public:
+ static void loadImage(Frame&, const URL&);
+ static void sendPing(Frame&, const URL& pingURL, const URL& destinationURL);
+ static void sendViolationReport(Frame&, const URL& reportURL, Ref<FormData>&& report, ViolationReportType);
private:
- static void createPingLoader(Frame*, ResourceRequest&);
- PingLoader(Frame*, ResourceRequest&);
-
- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override { delete this; }
- virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int) override { delete this; }
- virtual void didFinishLoading(ResourceHandle*, double) override { delete this; }
- virtual void didFail(ResourceHandle*, const ResourceError&) override { delete this; }
- virtual bool shouldUseCredentialStorage(ResourceHandle*) override { return m_shouldUseCredentialStorage; }
- void timeoutTimerFired(Timer<PingLoader>&) { delete this; }
-
- RefPtr<ResourceHandle> m_handle;
- Timer<PingLoader> m_timeout;
- bool m_shouldUseCredentialStorage;
+ enum class ShouldFollowRedirects { No, Yes };
+ static void startPingLoad(Frame&, ResourceRequest&, ShouldFollowRedirects);
};
-}
-
-#endif
+} // namespace WebCore