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

Side by Side Diff: net/flip/flip_io_buffer.h

Issue 341032: Rename PrioritizedIOBuffer to FlipIOBuffer, refactor it into... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/flip/flip_io_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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 #ifndef NET_FLIP_FLIP_IO_BUFFER_H_
6 #define NET_FLIP_FLIP_IO_BUFFER_H_
7
8 #include "base/ref_counted.h"
9 #include "net/base/io_buffer.h"
10
11 namespace net {
12
13 class FlipStream;
14
15 // A class for managing FLIP IO buffers. These buffers need to be prioritized
16 // so that the FlipSession sends them in the right order. Further, they need
17 // to track the FlipStream which they are associated with so that incremental
18 // completion of the IO can notify the appropriate stream of completion.
19 class FlipIOBuffer {
20 public:
21 // Constructor
22 // |buffer| is the actual data buffer.
23 // |priority| is the priority of this buffer. Lower numbers are higher
24 // priority.
25 // |stream| is a pointer to the stream which is managing this buffer.
26 FlipIOBuffer(IOBufferWithSize* buffer, int priority, FlipStream* stream)
27 : buffer_(buffer),
28 priority_(priority),
29 position_(++order_),
30 stream_(stream) {
31 }
32 FlipIOBuffer() : priority_(0), stream_(NULL) {}
33
34 // Accessors.
35 IOBuffer* buffer() const { return buffer_; }
36 size_t size() const { return buffer_->size(); }
37 void release() { buffer_ = NULL; }
38 int priority() const { return priority_; }
39 FlipStream* stream() const { return stream_; }
40
41 // Comparison operator to support sorting.
42 bool operator<(const FlipIOBuffer& other) const {
43 if (priority_ != other.priority_)
44 return priority_ > other.priority_;
45 return position_ > other.position_;
46 }
47
48 private:
49 scoped_refptr<IOBufferWithSize> buffer_;
50 int priority_;
51 uint64 position_;
52 FlipStream* stream_;
53 static uint64 order_; // Maintains a FIFO order for equal priorities.
54 };
55
56 } // namespace net
57
58 #endif // NET_FLIP_FLIP_IO_BUFFER_H_
59
OLDNEW
« no previous file with comments | « no previous file | net/flip/flip_io_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698