LegacyCustomProtocolManager.h [plain text]
#pragma once
#include "LegacyCustomProtocolID.h"
#include "MessageReceiver.h"
#include "NetworkProcessSupplement.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(COCOA)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSURLSessionConfiguration;
OBJC_CLASS WKCustomProtocol;
#endif
namespace IPC {
class DataReference;
}
namespace WebCore {
class ResourceError;
class ResourceRequest;
class ResourceResponse;
}
namespace WebKit {
class NetworkProcess;
struct NetworkProcessCreationParameters;
class LegacyCustomProtocolManager : public NetworkProcessSupplement, public IPC::MessageReceiver {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(LegacyCustomProtocolManager);
public:
explicit LegacyCustomProtocolManager(NetworkProcess&);
static const char* supplementName();
void registerScheme(const String&);
void unregisterScheme(const String&);
bool supportsScheme(const String&);
#if PLATFORM(COCOA)
typedef RetainPtr<WKCustomProtocol> CustomProtocol;
#endif
LegacyCustomProtocolID addCustomProtocol(CustomProtocol&&);
void removeCustomProtocol(LegacyCustomProtocolID);
void startLoading(LegacyCustomProtocolID, const WebCore::ResourceRequest&);
void stopLoading(LegacyCustomProtocolID);
#if PLATFORM(COCOA)
void registerProtocolClass(NSURLSessionConfiguration*);
static void networkProcessCreated(NetworkProcess&);
#endif
private:
void initialize(const NetworkProcessCreationParameters&) override;
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
void didFailWithError(LegacyCustomProtocolID, const WebCore::ResourceError&);
void didLoadData(LegacyCustomProtocolID, const IPC::DataReference&);
void didReceiveResponse(LegacyCustomProtocolID, const WebCore::ResourceResponse&, uint32_t cacheStoragePolicy);
void didFinishLoading(LegacyCustomProtocolID);
void wasRedirectedToRequest(LegacyCustomProtocolID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
void registerProtocolClass();
NetworkProcess& m_networkProcess;
typedef HashMap<LegacyCustomProtocolID, CustomProtocol> CustomProtocolMap;
CustomProtocolMap m_customProtocolMap;
Lock m_customProtocolMapMutex;
#if PLATFORM(COCOA)
HashSet<String, ASCIICaseInsensitiveHash> m_registeredSchemes;
Lock m_registeredSchemesMutex;
RetainPtr<WKCustomProtocol> protocolForID(LegacyCustomProtocolID);
#endif
};
}