OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ | 5 #ifndef NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ |
6 #define NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ | 6 #define NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // SocketStreamJob represents full-duplex communication over SocketStream. | 23 // SocketStreamJob represents full-duplex communication over SocketStream. |
24 // If a protocol (e.g. WebSocket protocol) needs to inspect/modify data | 24 // If a protocol (e.g. WebSocket protocol) needs to inspect/modify data |
25 // over SocketStream, you can implement protocol specific job (e.g. | 25 // over SocketStream, you can implement protocol specific job (e.g. |
26 // WebSocketJob) to do some work on data over SocketStream. | 26 // WebSocketJob) to do some work on data over SocketStream. |
27 // Registers the protocol specific SocketStreamJob by RegisterProtocolFactory | 27 // Registers the protocol specific SocketStreamJob by RegisterProtocolFactory |
28 // and call CreateSocketStreamJob to create SocketStreamJob for the URL. | 28 // and call CreateSocketStreamJob to create SocketStreamJob for the URL. |
29 class NET_EXPORT SocketStreamJob | 29 class NET_EXPORT SocketStreamJob |
30 : public base::RefCountedThreadSafe<SocketStreamJob> { | 30 : public base::RefCountedThreadSafe<SocketStreamJob> { |
31 public: | 31 public: |
32 // Callback function implemented by protocol handlers to create new jobs. | 32 // Callback function implemented by protocol handlers to create new jobs. |
33 typedef SocketStreamJob* (ProtocolFactory)(const GURL& url, | 33 typedef SocketStreamJob*(ProtocolFactory)(const GURL& url, |
34 SocketStream::Delegate* delegate, | 34 SocketStream::Delegate* delegate, |
35 URLRequestContext* context, | 35 URLRequestContext* context, |
36 CookieStore* cookie_store); | 36 CookieStore* cookie_store); |
37 | 37 |
38 static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme, | 38 static ProtocolFactory* RegisterProtocolFactory(const std::string& scheme, |
39 ProtocolFactory* factory); | 39 ProtocolFactory* factory); |
40 | 40 |
41 static SocketStreamJob* CreateSocketStreamJob( | 41 static SocketStreamJob* CreateSocketStreamJob( |
42 const GURL& url, | 42 const GURL& url, |
43 SocketStream::Delegate* delegate, | 43 SocketStream::Delegate* delegate, |
44 TransportSecurityState* sts, | 44 TransportSecurityState* sts, |
45 SSLConfigService* ssl, | 45 SSLConfigService* ssl, |
46 URLRequestContext* context, | 46 URLRequestContext* context, |
47 CookieStore* cookie_store); | 47 CookieStore* cookie_store); |
48 | 48 |
49 SocketStreamJob(); | 49 SocketStreamJob(); |
50 void InitSocketStream(SocketStream* socket) { | 50 void InitSocketStream(SocketStream* socket) { socket_ = socket; } |
51 socket_ = socket; | |
52 } | |
53 | 51 |
54 virtual SocketStream::UserData* GetUserData(const void* key) const; | 52 virtual SocketStream::UserData* GetUserData(const void* key) const; |
55 virtual void SetUserData(const void* key, SocketStream::UserData* data); | 53 virtual void SetUserData(const void* key, SocketStream::UserData* data); |
56 | 54 |
57 URLRequestContext* context() const { | 55 URLRequestContext* context() const { |
58 return socket_.get() ? socket_->context() : 0; | 56 return socket_.get() ? socket_->context() : 0; |
59 } | 57 } |
60 CookieStore* cookie_store() const { | 58 CookieStore* cookie_store() const { |
61 return socket_.get() ? socket_->cookie_store() : 0; | 59 return socket_.get() ? socket_->cookie_store() : 0; |
62 } | 60 } |
(...skipping 22 matching lines...) Expand all Loading... |
85 virtual ~SocketStreamJob(); | 83 virtual ~SocketStreamJob(); |
86 | 84 |
87 scoped_refptr<SocketStream> socket_; | 85 scoped_refptr<SocketStream> socket_; |
88 | 86 |
89 DISALLOW_COPY_AND_ASSIGN(SocketStreamJob); | 87 DISALLOW_COPY_AND_ASSIGN(SocketStreamJob); |
90 }; | 88 }; |
91 | 89 |
92 } // namespace net | 90 } // namespace net |
93 | 91 |
94 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ | 92 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_JOB_H_ |
OLD | NEW |