| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 private: | 113 private: |
| 114 scoped_refptr<IOBufferWithSize> buffer_; | 114 scoped_refptr<IOBufferWithSize> buffer_; |
| 115 int priority_; | 115 int priority_; |
| 116 int position_; | 116 int position_; |
| 117 static int order_; // Maintains a FIFO order for equal priorities. | 117 static int order_; // Maintains a FIFO order for equal priorities. |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 class FlipSession : public base::RefCounted<FlipSession>, | 120 class FlipSession : public base::RefCounted<FlipSession>, |
| 121 public flip::FlipFramerVisitorInterface { | 121 public flip::FlipFramerVisitorInterface { |
| 122 public: | 122 public: |
| 123 // Factory for finding open sessions. | |
| 124 // TODO(mbelshe): Break this out into a connection pool class? | |
| 125 static FlipSession* GetFlipSession(const HostResolver::RequestInfo&, | |
| 126 HttpNetworkSession* session); | |
| 127 virtual ~FlipSession(); | 123 virtual ~FlipSession(); |
| 128 | 124 |
| 129 // Get the domain for this FlipSession. | 125 // Get the domain for this FlipSession. |
| 130 std::string domain() { return domain_; } | 126 const std::string& domain() const { return domain_; } |
| 131 | 127 |
| 132 // Connect the FLIP Socket. | 128 // Connect the FLIP Socket. |
| 133 // Returns net::Error::OK on success. | 129 // Returns net::Error::OK on success. |
| 134 // Note that this call does not wait for the connect to complete. Callers can | 130 // Note that this call does not wait for the connect to complete. Callers can |
| 135 // immediately start using the FlipSession while it connects. | 131 // immediately start using the FlipSession while it connects. |
| 136 net::Error Connect(const std::string& group_name, | 132 net::Error Connect(const std::string& group_name, |
| 137 const HostResolver::RequestInfo& host, int priority); | 133 const HostResolver::RequestInfo& host, int priority); |
| 138 | 134 |
| 139 // Create a new stream. | 135 // Create a new stream. |
| 140 // FlipDelegate must remain valid until the stream is either cancelled by the | 136 // FlipDelegate must remain valid until the stream is either cancelled by the |
| 141 // creator via CancelStream or the FlipDelegate OnClose or OnCancel callbacks | 137 // creator via CancelStream or the FlipDelegate OnClose or OnCancel callbacks |
| 142 // have been made. | 138 // have been made. |
| 143 // Once the stream is created, the delegate should wait for a callback. | 139 // Once the stream is created, the delegate should wait for a callback. |
| 144 int CreateStream(FlipDelegate* delegate); | 140 int CreateStream(FlipDelegate* delegate); |
| 145 | 141 |
| 146 // Cancel a stream. | 142 // Cancel a stream. |
| 147 bool CancelStream(int id); | 143 bool CancelStream(int id); |
| 148 | 144 |
| 149 // Check if a stream is active. | 145 // Check if a stream is active. |
| 150 bool IsStreamActive(int id); | 146 bool IsStreamActive(int id) const; |
| 151 | 147 |
| 152 // The LoadState is used for informing the user of the current network | 148 // The LoadState is used for informing the user of the current network |
| 153 // status, such as "resolving host", "connecting", etc. | 149 // status, such as "resolving host", "connecting", etc. |
| 154 LoadState GetLoadState() const; | 150 LoadState GetLoadState() const; |
| 151 |
| 155 protected: | 152 protected: |
| 156 friend class FlipNetworkTransactionTest; | 153 friend class FlipNetworkTransactionTest; |
| 157 friend class FlipSessionPool; | 154 friend class FlipSessionPool; |
| 158 friend class HttpNetworkLayer; // Temporary for server. | 155 friend class HttpNetworkLayer; // Temporary for server. |
| 159 | 156 |
| 160 // Provide access to the framer for testing. | 157 // Provide access to the framer for testing. |
| 161 flip::FlipFramer* GetFramer() { return &flip_framer_; } | 158 flip::FlipFramer* GetFramer() { return &flip_framer_; } |
| 162 | 159 |
| 163 // Create a new FlipSession. | 160 // Create a new FlipSession. |
| 164 // |host| is the hostname that this session connects to. | 161 // |host| is the hostname that this session connects to. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 251 |
| 255 // TODO(mbelshe): this is ugly!! | 252 // TODO(mbelshe): this is ugly!! |
| 256 // The packet we are currently sending. | 253 // The packet we are currently sending. |
| 257 PrioritizedIOBuffer in_flight_write_; | 254 PrioritizedIOBuffer in_flight_write_; |
| 258 bool delayed_write_pending_; | 255 bool delayed_write_pending_; |
| 259 bool write_pending_; | 256 bool write_pending_; |
| 260 | 257 |
| 261 // Flip Frame state. | 258 // Flip Frame state. |
| 262 flip::FlipFramer flip_framer_; | 259 flip::FlipFramer flip_framer_; |
| 263 | 260 |
| 264 // This is our weak session pool - one session per domain. | |
| 265 static scoped_ptr<FlipSessionPool> session_pool_; | |
| 266 static bool use_ssl_; | 261 static bool use_ssl_; |
| 267 }; | 262 }; |
| 268 | 263 |
| 269 } // namespace net | 264 } // namespace net |
| 270 | 265 |
| 271 #endif // NET_FLIP_FLIP_SESSION_H_ | 266 #endif // NET_FLIP_FLIP_SESSION_H_ |
| 272 | |
| OLD | NEW |