diff options
| author | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
|---|---|---|
| committer | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
| commit | 679147eead574d186ebf3069647b4c23e8ccace6 (patch) | |
| tree | fc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/net/socket_stream/socket_stream_job.h | |
Initial import.
Diffstat (limited to 'chromium/net/socket_stream/socket_stream_job.h')
| -rw-r--r-- | chromium/net/socket_stream/socket_stream_job.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/chromium/net/socket_stream/socket_stream_job.h b/chromium/net/socket_stream/socket_stream_job.h new file mode 100644 index 00000000000..d12e73aff31 --- /dev/null +++ b/chromium/net/socket_stream/socket_stream_job.h @@ -0,0 +1,88 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ +#define NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ + +#include <string> + +#include "base/memory/ref_counted.h" +#include "net/base/net_export.h" +#include "net/socket_stream/socket_stream.h" + +class GURL; + +namespace net { + +class SSLConfigService; +class SSLInfo; +class TransportSecurityState; + +// SocketStreamJob represents full-duplex communication over SocketStream. +// If a protocol (e.g. WebSocket protocol) needs to inspect/modify data +// over SocketStream, you can implement protocol specific job (e.g. +// WebSocketJob) to do some work on data over SocketStream. +// Registers the protocol specific SocketStreamJob by RegisterProtocolFactory +// and call CreateSocketStreamJob to create SocketStreamJob for the URL. +class NET_EXPORT SocketStreamJob + : public base::RefCountedThreadSafe<SocketStreamJob> { + public: + // Callback function implemented by protocol handlers to create new jobs. + typedef SocketStreamJob* (ProtocolFactory)(const GURL& url, + SocketStream::Delegate* delegate); + + static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme, + ProtocolFactory* factory); + + static SocketStreamJob* CreateSocketStreamJob( + const GURL& url, + SocketStream::Delegate* delegate, + TransportSecurityState* sts, + SSLConfigService* ssl); + + SocketStreamJob(); + void InitSocketStream(SocketStream* socket) { + socket_ = socket; + } + + virtual SocketStream::UserData* GetUserData(const void* key) const; + virtual void SetUserData(const void* key, SocketStream::UserData* data); + + URLRequestContext* context() const { + return socket_.get() ? socket_->context() : 0; + } + void set_context(URLRequestContext* context) { + if (socket_.get()) + socket_->set_context(context); + } + + virtual void Connect(); + + virtual bool SendData(const char* data, int len); + + virtual void Close(); + + virtual void RestartWithAuth(const AuthCredentials& credentials); + + virtual void CancelWithError(int error); + + virtual void CancelWithSSLError(const net::SSLInfo& ssl_info); + + virtual void ContinueDespiteError(); + + virtual void DetachDelegate(); + + protected: + friend class WebSocketJobTest; + friend class base::RefCountedThreadSafe<SocketStreamJob>; + virtual ~SocketStreamJob(); + + scoped_refptr<SocketStream> socket_; + + DISALLOW_COPY_AND_ASSIGN(SocketStreamJob); +}; + +} // namespace net + +#endif // NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ |
