| Index: net/http/bidirectional_stream_job.h
|
| diff --git a/net/http/bidirectional_stream_job.h b/net/http/bidirectional_stream_job.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e9c72858663501ad38344822ae8b2fff99babe18
|
| --- /dev/null
|
| +++ b/net/http/bidirectional_stream_job.h
|
| @@ -0,0 +1,88 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_HTTP_BIDIRECTIONAL_STREAM_JOB_H_
|
| +#define NET_HTTP_BIDIRECTIONAL_STREAM_JOB_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "net/base/net_export.h"
|
| +#include "net/base/request_priority.h"
|
| +
|
| +namespace net {
|
| +
|
| +class BoundNetLog;
|
| +class IOBuffer;
|
| +class SpdyHeaderBlock;
|
| +struct HttpRequestInfo;
|
| +
|
| +// Exposes an interface to do HTTP/2 bidirectional streaming.
|
| +// Note that only one ReadData or SendData should be in flight until the
|
| +// operation completes synchronously or asynchronously.
|
| +// BidirectionalStreamJob once created by HttpStreamFactoryImpl should be owned
|
| +// by BidirectionalStream.
|
| +class NET_EXPORT_PRIVATE BidirectionalStreamJob {
|
| + public:
|
| + // Delegate to handle BidirectionalStreamJob events.
|
| + class Delegate {
|
| + public:
|
| + Delegate();
|
| +
|
| + // Called when the request headers have been sent.
|
| + virtual void OnRequestHeadersSent() = 0;
|
| +
|
| + // Called when response headers are received.
|
| + // The delegate should call BidirectionalStreamJob::ReadData to start
|
| + // reading or call BidirectionalStream::Cancel to cancel the stream.
|
| + virtual void OnHeaders(const SpdyHeaderBlock& response_headers) = 0;
|
| +
|
| + // Called when read is completed asynchronously. |bytes_read| specifies how
|
| + // much data is available.
|
| + // The delegate should call BidirectionalStreamJob::ReadData to continue
|
| + // reading or call BidirectionalStream::Cancel to cancel the stream.
|
| + virtual void OnReadCompleted(int bytes_read) = 0;
|
| +
|
| + // Called when the entire buffer passed through SendData is sent.
|
| + virtual void OnDataSent() = 0;
|
| +
|
| + // Called when trailers are received.
|
| + // No other delegate functions will be called after this.
|
| + virtual void OnTrailers(const SpdyHeaderBlock& trailers) = 0;
|
| +
|
| + // Called when an error occurred.
|
| + // No other delegate functions will be called after this.
|
| + virtual void OnFailed(int status) = 0;
|
| +
|
| + protected:
|
| + virtual ~Delegate();
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(Delegate);
|
| + };
|
| +
|
| + BidirectionalStreamJob();
|
| + virtual ~BidirectionalStreamJob();
|
| +
|
| + // Starts the BidirectionalStreamJob and sends request headers.
|
| + virtual void Start(const HttpRequestInfo& request_info,
|
| + RequestPriority priority,
|
| + const BoundNetLog& net_log,
|
| + Delegate* delegate) = 0;
|
| +
|
| + // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read,
|
| + // or ERR_IO_PENDING if the read is to be completed asynchronously.
|
| + virtual int ReadData(IOBuffer* buf, int buf_len) = 0;
|
| +
|
| + // Sends data. This should not be called again until OnDataSent is invoked.
|
| + virtual void SendData(IOBuffer* data, int length, bool end_stream) = 0;
|
| +
|
| + // Cancels the stream. No Delegate method will be called.
|
| + virtual void Cancel() = 0;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamJob);
|
| +};
|
| +
|
| +} // namespace net
|
| +
|
| +#endif // NET_HTTP_BIDIRECTIONAL_STREAM_JOB_H_
|
|
|