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

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

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Get rid of Delegate::OnClose Created 5 years 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_
6 #define NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "net/http/bidirectional_stream_job.h"
11 #include "net/http/http_request_info.h"
12 #include "net/spdy/spdy_read_queue.h"
13 #include "net/spdy/spdy_session.h"
14 #include "net/spdy/spdy_stream.h"
15
16 namespace base {
17 class Timer;
18 } // namespace base
19
20 namespace net {
21
22 class BoundNetLog;
23 class IOBuffer;
24 class SpdyHeaderBlock;
25
26 class NET_EXPORT_PRIVATE BidirectionalStreamSpdyJob
27 : public BidirectionalStreamJob,
28 public SpdyStream::Delegate {
29 public:
30 BidirectionalStreamSpdyJob(const base::WeakPtr<SpdySession>& spdy_session);
31
32 // Constructor that accepts a Timer. This is used in tests.
33 BidirectionalStreamSpdyJob(const base::WeakPtr<SpdySession>& spdy_session,
34 scoped_ptr<base::Timer> timer);
35 ~BidirectionalStreamSpdyJob() override;
36
37 // BidirectionalStreamSpdyJob implementation:
38
39 void Start(const HttpRequestInfo& request_info,
40 RequestPriority priority,
41 const BoundNetLog& net_log,
42 BidirectionalStreamJob::Delegate* delegate) override;
43
44 int ReadData(IOBuffer* buf, int buf_len) override;
45
46 void SendData(IOBuffer* data, int length, bool end_stream) override;
47
48 void Cancel() override;
49
50 // SpdyStream::Delegate implementation:
51
52 void OnRequestHeadersSent() override;
53
54 SpdyResponseHeadersStatus OnResponseHeadersUpdated(
55 const SpdyHeaderBlock& response_headers) override;
56
57 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override;
58
59 void OnDataSent() override;
60
61 void OnTrailers(const SpdyHeaderBlock& trailers) override;
62
63 void OnClose(int status) override;
64
65 private:
66 void SendRequestHeaders();
67 void OnStreamInitialized(int rv);
68 void ScheduleBufferedRead();
69 void DoBufferedRead();
70 bool ShouldWaitForMoreBufferedData() const;
71
72 const base::WeakPtr<SpdySession> spdy_session_;
73 scoped_ptr<base::Timer> timer_;
74 bool stream_closed_;
75 int closed_stream_status_;
76 bool more_read_data_pending_;
77
78 HttpRequestInfo request_info_;
79 // Buffers the data as it arrives asynchronously from the stream.
80 SpdyReadQueue data_queue_;
81 // User provided buffer for ReadData() response.
82 scoped_refptr<IOBuffer> user_buffer_;
83 int user_buffer_len_;
84
85 BidirectionalStreamJob::Delegate* delegate_;
86 SpdyStreamRequest stream_request_;
87 base::WeakPtr<SpdyStream> stream_;
88
89 base::WeakPtrFactory<BidirectionalStreamSpdyJob> weak_factory_;
90
91 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamSpdyJob);
92 };
93
94 } // namespace net
95
96 #endif // NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_
OLDNEW
« net/net.gypi ('K') | « net/net.gypi ('k') | net/spdy/bidirectional_stream_spdy_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698