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

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

Issue 2024813003: Split SocketWatcher and SocketWatcherFactory out of NQE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 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_estimator.cc ('k') | net/nqe/socket_watcher.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_SOCKET_WATCHER_H_
6 #define NET_NQE_SOCKET_WATCHER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "net/socket/socket_performance_watcher.h"
13 #include "net/socket/socket_performance_watcher_factory.h"
14
15 namespace base {
16 class SingleThreadTaskRunner;
17 class TimeDelta;
18 } // namespace base
19
20 namespace net {
21
22 namespace {
23 typedef base::Callback<void(SocketPerformanceWatcherFactory::Protocol protocol,
24 const base::TimeDelta& rtt)>
25 OnUpdatedRTTAvailableCallback;
26 }
27
28 namespace nqe {
29
30 namespace internal {
31
32 // SocketWatcher implements SocketPerformanceWatcher, and is not thread-safe.
33 class SocketWatcher : public SocketPerformanceWatcher {
34 public:
35 // Creates a SocketWatcher which can be used to watch a socket that uses
36 // |protocol| as the transport layer protocol. The socket watcher will call
37 // |updated_rtt_observation_callback| on |task_runner| every time a new RTT
38 // observation is available.
39 SocketWatcher(SocketPerformanceWatcherFactory::Protocol protocol,
40 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
41 OnUpdatedRTTAvailableCallback updated_rtt_observation_callback);
42
43 ~SocketWatcher() override;
44
45 // SocketPerformanceWatcher implementation:
46 bool ShouldNotifyUpdatedRTT() const override;
47 void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) override;
48 void OnConnectionChanged() override;
49
50 private:
51 // Transport layer protocol used by the socket that |this| is watching.
52 const SocketPerformanceWatcherFactory::Protocol protocol_;
53
54 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
55
56 // Called every time a new RTT observation is available.
57 OnUpdatedRTTAvailableCallback updated_rtt_observation_callback_;
58
59 base::ThreadChecker thread_checker_;
60
61 DISALLOW_COPY_AND_ASSIGN(SocketWatcher);
62 };
63
64 } // namespace internal
65
66 } // namespace nqe
67
68 } // namespace net
69
70 #endif // NET_NQE_SOCKET_WATCHER_H_
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | net/nqe/socket_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698