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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/nqe/observation_buffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/weighted_observation.h
diff --git a/net/nqe/weighted_observation.h b/net/nqe/weighted_observation.h
new file mode 100644
index 0000000000000000000000000000000000000000..287442a02290eed77c09e22b78778123c65a31c1
--- /dev/null
+++ b/net/nqe/weighted_observation.h
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_NQE_WEIGHTED_OBSERVATION_H_
+#define NET_NQE_WEIGHTED_OBSERVATION_H_
+
+#include <vector>
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "net/base/net_export.h"
+#include "net/nqe/network_quality_observation_source.h"
+
+namespace net {
+
+namespace nqe {
+
+namespace internal {
+
+// Holds an observation and its weight.
+template <typename ValueType>
+struct NET_EXPORT_PRIVATE WeightedObservation {
+ WeightedObservation(ValueType value, double weight)
+ : value(value), weight(weight) {}
+ WeightedObservation(const WeightedObservation& other)
+ : WeightedObservation(other.value, other.weight) {}
+
+ WeightedObservation& operator=(const WeightedObservation& other) {
+ value = other.value;
+ weight = other.weight;
+ return *this;
+ }
+
+ // Required for sorting the samples in the ascending order of values.
+ bool operator<(const WeightedObservation& other) const {
+ return (value < other.value);
+ }
+
+ // Value of the sample.
+ ValueType value;
+
+ // Weight of the sample. This is computed based on how much time has passed
+ // since the sample was taken.
+ double weight;
+};
+
+} // namespace internal
+
+} // namespace nqe
+
+} // namespace net
+
+#endif // NET_NQE_WEIGHTED_OBSERVATION_H_
« 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