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_H_ | 5 #ifndef NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
6 #define NET_SOCKET_STREAM_SOCKET_STREAM_H_ | 6 #define NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <map> | 10 #include <map> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // information with a SocketStream. Use GetUserData(key) and | 52 // information with a SocketStream. Use GetUserData(key) and |
53 // SetUserData(key, data). | 53 // SetUserData(key, data). |
54 class UserData { | 54 class UserData { |
55 public: | 55 public: |
56 UserData() {} | 56 UserData() {} |
57 virtual ~UserData() {} | 57 virtual ~UserData() {} |
58 }; | 58 }; |
59 | 59 |
60 class NET_EXPORT Delegate { | 60 class NET_EXPORT Delegate { |
61 public: | 61 public: |
62 virtual ~Delegate() {} | |
63 | |
64 virtual int OnStartOpenConnection(SocketStream* socket, | 62 virtual int OnStartOpenConnection(SocketStream* socket, |
65 const CompletionCallback& callback) { | 63 const CompletionCallback& callback) { |
66 return OK; | 64 return OK; |
67 } | 65 } |
68 | 66 |
69 // Called when socket stream has been connected. The socket stream accepts | 67 // Called when socket stream has been connected. The socket stream accepts |
70 // at most |max_pending_send_allowed| so that a client of the socket stream | 68 // at most |max_pending_send_allowed| so that a client of the socket stream |
71 // should keep track of how much it has pending and shouldn't go over | 69 // should keep track of how much it has pending and shouldn't go over |
72 // |max_pending_send_allowed| bytes. | 70 // |max_pending_send_allowed| bytes. |
73 virtual void OnConnected(SocketStream* socket, | 71 virtual void OnConnected(SocketStream* socket, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 112 } |
115 | 113 |
116 // Called when a cookie is set to allow the delegate to block access to the | 114 // Called when a cookie is set to allow the delegate to block access to the |
117 // cookie. | 115 // cookie. |
118 virtual bool CanSetCookie(SocketStream* request, | 116 virtual bool CanSetCookie(SocketStream* request, |
119 const GURL& url, | 117 const GURL& url, |
120 const std::string& cookie_line, | 118 const std::string& cookie_line, |
121 CookieOptions* options) { | 119 CookieOptions* options) { |
122 return true; | 120 return true; |
123 } | 121 } |
| 122 |
| 123 protected: |
| 124 virtual ~Delegate() {} |
124 }; | 125 }; |
125 | 126 |
126 SocketStream(const GURL& url, Delegate* delegate); | 127 SocketStream(const GURL& url, Delegate* delegate); |
127 | 128 |
128 // The user data allows the clients to associate data with this job. | 129 // The user data allows the clients to associate data with this job. |
129 // Multiple user data values can be stored under different keys. | 130 // Multiple user data values can be stored under different keys. |
130 // This job will TAKE OWNERSHIP of the given data pointer, and will | 131 // This job will TAKE OWNERSHIP of the given data pointer, and will |
131 // delete the object if it is changed or the job is destroyed. | 132 // delete the object if it is changed or the job is destroyed. |
132 UserData* GetUserData(const void* key) const; | 133 UserData* GetUserData(const void* key) const; |
133 void SetUserData(const void* key, UserData* data); | 134 void SetUserData(const void* key, UserData* data); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 bool server_closed_; | 375 bool server_closed_; |
375 | 376 |
376 scoped_ptr<SocketStreamMetrics> metrics_; | 377 scoped_ptr<SocketStreamMetrics> metrics_; |
377 | 378 |
378 DISALLOW_COPY_AND_ASSIGN(SocketStream); | 379 DISALLOW_COPY_AND_ASSIGN(SocketStream); |
379 }; | 380 }; |
380 | 381 |
381 } // namespace net | 382 } // namespace net |
382 | 383 |
383 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ | 384 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
OLD | NEW |