| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_SPDY_SPDY_IO_BUFFER_H_ | 5 #ifndef NET_SPDY_SPDY_IO_BUFFER_H_ |
| 6 #define NET_SPDY_SPDY_IO_BUFFER_H_ | 6 #define NET_SPDY_SPDY_IO_BUFFER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 SpdyIOBuffer(IOBuffer* buffer, int size, int priority, SpdyStream* stream); | 28 SpdyIOBuffer(IOBuffer* buffer, int size, int priority, SpdyStream* stream); |
| 29 SpdyIOBuffer(); | 29 SpdyIOBuffer(); |
| 30 ~SpdyIOBuffer(); | 30 ~SpdyIOBuffer(); |
| 31 | 31 |
| 32 // Accessors. | 32 // Accessors. |
| 33 DrainableIOBuffer* buffer() const { return buffer_; } | 33 DrainableIOBuffer* buffer() const { return buffer_; } |
| 34 size_t size() const { return buffer_->size(); } | 34 size_t size() const { return buffer_->size(); } |
| 35 void release(); | 35 void release(); |
| 36 int priority() const { return priority_; } | 36 int priority() const { return priority_; } |
| 37 const scoped_refptr<SpdyStream>& stream() const { return stream_; } | 37 const scoped_refptr<SpdyStream>& stream() const { return stream_; } |
| 38 uint16 sctp_stream_id() { |
| 39 return buffer()->sctp_stream_id(); |
| 40 } |
| 41 void set_sctp_stream_id(uint16 sctp_stream_id) { |
| 42 buffer()->set_sctp_stream_id(sctp_stream_id); |
| 43 } |
| 38 | 44 |
| 39 // Comparison operator to support sorting. | 45 // Comparison operator to support sorting. |
| 40 bool operator<(const SpdyIOBuffer& other) const { | 46 bool operator<(const SpdyIOBuffer& other) const { |
| 41 if (priority_ != other.priority_) | 47 if (priority_ != other.priority_) |
| 42 return priority_ > other.priority_; | 48 return priority_ > other.priority_; |
| 43 return position_ > other.position_; | 49 return position_ > other.position_; |
| 44 } | 50 } |
| 45 | 51 |
| 46 private: | 52 private: |
| 47 scoped_refptr<DrainableIOBuffer> buffer_; | 53 scoped_refptr<DrainableIOBuffer> buffer_; |
| 48 int priority_; | 54 int priority_; |
| 49 uint64 position_; | 55 uint64 position_; |
| 50 scoped_refptr<SpdyStream> stream_; | 56 scoped_refptr<SpdyStream> stream_; |
| 51 static uint64 order_; // Maintains a FIFO order for equal priorities. | 57 static uint64 order_; // Maintains a FIFO order for equal priorities. |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 } // namespace net | 60 } // namespace net |
| 55 | 61 |
| 56 #endif // NET_SPDY_SPDY_IO_BUFFER_H_ | 62 #endif // NET_SPDY_SPDY_IO_BUFFER_H_ |
| OLD | NEW |