Chromium Code Reviews| Index: net/nqe/network_quality_store.h |
| diff --git a/net/nqe/network_quality_store.h b/net/nqe/network_quality_store.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6b789d12cb8f3f558818b4c47a9860d99775de0 |
| --- /dev/null |
| +++ b/net/nqe/network_quality_store.h |
| @@ -0,0 +1,67 @@ |
| +// 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_NETWORK_QUALITY_STORE_H_ |
| +#define NET_NQE_NETWORK_QUALITY_STORE_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/macros.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "net/base/net_export.h" |
| +#include "net/nqe/cached_network_quality.h" |
| +#include "net/nqe/network_id.h" |
| + |
| +namespace net { |
| + |
| +namespace nqe { |
| + |
| +namespace internal { |
| + |
| +// NetworkQualityStore holds the network qualities of different networks in |
| +// memory. Entries are stored in LRU order, and older entries may be evicted. |
| +class NET_EXPORT_PRIVATE NetworkQualityStore { |
| + public: |
| + NetworkQualityStore(); |
| + ~NetworkQualityStore(); |
| + |
| + // Stores the network quality |cached_network_quality| of network with id |
|
bengr
2016/07/21 21:48:15
id -> ID
tbansal1
2016/07/21 22:50:55
Done.
|
| + // |network_id|. |
| + void Add(const nqe::internal::NetworkID& network_id, |
| + const nqe::internal::CachedNetworkQuality& cached_network_quality); |
| + |
| + // Returns true if the network quality estimate was successfully read |
| + // for network with id |network_id|, and sets |cached_network_quality| to the |
|
bengr
2016/07/21 21:48:15
for -> for a
tbansal1
2016/07/21 22:50:54
Done.
|
| + // estimate read. |
| + bool GetById(const nqe::internal::NetworkID& network_id, |
| + nqe::internal::CachedNetworkQuality* cached_network_quality); |
| + |
| + private: |
| + // Maximum size of the store that holds network quality estimates. |
| + // Smaller size may reduce the cache hit rate due to frequent evictions. |
|
bengr
2016/07/21 21:48:15
Smaller -> A smaller
Larger -> A larger
tbansal1
2016/07/21 22:50:54
Done.
|
| + // Larger size may affect performance. |
| + static const size_t kMaximumNetworkQualityCacheSize = 10; |
| + |
| + // This does not use a unordered_map or hash_map for code simplicity (key just |
|
bengr
2016/07/21 21:48:15
a -> an
key -> the key
tbansal1
2016/07/21 22:50:54
Done.
|
| + // implements operator<, rather than hash and equality) and because the map is |
| + // tiny. |
| + typedef std::map<nqe::internal::NetworkID, |
| + nqe::internal::CachedNetworkQuality> |
| + CachedNetworkQualities; |
| + |
| + // Data structure that stores the quality of networks. |
|
bengr
2016/07/21 21:48:15
quality -> qualities
tbansal1
2016/07/21 22:50:54
Done.
|
| + CachedNetworkQualities cached_network_qualities_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NetworkQualityStore); |
| +}; |
| + |
| +} // namespace internal |
| + |
| +} // namespace nqe |
| + |
| +} // namespace net |
| + |
| +#endif // NET_NQE_NETWORK_QUALITY_STORE_H_ |