diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 21:24:02 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 21:24:02 +0000 |
commit | a1640051f4c4abcc7c7de1b224e696284f1fbc57 (patch) | |
tree | 90f8c99cdb789c2a493ee2f49fcf3a6047d874b7 /net | |
parent | ba75f013cb87b3404a8b0352956fc42dde29ce5c (diff) | |
download | chromium_src-a1640051f4c4abcc7c7de1b224e696284f1fbc57.zip chromium_src-a1640051f4c4abcc7c7de1b224e696284f1fbc57.tar.gz chromium_src-a1640051f4c4abcc7c7de1b224e696284f1fbc57.tar.bz2 |
Rename PrioritizedIOBuffer to FlipIOBuffer, refactor it into
its own file, and have it carry a FlipStream pointer.
The PrioritizedIOBuffer was more generic, but after we queued IO,
we couldn't track which stream should be notified about the IO
completion. Having it carry the FlipStream pointer will enable
IO tracking, but with a FlipStream pointer, it is really specific
to Flip, so I renamed to FlipIOBuffer. I could have kept a generic
(void*) pointer (or used a template), but that seemed unnecessary
in this case.
This CL just changes the refactoring. Will remove the
PrioritizedIOBuffer next.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/341032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/flip/flip_io_buffer.cc | 13 | ||||
-rw-r--r-- | net/flip/flip_io_buffer.h | 59 | ||||
-rw-r--r-- | net/net.gyp | 2 |
3 files changed, 74 insertions, 0 deletions
diff --git a/net/flip/flip_io_buffer.cc b/net/flip/flip_io_buffer.cc new file mode 100644 index 0000000..963aa3e --- /dev/null +++ b/net/flip/flip_io_buffer.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/flip/flip_io_buffer.h" + +namespace net { + +// static +uint64 FlipIOBuffer::order_ = 0; + +} // namespace net + diff --git a/net/flip/flip_io_buffer.h b/net/flip/flip_io_buffer.h new file mode 100644 index 0000000..c7b6155 --- /dev/null +++ b/net/flip/flip_io_buffer.h @@ -0,0 +1,59 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_FLIP_FLIP_IO_BUFFER_H_ +#define NET_FLIP_FLIP_IO_BUFFER_H_ + +#include "base/ref_counted.h" +#include "net/base/io_buffer.h" + +namespace net { + +class FlipStream; + +// A class for managing FLIP IO buffers. These buffers need to be prioritized +// so that the FlipSession sends them in the right order. Further, they need +// to track the FlipStream which they are associated with so that incremental +// completion of the IO can notify the appropriate stream of completion. +class FlipIOBuffer { + public: + // Constructor + // |buffer| is the actual data buffer. + // |priority| is the priority of this buffer. Lower numbers are higher + // priority. + // |stream| is a pointer to the stream which is managing this buffer. + FlipIOBuffer(IOBufferWithSize* buffer, int priority, FlipStream* stream) + : buffer_(buffer), + priority_(priority), + position_(++order_), + stream_(stream) { + } + FlipIOBuffer() : priority_(0), stream_(NULL) {} + + // Accessors. + IOBuffer* buffer() const { return buffer_; } + size_t size() const { return buffer_->size(); } + void release() { buffer_ = NULL; } + int priority() const { return priority_; } + FlipStream* stream() const { return stream_; } + + // Comparison operator to support sorting. + bool operator<(const FlipIOBuffer& other) const { + if (priority_ != other.priority_) + return priority_ > other.priority_; + return position_ > other.position_; + } + + private: + scoped_refptr<IOBufferWithSize> buffer_; + int priority_; + uint64 position_; + FlipStream* stream_; + static uint64 order_; // Maintains a FIFO order for equal priorities. +}; + +} // namespace net + +#endif // NET_FLIP_FLIP_IO_BUFFER_H_ + diff --git a/net/net.gyp b/net/net.gyp index aa8a23f..d83f545 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -277,6 +277,8 @@ 'flip/flip_frame_builder.h', 'flip/flip_framer.cc', 'flip/flip_framer.h', + 'flip/flip_io_buffer.cc', + 'flip/flip_io_buffer.h', 'flip/flip_network_transaction.cc', 'flip/flip_network_transaction.h', 'flip/flip_protocol.h', |