Remove NavigationRequestInfo::is_showing.
[chromium-blink-merge.git] / net / spdy / spdy_write_queue.h
blobbd67f6ba38ba3ba8ed149aa717307f32be3af14b
1 // Copyright (c) 2013 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.
5 #ifndef NET_SPDY_SPDY_WRITE_QUEUE_H_
6 #define NET_SPDY_SPDY_WRITE_QUEUE_H_
8 #include <deque>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "net/base/net_export.h"
14 #include "net/base/request_priority.h"
15 #include "net/spdy/spdy_protocol.h"
17 namespace net {
19 class SpdyBuffer;
20 class SpdyBufferProducer;
21 class SpdyStream;
23 // A queue of SpdyBufferProducers to produce frames to write. Ordered
24 // by priority, and then FIFO.
25 class NET_EXPORT_PRIVATE SpdyWriteQueue {
26 public:
27 SpdyWriteQueue();
28 ~SpdyWriteQueue();
30 // Returns whether there is anything in the write queue,
31 // i.e. whether the next call to Dequeue will return true.
32 bool IsEmpty() const;
34 // Enqueues the given frame producer of the given type at the given
35 // priority associated with the given stream, which may be NULL if
36 // the frame producer is not associated with a stream. If |stream|
37 // is non-NULL, its priority must be equal to |priority|, and it
38 // must remain non-NULL until the write is dequeued or removed.
39 void Enqueue(RequestPriority priority,
40 SpdyFrameType frame_type,
41 scoped_ptr<SpdyBufferProducer> frame_producer,
42 const base::WeakPtr<SpdyStream>& stream);
44 // Dequeues the frame producer with the highest priority that was
45 // enqueued the earliest and its associated stream. Returns true and
46 // fills in |frame_type|, |frame_producer|, and |stream| if
47 // successful -- otherwise, just returns false.
48 bool Dequeue(SpdyFrameType* frame_type,
49 scoped_ptr<SpdyBufferProducer>* frame_producer,
50 base::WeakPtr<SpdyStream>* stream);
52 // Removes all pending writes for the given stream, which must be
53 // non-NULL.
54 void RemovePendingWritesForStream(const base::WeakPtr<SpdyStream>& stream);
56 // Removes all pending writes for streams after |last_good_stream_id|
57 // and streams with no stream id.
58 void RemovePendingWritesForStreamsAfter(SpdyStreamId last_good_stream_id);
60 // Removes all pending writes.
61 void Clear();
63 private:
64 // A struct holding a frame producer and its associated stream.
65 struct PendingWrite {
66 SpdyFrameType frame_type;
67 // This has to be a raw pointer since we store this in an STL
68 // container.
69 SpdyBufferProducer* frame_producer;
70 base::WeakPtr<SpdyStream> stream;
71 // Whether |stream| was non-NULL when enqueued.
72 bool has_stream;
74 PendingWrite();
75 PendingWrite(SpdyFrameType frame_type,
76 SpdyBufferProducer* frame_producer,
77 const base::WeakPtr<SpdyStream>& stream);
78 ~PendingWrite();
81 bool removing_writes_;
83 // The actual write queue, binned by priority.
84 std::deque<PendingWrite> queue_[NUM_PRIORITIES];
86 DISALLOW_COPY_AND_ASSIGN(SpdyWriteQueue);
89 } // namespace net
91 #endif // NET_SPDY_SPDY_WRITE_QUEUE_H_