| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SPDY_HTTP2_PRIORITY_DEPENDENCIES_H_ | 5 #ifndef NET_SPDY_HTTP2_PRIORITY_DEPENDENCIES_H_ |
| 6 #define NET_SPDY_HTTP2_PRIORITY_DEPENDENCIES_H_ | 6 #define NET_SPDY_HTTP2_PRIORITY_DEPENDENCIES_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 bool exclusive; | 40 bool exclusive; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Called when a stream's priority has changed. Returns a list of | 43 // Called when a stream's priority has changed. Returns a list of |
| 44 // dependency updates that should be sent to the server to describe | 44 // dependency updates that should be sent to the server to describe |
| 45 // the requested priority change. The updates should be sent in the | 45 // the requested priority change. The updates should be sent in the |
| 46 // given order. | 46 // given order. |
| 47 std::vector<DependencyUpdate> OnStreamUpdate(SpdyStreamId id, | 47 std::vector<DependencyUpdate> OnStreamUpdate(SpdyStreamId id, |
| 48 SpdyPriority new_priority); | 48 SpdyPriority new_priority); |
| 49 | 49 |
| 50 // Returns the estimate of dynamically allocated memory in bytes. |
| 51 size_t EstimateMemoryUsage() const; |
| 52 |
| 50 private: | 53 private: |
| 51 // The requirements for the internal data structure for this class are: | 54 // The requirements for the internal data structure for this class are: |
| 52 // a) Constant time insertion of entries at the end of the list, | 55 // a) Constant time insertion of entries at the end of the list, |
| 53 // b) Fast removal of any entry based on its id. | 56 // b) Fast removal of any entry based on its id. |
| 54 // c) Constant time lookup of the entry at the end of the list. | 57 // c) Constant time lookup of the entry at the end of the list. |
| 55 // std::list would satisfy (a) & (c), but some form of map is | 58 // std::list would satisfy (a) & (c), but some form of map is |
| 56 // needed for (b). The priority must be included in the map | 59 // needed for (b). The priority must be included in the map |
| 57 // entries so that deletion can determine which list in id_priority_lists_ | 60 // entries so that deletion can determine which list in id_priority_lists_ |
| 58 // to erase from. | 61 // to erase from. |
| 59 using IdList = std::list<std::pair<SpdyStreamId, SpdyPriority>>; | 62 using IdList = std::list<std::pair<SpdyStreamId, SpdyPriority>>; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 78 | 81 |
| 79 // Finds the stream just below |id| in the total order. | 82 // Finds the stream just below |id| in the total order. |
| 80 // Returns false if there are no streams with a lower priority. | 83 // Returns false if there are no streams with a lower priority. |
| 81 // Otherwise, returns true and sets |*child|. | 84 // Otherwise, returns true and sets |*child|. |
| 82 bool ChildOfStream(SpdyStreamId id, IdList::iterator* child); | 85 bool ChildOfStream(SpdyStreamId id, IdList::iterator* child); |
| 83 }; | 86 }; |
| 84 | 87 |
| 85 } // namespace net | 88 } // namespace net |
| 86 | 89 |
| 87 #endif // NET_SPDY_HTTP2_PRIORITY_DEPENDENCIES_H_ | 90 #endif // NET_SPDY_HTTP2_PRIORITY_DEPENDENCIES_H_ |
| OLD | NEW |