Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: net/spdy/spdy_stream.h

Issue 6292013: Add chunked uploads support to SPDY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_SPDY_SPDY_STREAM_H_ 5 #ifndef NET_SPDY_SPDY_STREAM_H_
6 #define NET_SPDY_SPDY_STREAM_H_ 6 #define NET_SPDY_SPDY_STREAM_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/linked_ptr.h" 13 #include "base/linked_ptr.h"
14 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "net/base/bandwidth_metrics.h" 17 #include "net/base/bandwidth_metrics.h"
18 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
19 #include "net/base/upload_data.h"
19 #include "net/base/net_log.h" 20 #include "net/base/net_log.h"
20 #include "net/spdy/spdy_framer.h" 21 #include "net/spdy/spdy_framer.h"
21 #include "net/spdy/spdy_protocol.h" 22 #include "net/spdy/spdy_protocol.h"
22 23
23 namespace net { 24 namespace net {
24 25
25 class AddressList; 26 class AddressList;
26 class SpdySession; 27 class SpdySession;
27 class SSLCertRequestInfo; 28 class SSLCertRequestInfo;
28 class SSLInfo; 29 class SSLInfo;
29 30
30 // The SpdyStream is used by the SpdySession to represent each stream known 31 // The SpdyStream is used by the SpdySession to represent each stream known
31 // on the SpdySession. This class provides interfaces for SpdySession to use. 32 // on the SpdySession. This class provides interfaces for SpdySession to use.
32 // Streams can be created either by the client or by the server. When they 33 // Streams can be created either by the client or by the server. When they
33 // are initiated by the client, both the SpdySession and client object (such as 34 // are initiated by the client, both the SpdySession and client object (such as
34 // a SpdyNetworkTransaction) will maintain a reference to the stream. When 35 // a SpdyNetworkTransaction) will maintain a reference to the stream. When
35 // initiated by the server, only the SpdySession will maintain any reference, 36 // initiated by the server, only the SpdySession will maintain any reference,
36 // until such a time as a client object requests a stream for the path. 37 // until such a time as a client object requests a stream for the path.
37 class SpdyStream : public base::RefCounted<SpdyStream> { 38 class SpdyStream
39 : public base::RefCounted<SpdyStream>,
40 public ChunkCallback {
38 public: 41 public:
39 // Delegate handles protocol specific behavior of spdy stream. 42 // Delegate handles protocol specific behavior of spdy stream.
40 class Delegate { 43 class Delegate {
41 public: 44 public:
42 Delegate() {} 45 Delegate() {}
43 46
44 // Called when SYN frame has been sent. 47 // Called when SYN frame has been sent.
45 // Returns true if no more data to be sent after SYN frame. 48 // Returns true if no more data to be sent after SYN frame.
46 virtual bool OnSendHeadersComplete(int status) = 0; 49 virtual bool OnSendHeadersComplete(int status) = 0;
47 50
48 // Called when stream is ready to send data. 51 // Called when stream is ready to send data.
49 // Returns network error code. OK when it successfully sent data. 52 // Returns network error code. OK when it successfully sent data.
50 virtual int OnSendBody() = 0; 53 virtual int OnSendBody() = 0;
51 54
52 // Called when data has been sent. |status| indicates network error 55 // Called when data has been sent. |status| indicates network error
53 // or number of bytes has been sent. 56 // or number of bytes has been sent.
54 // Returns true if no more data to be sent. 57 // Returns true if no more data to be sent.
55 virtual bool OnSendBodyComplete(int status) = 0; 58 virtual bool OnSendBodyComplete(int* status) = 0;
willchan no longer on Chromium 2011/02/01 23:35:59 Change this to be more consistent with the rest of
Satish 2011/02/22 14:25:44 Done.
56 59
57 // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received. 60 // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received.
58 // Normal streams will receive a SYN_REPLY and optional HEADERS frames. 61 // Normal streams will receive a SYN_REPLY and optional HEADERS frames.
59 // Pushed streams will receive a SYN_STREAM and optional HEADERS frames. 62 // Pushed streams will receive a SYN_STREAM and optional HEADERS frames.
60 // Because a stream may have a SYN_* frame and multiple HEADERS frames, 63 // Because a stream may have a SYN_* frame and multiple HEADERS frames,
61 // this callback may be called multiple times. 64 // this callback may be called multiple times.
62 // |status| indicates network error. Returns network error code. 65 // |status| indicates network error. Returns network error code.
63 virtual int OnResponseReceived(const spdy::SpdyHeaderBlock& response, 66 virtual int OnResponseReceived(const spdy::SpdyHeaderBlock& response,
64 base::Time response_time, 67 base::Time response_time,
65 int status) = 0; 68 int status) = 0;
66 69
67 // Called when data is received. 70 // Called when data is received.
68 virtual void OnDataReceived(const char* data, int length) = 0; 71 virtual void OnDataReceived(const char* data, int length) = 0;
69 72
70 // Called when data is sent. 73 // Called when data is sent.
71 virtual void OnDataSent(int length) = 0; 74 virtual void OnDataSent(int length) = 0;
72 75
73 // Called when SpdyStream is closed. 76 // Called when SpdyStream is closed.
74 virtual void OnClose(int status) = 0; 77 virtual void OnClose(int status) = 0;
75 78
79 virtual void set_chunk_callback(ChunkCallback* callback) = 0;
willchan no longer on Chromium 2011/02/01 23:35:59 Please comment this.
80
76 protected: 81 protected:
77 friend class base::RefCounted<Delegate>; 82 friend class base::RefCounted<Delegate>;
78 virtual ~Delegate() {} 83 virtual ~Delegate() {}
79 84
80 private: 85 private:
81 DISALLOW_COPY_AND_ASSIGN(Delegate); 86 DISALLOW_COPY_AND_ASSIGN(Delegate);
82 }; 87 };
83 88
84 // SpdyStream constructor 89 // SpdyStream constructor
85 SpdyStream(SpdySession* session, 90 SpdyStream(SpdySession* session,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 220
216 int response_status() const { return response_status_; } 221 int response_status() const { return response_status_; }
217 222
218 // Returns true if the URL for this stream is known. 223 // Returns true if the URL for this stream is known.
219 bool HasUrl() const; 224 bool HasUrl() const;
220 225
221 // Get the URL associated with this stream. Only valid when has_url() is 226 // Get the URL associated with this stream. Only valid when has_url() is
222 // true. 227 // true.
223 GURL GetUrl() const; 228 GURL GetUrl() const;
224 229
230 // ChunkCallback methods.
231 virtual void OnChunkAvailable();
232
225 private: 233 private:
226 enum State { 234 enum State {
227 STATE_NONE, 235 STATE_NONE,
228 STATE_SEND_HEADERS, 236 STATE_SEND_HEADERS,
229 STATE_SEND_HEADERS_COMPLETE, 237 STATE_SEND_HEADERS_COMPLETE,
230 STATE_SEND_BODY, 238 STATE_SEND_BODY,
231 STATE_SEND_BODY_COMPLETE, 239 STATE_SEND_BODY_COMPLETE,
232 STATE_WAITING_FOR_RESPONSE, 240 STATE_WAITING_FOR_RESPONSE,
233 STATE_OPEN, 241 STATE_OPEN,
234 STATE_DONE 242 STATE_DONE
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 int recv_bytes_; 316 int recv_bytes_;
309 // Data received before delegate is attached. 317 // Data received before delegate is attached.
310 std::vector<scoped_refptr<IOBufferWithSize> > pending_buffers_; 318 std::vector<scoped_refptr<IOBufferWithSize> > pending_buffers_;
311 319
312 DISALLOW_COPY_AND_ASSIGN(SpdyStream); 320 DISALLOW_COPY_AND_ASSIGN(SpdyStream);
313 }; 321 };
314 322
315 } // namespace net 323 } // namespace net
316 324
317 #endif // NET_SPDY_SPDY_STREAM_H_ 325 #endif // NET_SPDY_SPDY_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698