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

Side by Side Diff: net/http/http_stream.h

Issue 119346: Introduce HttpStream and HttpBasicStream. (Closed)
Patch Set: Add comments to HttpBasicStream. Switch declaration order of Read/Write. Created 11 years, 6 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
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // HttpStream is an interface for reading and writing data to an HttpStream that
6 // keeps the client agnostic of the actual underlying transport layer. This
7 // provides an abstraction for both a basic http stream as well as http
8 // pipelining implementations.
9 //
10 // NOTE(willchan): This interface is a work in progress. It will most likely
11 // change, since for a pipelining implementation, the stream needs to contain
12 // the http parsing code. For symmetry, the writing methods will probably
13 // contain the code for constructing http requests.
14
15 #ifndef NET_HTTP_HTTP_STREAM_H_
16 #define NET_HTTP_HTTP_STREAM_H_
17
18 #include "base/basictypes.h"
19 #include "net/base/completion_callback.h"
20
21 namespace net {
22
23 class IOBuffer;
24
25 class HttpStream {
26 public:
27 HttpStream() {}
28 virtual ~HttpStream() {}
29
30 // Reads data, up to buf_len bytes, from the socket. The number of bytes
31 // read is returned, or an error is returned upon failure. Zero is returned
32 // to indicate end-of-file. ERR_IO_PENDING is returned if the operation
33 // could not be completed synchronously, in which case the result will be
34 // passed to the callback when available. If the operation is not completed
35 // immediately, the socket acquires a reference to the provided buffer until
36 // the callback is invoked or the socket is destroyed.
37 virtual int Read(IOBuffer* buf,
38 int buf_len,
39 CompletionCallback* callback) = 0;
40
41 // Writes data, up to buf_len bytes, to the socket. Note: only part of the
42 // data may be written! The number of bytes written is returned, or an error
43 // is returned upon failure. ERR_IO_PENDING is returned if the operation
44 // could not be completed synchronously, in which case the result will be
45 // passed to the callback when available. If the operation is not completed
46 // immediately, the socket acquires a reference to the provided buffer until
47 // the callback is invoked or the socket is destroyed.
48 // Implementations of this method should not modify the contents of the actual
49 // buffer that is written to the socket.
50 virtual int Write(IOBuffer* buf,
51 int buf_len,
52 CompletionCallback* callback) = 0;
53
54 private:
55 DISALLOW_COPY_AND_ASSIGN(HttpStream);
56 };
57
58 } // namespace net
59
60 #endif // NET_HTTP_HTTP_STREAM_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698