CustomProtocolManager.h [plain text]
#ifndef CustomProtocolManager_h
#define CustomProtocolManager_h
#if ENABLE(CUSTOM_PROTOCOLS)
#include "Connection.h"
#include "NetworkProcessSupplement.h"
#include "WebProcessSupplement.h"
#include "WorkQueue.h"
#include <wtf/HashSet.h>
#include <wtf/Threading.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(MAC)
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS WKCustomProtocol;
#endif
namespace CoreIPC {
class DataReference;
}
namespace WebCore {
class ResourceError;
class ResourceResponse;
}
namespace WebKit {
class ChildProcess;
struct NetworkProcessCreationParameters;
class CustomProtocolManager : public WebProcessSupplement, public NetworkProcessSupplement, public CoreIPC::Connection::WorkQueueMessageReceiver {
WTF_MAKE_NONCOPYABLE(CustomProtocolManager);
public:
explicit CustomProtocolManager(ChildProcess*);
static const char* supplementName();
ChildProcess* childProcess() const { return m_childProcess; }
void registerScheme(const String&);
void unregisterScheme(const String&);
bool supportsScheme(const String&);
#if PLATFORM(MAC)
void addCustomProtocol(WKCustomProtocol *);
void removeCustomProtocol(WKCustomProtocol *);
#endif
private:
void initializeConnection(CoreIPC::Connection*) OVERRIDE;
void initialize(const WebProcessCreationParameters&) OVERRIDE;
#if ENABLE(NETWORK_PROCESS)
void initialize(const NetworkProcessCreationParameters&) OVERRIDE;
#endif
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
void didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError&);
void didLoadData(uint64_t customProtocolID, const CoreIPC::DataReference&);
void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&, uint32_t cacheStoragePolicy);
void didFinishLoading(uint64_t customProtocolID);
HashSet<String> m_registeredSchemes;
Mutex m_registeredSchemesMutex;
ChildProcess* m_childProcess;
RefPtr<WorkQueue> m_messageQueue;
#if PLATFORM(MAC)
typedef HashMap<uint64_t, RetainPtr<WKCustomProtocol>> CustomProtocolMap;
CustomProtocolMap m_customProtocolMap;
Mutex m_customProtocolMapMutex;
RetainPtr<WKCustomProtocol> protocolForID(uint64_t customProtocolID);
#endif
};
}
#endif // ENABLE(CUSTOM_PROTOCOLS)
#endif // CustomProtocolManager_h