OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Protobuf ZeroCopy[Input/Output]Stream implementations capable of using a | 5 // Protobuf ZeroCopy[Input/Output]Stream implementations capable of using a |
6 // net::StreamSocket. Built to work with Protobuf CodedStreams. | 6 // net::StreamSocket. Built to work with Protobuf CodedStreams. |
7 | 7 |
8 #ifndef GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_H_ | 8 #ifndef GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_H_ |
9 #define GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_H_ | 9 #define GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_H_ |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 READING, | 59 READING, |
60 // An permanent error occurred and the stream is now closed. | 60 // An permanent error occurred and the stream is now closed. |
61 CLOSED, | 61 CLOSED, |
62 }; | 62 }; |
63 | 63 |
64 // |socket| should already be connected. | 64 // |socket| should already be connected. |
65 explicit SocketInputStream(net::StreamSocket* socket); | 65 explicit SocketInputStream(net::StreamSocket* socket); |
66 virtual ~SocketInputStream(); | 66 virtual ~SocketInputStream(); |
67 | 67 |
68 // ZeroCopyInputStream implementation. | 68 // ZeroCopyInputStream implementation. |
69 virtual bool Next(const void** data, int* size) OVERRIDE; | 69 virtual bool Next(const void** data, int* size) override; |
70 virtual void BackUp(int count) OVERRIDE; | 70 virtual void BackUp(int count) override; |
71 virtual bool Skip(int count) OVERRIDE; // Not implemented. | 71 virtual bool Skip(int count) override; // Not implemented. |
72 virtual int64 ByteCount() const OVERRIDE; | 72 virtual int64 ByteCount() const override; |
73 | 73 |
74 // The remaining amount of valid data available to be read. | 74 // The remaining amount of valid data available to be read. |
75 int UnreadByteCount() const; | 75 int UnreadByteCount() const; |
76 | 76 |
77 // Reads from the socket, appending a max of |byte_limit| bytes onto the read | 77 // Reads from the socket, appending a max of |byte_limit| bytes onto the read |
78 // buffer. net::ERR_IO_PENDING is returned if the refresh can't complete | 78 // buffer. net::ERR_IO_PENDING is returned if the refresh can't complete |
79 // synchronously, in which case the callback is invoked upon completion. If | 79 // synchronously, in which case the callback is invoked upon completion. If |
80 // the refresh can complete synchronously, even in case of an error, returns | 80 // the refresh can complete synchronously, even in case of an error, returns |
81 // net::OK without invoking callback. | 81 // net::OK without invoking callback. |
82 // Note: GetState() (and possibly last_error()) should be checked upon | 82 // Note: GetState() (and possibly last_error()) should be checked upon |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 FLUSHING, | 155 FLUSHING, |
156 // A permanent error occurred, and the stream is now closed. | 156 // A permanent error occurred, and the stream is now closed. |
157 CLOSED, | 157 CLOSED, |
158 }; | 158 }; |
159 | 159 |
160 // |socket| should already be connected. | 160 // |socket| should already be connected. |
161 explicit SocketOutputStream(net::StreamSocket* socket); | 161 explicit SocketOutputStream(net::StreamSocket* socket); |
162 virtual ~SocketOutputStream(); | 162 virtual ~SocketOutputStream(); |
163 | 163 |
164 // ZeroCopyOutputStream implementation. | 164 // ZeroCopyOutputStream implementation. |
165 virtual bool Next(void** data, int* size) OVERRIDE; | 165 virtual bool Next(void** data, int* size) override; |
166 virtual void BackUp(int count) OVERRIDE; | 166 virtual void BackUp(int count) override; |
167 virtual int64 ByteCount() const OVERRIDE; | 167 virtual int64 ByteCount() const override; |
168 | 168 |
169 // Writes the buffer into the Socket. | 169 // Writes the buffer into the Socket. |
170 net::Error Flush(const base::Closure& callback); | 170 net::Error Flush(const base::Closure& callback); |
171 | 171 |
172 // Returns the last fatal error encountered. Only valid if GetState() == | 172 // Returns the last fatal error encountered. Only valid if GetState() == |
173 // CLOSED. | 173 // CLOSED. |
174 net::Error last_error() const; | 174 net::Error last_error() const; |
175 | 175 |
176 // Returns the current state. | 176 // Returns the current state. |
177 State GetState() const; | 177 State GetState() const; |
(...skipping 18 matching lines...) Expand all Loading... |
196 net::Error last_error_; | 196 net::Error last_error_; |
197 | 197 |
198 base::WeakPtrFactory<SocketOutputStream> weak_ptr_factory_; | 198 base::WeakPtrFactory<SocketOutputStream> weak_ptr_factory_; |
199 | 199 |
200 DISALLOW_COPY_AND_ASSIGN(SocketOutputStream); | 200 DISALLOW_COPY_AND_ASSIGN(SocketOutputStream); |
201 }; | 201 }; |
202 | 202 |
203 } // namespace gcm | 203 } // namespace gcm |
204 | 204 |
205 #endif // GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_H_ | 205 #endif // GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_H_ |
OLD | NEW |