Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / net / proxy / load_state_change_coalescer.cc
blobae15e53d8fce812ba0dd4763ae4821d7c63c2fd3
1 // Copyright 2015 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.
5 #include "net/proxy/load_state_change_coalescer.h"
7 namespace net {
9 LoadStateChangeCoalescer::LoadStateChangeCoalescer(
10 const base::Callback<void(LoadState)>& callback,
11 const base::TimeDelta& timeout,
12 LoadState initial_load_state)
13 : callback_(callback),
14 timeout_(timeout),
15 committed_load_state_(initial_load_state),
16 pending_load_state_(initial_load_state) {
19 void LoadStateChangeCoalescer::LoadStateChanged(LoadState load_state) {
20 if (load_state == committed_load_state_) {
21 timer_.Stop();
22 return;
24 pending_load_state_ = load_state;
25 timer_.Start(FROM_HERE, timeout_, this,
26 &LoadStateChangeCoalescer::SendLoadStateChanged);
29 LoadStateChangeCoalescer::~LoadStateChangeCoalescer() = default;
31 void LoadStateChangeCoalescer::SendLoadStateChanged() {
32 committed_load_state_ = pending_load_state_;
33 callback_.Run(pending_load_state_);
36 } // namespace net