Commit ad2f5b9f authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Revert "Soften the history.{push,replace}State throttling mechanism."

This reverts commit 1f637a1a.

Reason for revert: Part 2 of trying to revert history throttling changes to see if https://bugs.chromium.org/p/chromium/issues/detail?id=870861 improves.

Original change's description:
> Soften the history.{push,replace}State throttling mechanism.
> 
> johnme@ suggests a better way to handle it; let's do that.
> 
> Bug: 786211
> Change-Id: I446c70117451d2ef49ce13f5884ebb858d9ee392
> Reviewed-on: https://chromium-review.googlesource.com/1161400
> Commit-Queue: Chris Palmer <palmer@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#580455}

TBR=palmer@chromium.org,dcheng@chromium.org,kinuko@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 786211
Change-Id: Ia6a35add136361834c3afb40295b950c05cb9169
Reviewed-on: https://chromium-review.googlesource.com/1171709Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582434}
parent 31322898
...@@ -148,28 +148,22 @@ bool History::ShouldThrottleStateObjectChanges() { ...@@ -148,28 +148,22 @@ bool History::ShouldThrottleStateObjectChanges() {
if (!GetFrame()->GetSettings()->GetShouldThrottlePushState()) if (!GetFrame()->GetSettings()->GetShouldThrottlePushState())
return false; return false;
if (state_flood_guard.tokens > 0) { const int kStateUpdateLimit = 50;
state_flood_guard.tokens--;
return false; if (state_flood_guard.count > kStateUpdateLimit) {
} static constexpr auto kStateUpdateLimitResetInterval =
TimeDelta::FromSeconds(10);
const auto now = TimeTicks::Now(); const auto now = CurrentTimeTicks();
const TimeDelta elapsed = now - state_flood_guard.last_token_grant; if (now - state_flood_guard.last_updated > kStateUpdateLimitResetInterval) {
static constexpr base::TimeDelta kTimePerToken = state_flood_guard.count = 0;
base::TimeDelta::FromMilliseconds(16); state_flood_guard.last_updated = now;
static constexpr int kMaxTokens = 50; return false;
// It is OK to truncate from int64_t to int here. }
const int tokens_earned = std::min<int>(elapsed / kTimePerToken, kMaxTokens); return true;
if (tokens_earned > 0) {
state_flood_guard.tokens = tokens_earned - 1; // One consumed immediately.
state_flood_guard.last_token_grant = now;
return false;
} }
// Drop this event (though ideally it would be delivered once there are tokens state_flood_guard.count++;
// again, unless obsoleted by a subsequent state object change). return false;
return true;
} }
bool History::stateChanged() const { bool History::stateChanged() const {
......
...@@ -107,8 +107,8 @@ class CORE_EXPORT History final : public ScriptWrappable, ...@@ -107,8 +107,8 @@ class CORE_EXPORT History final : public ScriptWrappable,
scoped_refptr<SerializedScriptValue> last_state_object_requested_; scoped_refptr<SerializedScriptValue> last_state_object_requested_;
struct { struct {
int tokens = 0; int count;
TimeTicks last_token_grant; TimeTicks last_updated;
} state_flood_guard; } state_flood_guard;
}; };
......
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