Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: net/proxy/load_state_change_coalescer.cc

Issue 1145153004: Split ProxyResolverV8Tracing into an implementation and a wrapper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "net/proxy/load_state_change_coalescer.h"
6
7 namespace net {
8
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) {
17 }
18
19 void LoadStateChangeCoalescer::LoadStateChanged(LoadState load_state) {
20 if (load_state == committed_load_state_) {
21 timer_.Stop();
22 return;
23 }
24 pending_load_state_ = load_state;
25 timer_.Start(FROM_HERE, timeout_, this,
26 &LoadStateChangeCoalescer::SendLoadStateChanged);
27 }
28
29 LoadStateChangeCoalescer::~LoadStateChangeCoalescer() = default;
30
31 void LoadStateChangeCoalescer::SendLoadStateChanged() {
32 committed_load_state_ = pending_load_state_;
33 callback_.Run(pending_load_state_);
34 }
35
36 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/load_state_change_coalescer.h ('k') | net/proxy/load_state_change_coalescer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698