| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "net/tools/flip_server/output_ordering.h" | 5 #include "net/tools/flip_server/output_ordering.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "net/tools/flip_server/flip_config.h" | 9 #include "net/tools/flip_server/flip_config.h" |
| 10 #include "net/tools/flip_server/sm_connection.h" | 10 #include "net/tools/flip_server/sm_connection.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 OutputOrdering::PriorityMapPointer::PriorityMapPointer() | 14 OutputOrdering::PriorityMapPointer::PriorityMapPointer() |
| 15 : ring(NULL), alarm_enabled(false) {} | 15 : ring(NULL), alarm_enabled(false) { |
| 16 } |
| 16 | 17 |
| 17 OutputOrdering::PriorityMapPointer::~PriorityMapPointer() {} | 18 OutputOrdering::PriorityMapPointer::~PriorityMapPointer() { |
| 19 } |
| 18 | 20 |
| 19 // static | 21 // static |
| 20 double OutputOrdering::server_think_time_in_s_ = 0.0; | 22 double OutputOrdering::server_think_time_in_s_ = 0.0; |
| 21 | 23 |
| 22 OutputOrdering::OutputOrdering(SMConnectionInterface* connection) | 24 OutputOrdering::OutputOrdering(SMConnectionInterface* connection) |
| 23 : first_data_senders_threshold_(kInitialDataSendersThreshold), | 25 : first_data_senders_threshold_(kInitialDataSendersThreshold), |
| 24 connection_(connection) { | 26 connection_(connection) { |
| 25 if (connection) | 27 if (connection) |
| 26 epoll_server_ = connection->epoll_server(); | 28 epoll_server_ = connection->epoll_server(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 OutputOrdering::~OutputOrdering() { Reset(); } | 31 OutputOrdering::~OutputOrdering() { |
| 32 Reset(); |
| 33 } |
| 30 | 34 |
| 31 void OutputOrdering::Reset() { | 35 void OutputOrdering::Reset() { |
| 32 while (!stream_ids_.empty()) { | 36 while (!stream_ids_.empty()) { |
| 33 StreamIdToPriorityMap::iterator sitpmi = stream_ids_.begin(); | 37 StreamIdToPriorityMap::iterator sitpmi = stream_ids_.begin(); |
| 34 PriorityMapPointer& pmp = sitpmi->second; | 38 PriorityMapPointer& pmp = sitpmi->second; |
| 35 if (pmp.alarm_enabled) { | 39 if (pmp.alarm_enabled) { |
| 36 epoll_server_->UnregisterAlarm(pmp.alarm_token); | 40 epoll_server_->UnregisterAlarm(pmp.alarm_token); |
| 37 } | 41 } |
| 38 stream_ids_.erase(sitpmi); | 42 stream_ids_.erase(sitpmi); |
| 39 } | 43 } |
| 40 priority_map_.clear(); | 44 priority_map_.clear(); |
| 41 first_data_senders_.clear(); | 45 first_data_senders_.clear(); |
| 42 } | 46 } |
| 43 | 47 |
| 44 bool OutputOrdering::ExistsInPriorityMaps(uint32 stream_id) const { | 48 bool OutputOrdering::ExistsInPriorityMaps(uint32 stream_id) const { |
| 45 StreamIdToPriorityMap::const_iterator sitpmi = stream_ids_.find(stream_id); | 49 StreamIdToPriorityMap::const_iterator sitpmi = stream_ids_.find(stream_id); |
| 46 return sitpmi != stream_ids_.end(); | 50 return sitpmi != stream_ids_.end(); |
| 47 } | 51 } |
| 48 | 52 |
| 49 OutputOrdering::BeginOutputtingAlarm::BeginOutputtingAlarm( | 53 OutputOrdering::BeginOutputtingAlarm::BeginOutputtingAlarm( |
| 50 OutputOrdering* oo, | 54 OutputOrdering* oo, |
| 51 OutputOrdering::PriorityMapPointer* pmp, | 55 OutputOrdering::PriorityMapPointer* pmp, |
| 52 const MemCacheIter& mci) | 56 const MemCacheIter& mci) |
| 53 : output_ordering_(oo), pmp_(pmp), mci_(mci), epoll_server_(NULL) {} | 57 : output_ordering_(oo), pmp_(pmp), mci_(mci), epoll_server_(NULL) { |
| 58 } |
| 54 | 59 |
| 55 OutputOrdering::BeginOutputtingAlarm::~BeginOutputtingAlarm() { | 60 OutputOrdering::BeginOutputtingAlarm::~BeginOutputtingAlarm() { |
| 56 if (epoll_server_ && pmp_->alarm_enabled) | 61 if (epoll_server_ && pmp_->alarm_enabled) |
| 57 epoll_server_->UnregisterAlarm(pmp_->alarm_token); | 62 epoll_server_->UnregisterAlarm(pmp_->alarm_token); |
| 58 } | 63 } |
| 59 | 64 |
| 60 int64 OutputOrdering::BeginOutputtingAlarm::OnAlarm() { | 65 int64 OutputOrdering::BeginOutputtingAlarm::OnAlarm() { |
| 61 OnUnregistration(); | 66 OnUnregistration(); |
| 62 output_ordering_->MoveToActive(pmp_, mci_); | 67 output_ordering_->MoveToActive(pmp_, mci_); |
| 63 VLOG(2) << "ON ALARM! Should now start to output..."; | 68 VLOG(2) << "ON ALARM! Should now start to output..."; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 171 |
| 167 PriorityMapPointer& pmp = sitpmi->second; | 172 PriorityMapPointer& pmp = sitpmi->second; |
| 168 if (pmp.alarm_enabled) | 173 if (pmp.alarm_enabled) |
| 169 epoll_server_->UnregisterAlarm(pmp.alarm_token); | 174 epoll_server_->UnregisterAlarm(pmp.alarm_token); |
| 170 else | 175 else |
| 171 pmp.ring->erase(pmp.it); | 176 pmp.ring->erase(pmp.it); |
| 172 stream_ids_.erase(sitpmi); | 177 stream_ids_.erase(sitpmi); |
| 173 } | 178 } |
| 174 | 179 |
| 175 } // namespace net | 180 } // namespace net |
| OLD | NEW |