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

Side by Side Diff: net/base/load_state_change_coalescer.h

Issue 939503004: Add LoadState reporting to the mojo proxy resolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy-resolver-mojo
Patch Set: Created 5 years, 9 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 #ifndef NET_BASE_LOAD_STATE_CHANGE_COALESCER_H_
eroman 2015/03/06 05:13:01 please move this into the net/proxy directory. Thi
Sam McNally 2015/03/06 09:33:02 Done.
6 #define NET_BASE_LOAD_STATE_CHANGE_COALESCER_H_
7
8 #include "base/cancelable_callback.h"
9 #include "base/time/time.h"
10 #include "net/base/load_states.h"
11 #include "net/base/net_export.h"
12
13 namespace net {
14
15 // A class that coalesces LoadState changes. When a new LoadState is reported,
16 // it becomes the pending LoadState and is queued for |timeout|. If the timeout
17 // elapses without another new LoadState, the pending LoadState becomes the
18 // committed LoadState and the callback is called with that LoadState. If a new
19 // LoadState is reported before the timeout has elapsed, the pending LoadState
eroman 2015/03/06 05:13:01 "LoadState is discarded"
Sam McNally 2015/03/06 09:33:02 Done.
20 // discarded and the new LoadState becomes the new pending LoadState, unless
21 // it's the same as the committed LoadState, in which case no pending LoadState
22 // is queued.
23 class NET_EXPORT_PRIVATE LoadStateChangeCoalescer {
24 public:
25 LoadStateChangeCoalescer(const base::Callback<void(LoadState)>& callback,
26 const base::TimeDelta& timeout,
27 LoadState initial_load_state);
28 ~LoadStateChangeCoalescer();
29
30 // Adds a LoadState change to the pipeline. If it isn't coalesced, |callback_|
31 // will be called with |load_state| after |timeout_|.
32 void LoadStateChanged(LoadState load_state);
33
34 private:
35 void SendLoadStateChanged();
36
37 // The callback to call to report a LoadState change.
38 const base::Callback<void(LoadState)> callback_;
39
40 // The amount of time for which a LoadState change can be coalesced.
41 const base::TimeDelta timeout_;
42
43 base::CancelableClosure pending_load_state_change_;
44 LoadState committed_load_state_;
45 LoadState pending_load_state_;
46
47 DISALLOW_COPY_AND_ASSIGN(LoadStateChangeCoalescer);
48 };
49
50 } // namespace net
51
52 #endif // NET_BASE_LOAD_STATE_CHANGE_COALESCER_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/load_state_change_coalescer.cc » ('j') | net/base/load_state_change_coalescer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698