SocketStreamHandle.h [plain text]
#ifndef SocketStreamHandle_h
#define SocketStreamHandle_h
#include "AuthenticationClient.h"
#include "SocketStreamHandleBase.h"
#include <wtf/RetainPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
typedef struct __CFHTTPMessage* CFHTTPMessageRef;
namespace WebCore {
class AuthenticationChallenge;
class Credential;
class SocketStreamHandleClient;
class SocketStreamHandle : public ThreadSafeRefCounted<SocketStreamHandle>, public SocketStreamHandleBase, public AuthenticationClient {
public:
static PassRefPtr<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient* client) { return adoptRef(new SocketStreamHandle(url, client)); }
virtual ~SocketStreamHandle();
using ThreadSafeRefCounted<SocketStreamHandle>::ref;
using ThreadSafeRefCounted<SocketStreamHandle>::deref;
private:
virtual int platformSend(const char* data, int length);
virtual void platformClose();
SocketStreamHandle(const URL&, SocketStreamHandleClient*);
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);
virtual void receivedCredential(const AuthenticationChallenge&, const Credential&);
virtual void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);
virtual void receivedCancellation(const AuthenticationChallenge&);
virtual void receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&);
virtual void receivedChallengeRejection(const AuthenticationChallenge&);
virtual void refAuthenticationClient() { ref(); }
virtual void derefAuthenticationClient() { deref(); }
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; };
}
#endif // SocketStreamHandle_h