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

Side by Side Diff: net/spdy/http2_priority_dependencies.h

Issue 1779733003: Fix bug in net::RequestPriority -> HTTP/2 dependency conversion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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
OLDNEW
(Empty)
1 // Copyright 2016 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_HTTP2_PRIORITY_DEPENDENCIES_H_
6 #define NET_HTTP2_PRIORITY_DEPENDENCIES_H_
7
8 #include <list>
9 #include <map>
10
11 #include "net/base/request_priority.h"
12 #include "net/spdy/spdy_protocol.h"
13
14 namespace net {
15
16 // A helper class encapsulating the state and logic to set dependencies of
17 // HTTP2 streams based on their net::RequestPriority and the ordering
18 // of creation and deletion of the streams.
19 class Http2PriorityDependencies {
20 public:
21 Http2PriorityDependencies();
22 ~Http2PriorityDependencies();
23
24 // Called to override default behavior for testing. If |enabled|,
25 // |OnStreamSynSent()| will output correct header values; if
26 // |!enabled|, |*dependent_stream_id| will be set to 0 and
27 // |*exclusive| to false.
28 // Returns old default value (for resetting at end of test).
29 static bool SetEnabledDefaultForTesting(bool enabled);
30
31 // Called when a stream SYN is sent to the server. Note that in the
32 // case of server push, a stream may be created without this routine
33 // being called. In such cases, the client ignores the stream's priority
34 // (as the server is effectively overriding the client's notions of
35 // priority anyway.
Bence 2016/03/10 20:21:14 Nit: close opening parenthesis.
Randy Smith (Not in Mondays) 2016/03/16 19:38:10 Done.
36 // On return, |*dependent_stream_id| is set to the stream id that
37 // this stream should be made dependent on, and |*exclusive| set to
38 // whether that dependency should be exclusive.
39 void OnStreamSynSent(SpdyStreamId id,
40 RequestPriority priority,
41 SpdyStreamId* dependent_stream_id,
42 bool* exclusive);
43
44 void OnStreamDestruction(SpdyStreamId id);
45
46 private:
47 bool enabled_;
48
49 // The requirements for the internal data structure for this class are:
50 // a) Constant time insertion of entries at the end of the list,
51 // b) Fast removal of any entry based on its id.
52 // c) Constant time lookup of the entry at the end of the list.
53 // std::list would satisfy (a) & (c), but some form of map is
54 // needed for (b). The priority must be included in the map
55 // entries so that deletion can determine which list in id_priority_lists_
56 // to erase from.
Bence 2016/03/10 20:21:14 Makes sense. Too bad you have multiple lists and
Randy Smith (Not in Mondays) 2016/03/16 19:38:10 Acknowledged.
57 using IdList = std::list<std::pair<SpdyStreamId, net::RequestPriority>>;
58 using EntryMap = std::map<SpdyStreamId, IdList::iterator>;
59
60 IdList id_priority_lists_[NUM_PRIORITIES];
61
62 // Tracks the location of an id anywhere in the above vector of lists.
63 // Iterators to list elements remain valid until those particular elements
64 // are erased.
65 EntryMap entry_by_stream_id_;
66 };
67
68 } // namespace net
69
70 #endif // NET_HTTP2_PRIORITY_DEPENDENCIES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698