SocketStreamHandle.h [plain text]
#pragma once
#include "SessionID.h"
#include "SocketStreamHandleBase.h"
#include <wtf/RetainPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
typedef struct __CFHTTPMessage* CFHTTPMessageRef;
namespace WebCore {
class AuthenticationChallenge;
class Credential;
class NetworkingContext;
class ProtectionSpace;
class SocketStreamHandleClient;
class SocketStreamHandle : public ThreadSafeRefCounted<SocketStreamHandle>, public SocketStreamHandleBase {
public:
static Ref<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient& client, NetworkingContext& networkingContext, SessionID sessionID) { return adoptRef(*new SocketStreamHandle(url, client, networkingContext, sessionID)); }
virtual ~SocketStreamHandle();
private:
virtual int platformSend(const char* data, int length);
virtual void platformClose();
WEBCORE_EXPORT SocketStreamHandle(const URL&, SocketStreamHandleClient&, NetworkingContext&, SessionID);
void createStreams();
void scheduleStreams();
void chooseProxy();
void chooseProxyFromArray(CFArrayRef);
void executePACFileURL(CFURLRef);
void removePACRunLoopSource();
RetainPtr<CFRunLoopSourceRef> m_pacRunLoopSource;
static void pacExecutionCallback(void* client, CFArrayRef proxyList, CFErrorRef error);
static CFStringRef copyPACExecutionDescription(void*);
bool shouldUseSSL() const { return m_url.protocolIs("wss"); }
unsigned short port() const;
void addCONNECTCredentials(CFHTTPMessageRef response);
static void* retainSocketStreamHandle(void*);
static void releaseSocketStreamHandle(void*);
static CFStringRef copyCFStreamDescription(void*);
static void readStreamCallback(CFReadStreamRef, CFStreamEventType, void*);
static void writeStreamCallback(CFWriteStreamRef, CFStreamEventType, void*);
void readStreamCallback(CFStreamEventType);
void writeStreamCallback(CFStreamEventType);
void reportErrorToClient(CFErrorRef);
bool getStoredCONNECTProxyCredentials(const ProtectionSpace&, String& login, String& password);
enum ConnectingSubstate { New, ExecutingPACFile, WaitingForCredentials, WaitingForConnect, Connected };
ConnectingSubstate m_connectingSubstate;
enum ConnectionType { Unknown, Direct, SOCKSProxy, CONNECTProxy };
ConnectionType m_connectionType;
RetainPtr<CFStringRef> m_proxyHost;
RetainPtr<CFNumberRef> m_proxyPort;
RetainPtr<CFHTTPMessageRef> m_proxyResponseMessage;
bool m_sentStoredCredentials;
RetainPtr<CFReadStreamRef> m_readStream;
RetainPtr<CFWriteStreamRef> m_writeStream;
RetainPtr<CFURLRef> m_httpsURL;
Ref<NetworkingContext> m_networkingContext;
};
}