Commit f7010226 authored by rajendrant's avatar rajendrant Committed by Commit Bot

LiteVideo: Fix throttling to stop permanently on rebuffer event

Currently throttling is temporaily stopped, i.e., new requests will get
throttled, on too much rebuffer events. This CL changes it to stop
permanently.

Bug: 1137505
Change-Id: Iae6453c3799229939415bac5205450b82c4a4ae7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466605Reviewed-by: default avatarMichael Crouse <mcrouse@chromium.org>
Commit-Queue: rajendrant <rajendrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816315}
parent 38e7115d
......@@ -98,10 +98,14 @@ void LiteVideoHintAgent::SetLiteVideoHint(
LOCAL_HISTOGRAM_BOOLEAN("LiteVideo.HintAgent.HasHint", true);
}
void LiteVideoHintAgent::StopThrottling() {
void LiteVideoHintAgent::StopThrottlingAndClearHints() {
for (auto* throttle : active_throttles_)
throttle->ResumeIfThrottled();
kilobytes_buffered_before_throttle_ = 0;
target_downlink_bandwidth_kbps_.reset();
kilobytes_to_buffer_before_throttle_.reset();
target_downlink_rtt_latency_.reset();
max_throttling_delay_.reset();
}
} // namespace lite_video
......@@ -54,9 +54,10 @@ class LiteVideoHintAgent
return active_throttles_;
}
// Stop throttling and resume the current throttled media requests
// immediately. Throttling could start again for new requests
void StopThrottling();
// Stop throttling permanently. Resumes the current throttled media requests
// immediately, and clears the hints so that throttling does not happen for
// new requests.
void StopThrottlingAndClearHints();
private:
friend class LiteVideoHintAgentTest;
......
......@@ -122,7 +122,9 @@ class LiteVideoHintAgentTest : public ChromeRenderViewTest {
const base::HistogramTester& histogram_tester() { return histogram_tester_; }
void StopThrottling() { lite_video_hint_agent_->StopThrottling(); }
void StopThrottlingAndClearHints() {
lite_video_hint_agent_->StopThrottlingAndClearHints();
}
protected:
void SetUp() override {
......@@ -278,7 +280,9 @@ TEST_F(LiteVideoHintAgentTest, MediaResponseThrottled) {
EXPECT_TRUE(GetActiveThrottledResponses().empty());
}
TEST_F(LiteVideoHintAgentTest, StopThrottlingResumesResponsesImmediately) {
// Permanent stop throttling should resume the responses immediately and any not
// allow throttling for new requests.
TEST_F(LiteVideoHintAgentTest, StopThrottlingPermanently) {
histogram_tester().ExpectUniqueSample("LiteVideo.HintAgent.HasHint", true, 1);
// Initial response is not throttled, and the next two are throttled.
......@@ -295,10 +299,16 @@ TEST_F(LiteVideoHintAgentTest, StopThrottlingResumesResponsesImmediately) {
EXPECT_EQ(2U, GetActiveThrottledResponses().size());
// Stop throttling will immediately resume.
StopThrottling();
StopThrottlingAndClearHints();
EXPECT_FALSE(throttle_info2->is_throttled());
EXPECT_FALSE(throttle_info3->is_throttled());
// The new responses should not be throttled.
EXPECT_FALSE(CreateLiteVideoURLLoaderThrottle(
blink::mojom::RequestContextType::FETCH));
EXPECT_FALSE(CreateLiteVideoURLLoaderThrottle(
blink::mojom::RequestContextType::FETCH));
// When the throttle destroys it should get removed from active throttles.
throttle_info2.reset();
throttle_info3.reset();
......
......@@ -180,7 +180,7 @@ void ResourceLoadingHintsAgent::StopThrottlingMediaRequests() {
lite_video::LiteVideoHintAgent::Get(render_frame());
if (lite_video_hint_agent) {
LOCAL_HISTOGRAM_BOOLEAN("LiteVideo.HintsAgent.StopThrottling", true);
lite_video_hint_agent->StopThrottling();
lite_video_hint_agent->StopThrottlingAndClearHints();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment