OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_NQE_CACHED_NETWORK_QUALITY_H_ | 5 #ifndef NET_NQE_CACHED_NETWORK_QUALITY_H_ |
6 #define NET_NQE_CACHED_NETWORK_QUALITY_H_ | 6 #define NET_NQE_CACHED_NETWORK_QUALITY_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
11 #include "net/nqe/network_quality.h" | 11 #include "net/nqe/network_quality.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 namespace nqe { | 15 namespace nqe { |
16 | 16 |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 // CachedNetworkQuality stores the quality of a previously seen network. | 19 // CachedNetworkQuality stores the quality of a previously seen network. |
20 class NET_EXPORT_PRIVATE CachedNetworkQuality { | 20 class NET_EXPORT_PRIVATE CachedNetworkQuality { |
21 public: | 21 public: |
22 explicit CachedNetworkQuality(const NetworkQuality& network_quality); | 22 CachedNetworkQuality(); |
23 | |
24 // |last_update_time| is the time when the |network_quality| was computed. | |
25 CachedNetworkQuality(base::TimeTicks last_update_time, | |
26 const NetworkQuality& network_quality); | |
23 CachedNetworkQuality(const CachedNetworkQuality& other); | 27 CachedNetworkQuality(const CachedNetworkQuality& other); |
24 ~CachedNetworkQuality(); | 28 ~CachedNetworkQuality(); |
25 | 29 |
26 // Returns the network quality associated with this cached entry. | 30 // Returns the network quality associated with this cached entry. |
27 const NetworkQuality& network_quality() const { return network_quality_; } | 31 const NetworkQuality& network_quality() const { return network_quality_; } |
28 | 32 |
33 CachedNetworkQuality& operator=(const CachedNetworkQuality& other); | |
34 | |
29 // Returns true if this cache entry was updated before | 35 // Returns true if this cache entry was updated before |
30 // |cached_network_quality|. | 36 // |cached_network_quality|. |
31 bool OlderThan(const CachedNetworkQuality& cached_network_quality) const; | 37 bool OlderThan(const CachedNetworkQuality& cached_network_quality) const; |
32 | 38 |
39 base::TimeTicks last_update_time() { return last_update_time_; } | |
bengr
2016/07/19 01:04:35
Can this return a const &?
tbansal1
2016/07/20 00:08:47
Passing by ref is actually slower because it requi
bengr
2016/07/21 00:16:23
Interesting. Thanks.
| |
40 | |
41 const NetworkQuality& network_quality() { return network_quality_; } | |
42 | |
43 private: | |
33 // Time when this cache entry was last updated. | 44 // Time when this cache entry was last updated. |
34 const base::TimeTicks last_update_time_; | 45 base::TimeTicks last_update_time_; |
35 | 46 |
36 // Quality of this cached network. | 47 // Quality of this cached network. |
37 const NetworkQuality network_quality_; | 48 NetworkQuality network_quality_; |
38 | |
39 private: | |
40 DISALLOW_ASSIGN(CachedNetworkQuality); | |
41 }; | 49 }; |
42 | 50 |
43 } // namespace internal | 51 } // namespace internal |
44 | 52 |
45 } // namespace nqe | 53 } // namespace nqe |
46 | 54 |
47 } // namespace net | 55 } // namespace net |
48 | 56 |
49 #endif // NET_NQE_CACHED_NETWORK_QUALITY_H_ | 57 #endif // NET_NQE_CACHED_NETWORK_QUALITY_H_ |
OLD | NEW |