| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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_QUIC_QUIC_TYPES_H_ | |
| 6 #define NET_QUIC_QUIC_TYPES_H_ | |
| 7 | |
| 8 // This header defines some basic types that don't depend on quic_protocol.h, | |
| 9 // so that classes not directly related to the protocol wire format can avoid | |
| 10 // including quic_protocol.h. | |
| 11 | |
| 12 #include <stddef.h> | |
| 13 | |
| 14 #include <ostream> | |
| 15 | |
| 16 #include "net/base/net_export.h" | |
| 17 | |
| 18 namespace net { | |
| 19 | |
| 20 // A struct for functions which consume data payloads and fins. | |
| 21 struct NET_EXPORT_PRIVATE QuicConsumedData { | |
| 22 QuicConsumedData(size_t bytes_consumed, bool fin_consumed); | |
| 23 | |
| 24 // By default, gtest prints the raw bytes of an object. The bool data | |
| 25 // member causes this object to have padding bytes, which causes the | |
| 26 // default gtest object printer to read uninitialize memory. So we need | |
| 27 // to teach gtest how to print this object. | |
| 28 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, | |
| 29 const QuicConsumedData& s); | |
| 30 | |
| 31 // How many bytes were consumed. | |
| 32 size_t bytes_consumed; | |
| 33 | |
| 34 // True if an incoming fin was consumed. | |
| 35 bool fin_consumed; | |
| 36 }; | |
| 37 | |
| 38 // QuicAsyncStatus enumerates the possible results of an asynchronous | |
| 39 // operation. | |
| 40 enum QuicAsyncStatus { | |
| 41 QUIC_SUCCESS = 0, | |
| 42 QUIC_FAILURE = 1, | |
| 43 // QUIC_PENDING results from an operation that will occur asynchonously. When | |
| 44 // the operation is complete, a callback's |Run| method will be called. | |
| 45 QUIC_PENDING = 2, | |
| 46 }; | |
| 47 | |
| 48 // TODO(wtc): see if WriteStatus can be replaced by QuicAsyncStatus. | |
| 49 enum WriteStatus { | |
| 50 WRITE_STATUS_OK, | |
| 51 WRITE_STATUS_BLOCKED, | |
| 52 WRITE_STATUS_ERROR, | |
| 53 }; | |
| 54 | |
| 55 // A struct used to return the result of write calls including either the number | |
| 56 // of bytes written or the error code, depending upon the status. | |
| 57 struct NET_EXPORT_PRIVATE WriteResult { | |
| 58 WriteResult(WriteStatus status, int bytes_written_or_error_code); | |
| 59 WriteResult(); | |
| 60 | |
| 61 WriteStatus status; | |
| 62 union { | |
| 63 int bytes_written; // only valid when status is WRITE_STATUS_OK | |
| 64 int error_code; // only valid when status is WRITE_STATUS_ERROR | |
| 65 }; | |
| 66 }; | |
| 67 | |
| 68 } // namespace net | |
| 69 | |
| 70 #endif // NET_QUIC_QUIC_TYPES_H_ | |
| OLD | NEW |