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

Side by Side Diff: net/nqe/weighted_observation.h

Issue 1942893002: Split NQE to multiple files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 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
« no previous file with comments | « net/nqe/observation_buffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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_NQE_WEIGHTED_OBSERVATION_H_
6 #define NET_NQE_WEIGHTED_OBSERVATION_H_
7
8 #include <vector>
9
10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h"
12 #include "base/time/time.h"
13 #include "net/base/net_export.h"
14 #include "net/nqe/network_quality_observation_source.h"
15
16 namespace net {
17
18 namespace nqe {
19
20 namespace internal {
21
22 // Holds an observation and its weight.
23 template <typename ValueType>
24 struct NET_EXPORT_PRIVATE WeightedObservation {
25 WeightedObservation(ValueType value, double weight)
26 : value(value), weight(weight) {}
27 WeightedObservation(const WeightedObservation& other)
28 : WeightedObservation(other.value, other.weight) {}
29
30 WeightedObservation& operator=(const WeightedObservation& other) {
31 value = other.value;
32 weight = other.weight;
33 return *this;
34 }
35
36 // Required for sorting the samples in the ascending order of values.
37 bool operator<(const WeightedObservation& other) const {
38 return (value < other.value);
39 }
40
41 // Value of the sample.
42 ValueType value;
43
44 // Weight of the sample. This is computed based on how much time has passed
45 // since the sample was taken.
46 double weight;
47 };
48
49 } // namespace internal
50
51 } // namespace nqe
52
53 } // namespace net
54
55 #endif // NET_NQE_WEIGHTED_OBSERVATION_H_
OLDNEW
« no previous file with comments | « net/nqe/observation_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698