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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/socket_watcher.h
diff --git a/net/nqe/socket_watcher.h b/net/nqe/socket_watcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..25528f4bf8740659c2c9e50f0734db695f5894df
--- /dev/null
+++ b/net/nqe/socket_watcher.h
@@ -0,0 +1,70 @@
+// 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_SOCKET_WATCHER_H_
+#define NET_NQE_SOCKET_WATCHER_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "net/socket/socket_performance_watcher.h"
+#include "net/socket/socket_performance_watcher_factory.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+class TimeDelta;
+} // namespace base
+
+namespace net {
+
+namespace {
+typedef base::Callback<void(SocketPerformanceWatcherFactory::Protocol protocol,
+ const base::TimeDelta& rtt)>
+ OnUpdatedRTTAvailableCallback;
+}
+
+namespace nqe {
+
+namespace internal {
+
+// SocketWatcher implements SocketPerformanceWatcher, and is not thread-safe.
+class SocketWatcher : public SocketPerformanceWatcher {
+ public:
+ // Creates a SocketWatcher which can be used to watch a socket that uses
+ // |protocol| as the transport layer protocol. The socket watcher will call
+ // |updated_rtt_observation_callback| on |task_runner| every time a new RTT
+ // observation is available.
+ SocketWatcher(SocketPerformanceWatcherFactory::Protocol protocol,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ OnUpdatedRTTAvailableCallback updated_rtt_observation_callback);
+
+ ~SocketWatcher() override;
+
+ // SocketPerformanceWatcher implementation:
+ bool ShouldNotifyUpdatedRTT() const override;
+ void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) override;
+ void OnConnectionChanged() override;
+
+ private:
+ // Transport layer protocol used by the socket that |this| is watching.
+ const SocketPerformanceWatcherFactory::Protocol protocol_;
+
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ // Called every time a new RTT observation is available.
+ OnUpdatedRTTAvailableCallback updated_rtt_observation_callback_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(SocketWatcher);
+};
+
+} // namespace internal
+
+} // namespace nqe
+
+} // namespace net
+
+#endif // NET_NQE_SOCKET_WATCHER_H_
« 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