interceptor should handle default values of download and upload throughput

This commit is contained in:
deepak1556 2017-01-06 23:28:49 +05:30
parent d76f446140
commit 237cb7d0a3

View file

@ -195,15 +195,20 @@ base::TimeTicks DevToolsNetworkInterceptor::CalculateDesiredTime(
void DevToolsNetworkInterceptor::ArmTimer(base::TimeTicks now) { void DevToolsNetworkInterceptor::ArmTimer(base::TimeTicks now) {
size_t suspend_count = suspended_.size(); size_t suspend_count = suspended_.size();
if (!download_.size() && !upload_.size() && !suspend_count) if (!download_.size() && !upload_.size() && !suspend_count) {
timer_.Stop();
return; return;
}
base::TimeTicks desired_time = CalculateDesiredTime( base::TimeTicks desired_time = CalculateDesiredTime(
download_, download_last_tick_, download_tick_length_); download_, download_last_tick_, download_tick_length_);
if (desired_time == offset_) {
FinishRecords(&download_, false);
}
base::TimeTicks upload_time = CalculateDesiredTime( base::TimeTicks upload_time = CalculateDesiredTime(
upload_, upload_last_tick_, upload_tick_length_); upload_, upload_last_tick_, upload_tick_length_);
if (upload_time < desired_time) if (upload_time != offset_ && upload_time < desired_time)
desired_time = upload_time; desired_time = upload_time;
int64_t min_baseline = std::numeric_limits<int64_t>::max(); int64_t min_baseline = std::numeric_limits<int64_t>::max();
@ -218,9 +223,9 @@ void DevToolsNetworkInterceptor::ArmTimer(base::TimeTicks now) {
desired_time = activation_time; desired_time = activation_time;
} }
timer_.Start(FROM_HERE, desired_time - now, timer_.Start(
base::Bind(&DevToolsNetworkInterceptor::OnTimer, FROM_HERE, (desired_time - now).magnitude(),
base::Unretained(this))); base::Bind(&DevToolsNetworkInterceptor::OnTimer, base::Unretained(this)));
} }
int DevToolsNetworkInterceptor::StartThrottle( int DevToolsNetworkInterceptor::StartThrottle(