Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / net / spdy / spdy_write_queue.h
blob1d5556b084c8f72b12e533d2eacfc56c4de5d186
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/ref_counted.h"
12 #include "base/memory/scoped_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 // Enqueues the given frame producer of the given type at the given
31 // priority associated with the given stream, which may be NULL if
32 // the frame producer is not associated with a stream. If |stream|
33 // is non-NULL, its priority must be equal to |priority|.
34 void Enqueue(RequestPriority priority,
35 SpdyFrameType frame_type,
36 scoped_ptr<SpdyBufferProducer> frame_producer,
37 const scoped_refptr<SpdyStream>& stream);
39 // Dequeues the frame producer with the highest priority that was
40 // enqueued the earliest and its associated stream. Returns true and
41 // fills in |frame_type|, |frame_producer|, and |stream| if
42 // successful -- otherwise, just returns false.
43 bool Dequeue(SpdyFrameType* frame_type,
44 scoped_ptr<SpdyBufferProducer>* frame_producer,
45 scoped_refptr<SpdyStream>* stream);
47 // Removes all pending writes for the given stream, which must be
48 // non-NULL.
49 void RemovePendingWritesForStream(const scoped_refptr<SpdyStream>& stream);
51 // Removes all pending writes for streams after |last_good_stream_id|
52 // and streams with no stream id.
53 void RemovePendingWritesForStreamsAfter(SpdyStreamId last_good_stream_id);
55 // Removes all pending writes.
56 void Clear();
58 private:
59 // A struct holding a frame producer and its associated stream.
60 struct PendingWrite {
61 SpdyFrameType frame_type;
62 // This has to be a raw pointer since we store this in an STL
63 // container.
64 SpdyBufferProducer* frame_producer;
65 scoped_refptr<SpdyStream> stream;
67 PendingWrite();
68 PendingWrite(SpdyFrameType frame_type,
69 SpdyBufferProducer* frame_producer,
70 const scoped_refptr<SpdyStream>& stream);
71 ~PendingWrite();
74 // The actual write queue, binned by priority.
75 std::deque<PendingWrite> queue_[NUM_PRIORITIES];
77 DISALLOW_COPY_AND_ASSIGN(SpdyWriteQueue);
80 } // namespace net
82 #endif // NET_SPDY_SPDY_WRITE_QUEUE_H_