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

Side by Side Diff: content/browser/net/network_quality_observer_impl.h

Issue 2857093002: Expose changes in the network quality to the renderers (Closed)
Patch Set: ryansturm, nasko comments Created 3 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
OLDNEW
(Empty)
1 // Copyright 2017 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 CONTENT_BROWSER_NET_NETWORK_QUALITY_OBSERVER_IMPL_H_
6 #define CONTENT_BROWSER_NET_NETWORK_QUALITY_OBSERVER_IMPL_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/network_quality_observer_factory.h"
16 #include "net/nqe/network_quality.h"
17 #include "net/nqe/network_quality_estimator.h"
18
19 namespace content {
20
21 // Listens for changes to the network quality and manages sending updates to
22 // each RenderProcess via mojo.
23 class CONTENT_EXPORT NetworkQualityObserverImpl
24 : public net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver {
25 public:
26 explicit NetworkQualityObserverImpl(
27 net::NetworkQualityEstimator* network_quality_estimator);
28
29 ~NetworkQualityObserverImpl() override;
30
31 private:
32 class UiThreadObserver;
33
34 // net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver
35 // implementation:
36 void OnRTTOrThroughputEstimatesComputed(
37 base::TimeDelta http_rtt,
38 base::TimeDelta transport_rtt,
39 int32_t downstream_throughput_kbps) override;
40
41 // |ui_thread_observer_| is owned by |this|, and interacts with
42 // the render processes. It is created on the IO thread but afterwards, should
43 // only be accessed on the UI thread.
44 std::unique_ptr<UiThreadObserver> ui_thread_observer_;
45
46 // |network_quality_estimator_| is guaranteed to be non-null during the
47 // lifetime of |this|.
48 net::NetworkQualityEstimator* network_quality_estimator_;
49
50 // The network quality when the |ui_thread_observer_| was last notified.
51 net::nqe::internal::NetworkQuality last_notified_network_quality_;
52
53 base::ThreadChecker thread_checker_;
54
55 DISALLOW_COPY_AND_ASSIGN(NetworkQualityObserverImpl);
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_BROWSER_NET_NETWORK_QUALITY_OBSERVER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698