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

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

Issue 2128793003: Factor out NetworkID and caching mechanism from n_q_e.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments, renamed the class from *Manager to *Store Created 4 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
« no previous file with comments | « net/nqe/network_quality_observation_source.h ('k') | net/nqe/network_quality_store.cc » ('j') | 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_NETWORK_QUALITY_STORE_H_
6 #define NET_NQE_NETWORK_QUALITY_STORE_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "base/threading/thread_checker.h"
12 #include "net/base/net_export.h"
13 #include "net/nqe/cached_network_quality.h"
14 #include "net/nqe/network_id.h"
15
16 namespace net {
17
18 namespace nqe {
19
20 namespace internal {
21
22 // NetworkQualityStore holds the network qualities of different networks in
23 // memory. Entries are stored in LRU order, and older entries may be evicted.
24 class NET_EXPORT_PRIVATE NetworkQualityStore {
25 public:
26 NetworkQualityStore();
27 ~NetworkQualityStore();
28
29 // 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.
30 // |network_id|.
31 void Add(const nqe::internal::NetworkID& network_id,
32 const nqe::internal::CachedNetworkQuality& cached_network_quality);
33
34 // Returns true if the network quality estimate was successfully read
35 // 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.
36 // estimate read.
37 bool GetById(const nqe::internal::NetworkID& network_id,
38 nqe::internal::CachedNetworkQuality* cached_network_quality);
39
40 private:
41 // Maximum size of the store that holds network quality estimates.
42 // 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.
43 // Larger size may affect performance.
44 static const size_t kMaximumNetworkQualityCacheSize = 10;
45
46 // 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.
47 // implements operator<, rather than hash and equality) and because the map is
48 // tiny.
49 typedef std::map<nqe::internal::NetworkID,
50 nqe::internal::CachedNetworkQuality>
51 CachedNetworkQualities;
52
53 // 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.
54 CachedNetworkQualities cached_network_qualities_;
55
56 base::ThreadChecker thread_checker_;
57
58 DISALLOW_COPY_AND_ASSIGN(NetworkQualityStore);
59 };
60
61 } // namespace internal
62
63 } // namespace nqe
64
65 } // namespace net
66
67 #endif // NET_NQE_NETWORK_QUALITY_STORE_H_
OLDNEW
« no previous file with comments | « net/nqe/network_quality_observation_source.h ('k') | net/nqe/network_quality_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698