Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #include "net/spdy/http2_priority_dependencies.h" | |
| 6 | |
| 7 namespace net { | |
| 8 | |
| 9 Http2PriorityDependencies::Http2PriorityDependencies() {} | |
| 10 | |
| 11 Http2PriorityDependencies::~Http2PriorityDependencies() {} | |
| 12 | |
| 13 void Http2PriorityDependencies::OnStreamSynSent( | |
| 14 SpdyStreamId id, | |
| 15 SpdyPriority priority, | |
| 16 SpdyStreamId* dependent_stream_id, | |
| 17 bool* exclusive) { | |
| 18 DCHECK(entry_by_stream_id_.find(id) == entry_by_stream_id_.end()); | |
| 19 | |
| 20 *dependent_stream_id = 0ul; | |
| 21 *exclusive = true; | |
| 22 | |
| 23 // Find the next highest entry in total order. | |
| 24 for (int i = priority; i >= kV3HighestPriority; --i) { | |
| 25 if (!id_priority_lists_[i].empty()) { | |
| 26 *dependent_stream_id = id_priority_lists_[i].back().first; | |
| 27 break; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 id_priority_lists_[priority].push_back(std::make_pair(id, priority)); | |
| 32 IdList::iterator it = id_priority_lists_[priority].end(); | |
| 33 entry_by_stream_id_[id] = --it; | |
|
Bence
2016/03/17 01:48:59
Optional: would you consider
--it;
entry_b
Randy Smith (Not in Mondays)
2016/03/17 20:27:42
I think of this as your code, so ok, but I tend to
| |
| 34 } | |
| 35 | |
| 36 void Http2PriorityDependencies::OnStreamDestruction(SpdyStreamId id) { | |
| 37 EntryMap::iterator emit = entry_by_stream_id_.find(id); | |
| 38 | |
| 39 // This routine may be called without a matching call to | |
| 40 // OnStreamSynSent above, in the case of server push. In that case, | |
| 41 // it's a no-op. | |
| 42 if (emit == entry_by_stream_id_.end()) | |
| 43 return; | |
| 44 | |
| 45 IdList::iterator it = emit->second; | |
| 46 id_priority_lists_[it->second].erase(it); | |
| 47 entry_by_stream_id_.erase(emit); | |
| 48 } | |
| 49 | |
| 50 } // namespace net | |
| OLD | NEW |