OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_FLIP_FLIP_SESSION_H_ | 5 #ifndef NET_FLIP_FLIP_SESSION_H_ |
6 #define NET_FLIP_FLIP_SESSION_H_ | 6 #define NET_FLIP_FLIP_SESSION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "net/socket/client_socket_handle.h" | 24 #include "net/socket/client_socket_handle.h" |
25 #include "testing/platform_test.h" | 25 #include "testing/platform_test.h" |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 | 28 |
29 class FlipStreamImpl; | 29 class FlipStreamImpl; |
30 class HttpNetworkSession; | 30 class HttpNetworkSession; |
31 class HttpRequestInfo; | 31 class HttpRequestInfo; |
32 class HttpResponseInfo; | 32 class HttpResponseInfo; |
33 | 33 |
34 // A callback interface for HTTP content retrieved from the Flip stream. | 34 // The FlipDelegate interface is an interface so that the FlipSession |
| 35 // can interact with the provider of a given Flip stream. |
35 class FlipDelegate { | 36 class FlipDelegate { |
36 public: | 37 public: |
37 virtual ~FlipDelegate() {} | 38 virtual ~FlipDelegate() {} |
| 39 |
| 40 // Accessors from the delegate. |
| 41 |
| 42 // The delegate provides access to the HttpRequestInfo for use by the flip |
| 43 // session. |
38 virtual const HttpRequestInfo* request() = 0; | 44 virtual const HttpRequestInfo* request() = 0; |
| 45 |
| 46 // The delegate provides access to an UploadDataStream for use by the |
| 47 // flip session. If the delegate is not uploading content, this call |
| 48 // must return NULL. |
39 virtual const UploadDataStream* data() = 0; | 49 virtual const UploadDataStream* data() = 0; |
40 | 50 |
41 virtual void OnRequestSent(int status) = 0; | 51 // Callbacks. |
| 52 |
| 53 // Called by the FlipSession when UploadData has been sent. If the |
| 54 // request has no upload data, this call will never be called. This |
| 55 // callback may be called multiple times if large amounts of data are |
| 56 // being uploaded. This callback will only be called prior to the |
| 57 // OnRequestSent callback. |
| 58 // |result| contains the number of bytes written or an error code. |
| 59 virtual void OnUploadDataSent(int result) = 0; |
| 60 |
| 61 // Called by the FlipSession when the Request has been entirely sent. |
| 62 // If the request contains upload data, all upload data has been sent. |
| 63 // |result| contains an error code if a failure has occurred or OK |
| 64 // on success. |
| 65 virtual void OnRequestSent(int result) = 0; |
| 66 |
| 67 // Called by the FlipSession when a response (e.g. a SYN_REPLY) has been |
| 68 // received for this request. This callback will never be called prior |
| 69 // to the OnRequestSent() callback. |
42 virtual void OnResponseReceived(HttpResponseInfo* response) = 0; | 70 virtual void OnResponseReceived(HttpResponseInfo* response) = 0; |
| 71 |
| 72 // Called by the FlipSession when response data has been received for this |
| 73 // request. This callback may be called multiple times as data arrives |
| 74 // from the network, and will never be called prior to OnResponseReceived. |
| 75 // |buffer| contains the data received. The delegate must copy any data |
| 76 // from this buffer before returning from this callback. |
| 77 // |bytes| is the number of bytes received or an error. |
| 78 // A zero-length count does not indicate end-of-stream. |
43 virtual void OnDataReceived(const char* buffer, int bytes) = 0; | 79 virtual void OnDataReceived(const char* buffer, int bytes) = 0; |
| 80 |
| 81 // Called by the FlipSession when the request is finished. This callback |
| 82 // will always be called at the end of the request and signals to the |
| 83 // delegate that the delegate can be torn down. No further callbacks to the |
| 84 // delegate will be made after this call. |
| 85 // |status| is an error code or OK. |
44 virtual void OnClose(int status) = 0; | 86 virtual void OnClose(int status) = 0; |
45 virtual void OnCancel() = 0; | |
46 }; | 87 }; |
47 | 88 |
48 class PrioritizedIOBuffer { | 89 class PrioritizedIOBuffer { |
49 public: | 90 public: |
50 PrioritizedIOBuffer() : buffer_(0), priority_(0) {} | 91 PrioritizedIOBuffer() : buffer_(0), priority_(0) {} |
51 PrioritizedIOBuffer(IOBufferWithSize* buffer, int priority) | 92 PrioritizedIOBuffer(IOBufferWithSize* buffer, int priority) |
52 : buffer_(buffer), | 93 : buffer_(buffer), |
53 priority_(priority), | 94 priority_(priority), |
54 position_(++order_) { | 95 position_(++order_) { |
55 } | 96 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 263 |
223 // This is our weak session pool - one session per domain. | 264 // This is our weak session pool - one session per domain. |
224 static scoped_ptr<FlipSessionPool> session_pool_; | 265 static scoped_ptr<FlipSessionPool> session_pool_; |
225 static bool use_ssl_; | 266 static bool use_ssl_; |
226 }; | 267 }; |
227 | 268 |
228 } // namespace net | 269 } // namespace net |
229 | 270 |
230 #endif // NET_FLIP_FLIP_SESSION_H_ | 271 #endif // NET_FLIP_FLIP_SESSION_H_ |
231 | 272 |
OLD | NEW |