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

Unified Diff: components/cast_channel/keep_alive_delegate.h

Issue 2926313002: Revert of [cast_channel] Move cast_channel related files from //extensions to //components (Closed)
Patch Set: Created 3 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 | « components/cast_channel/cast_transport_unittest.cc ('k') | components/cast_channel/keep_alive_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cast_channel/keep_alive_delegate.h
diff --git a/components/cast_channel/keep_alive_delegate.h b/components/cast_channel/keep_alive_delegate.h
deleted file mode 100644
index 9840b602af68bae13d1b72af13fddcb7664da793..0000000000000000000000000000000000000000
--- a/components/cast_channel/keep_alive_delegate.h
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2015 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 COMPONENTS_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_
-#define COMPONENTS_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_
-
-#include "base/macros.h"
-#include "base/threading/thread_checker.h"
-#include "base/timer/timer.h"
-#include "components/cast_channel/cast_transport.h"
-#include "components/cast_channel/proto/cast_channel.pb.h"
-
-namespace cast_channel {
-
-class CastSocket;
-class Logger;
-
-// Decorator delegate which provides keep-alive functionality.
-// Keep-alive messages are handled by this object; all other messages and
-// errors are passed to |inner_delegate_|.
-class KeepAliveDelegate : public CastTransport::Delegate {
- public:
- // |socket|: The socket to be kept alive.
- // |logger|: The logging object which collects protocol events and error
- // details.
- // |inner_delegate|: The delegate which processes all non-keep-alive
- // messages. This object assumes ownership of
- // |inner_delegate|.
- // |ping_interval|: The amount of idle time to wait before sending a PING to
- // the remote end.
- // |liveness_timeout|: The amount of idle time to wait before terminating the
- // connection.
- KeepAliveDelegate(CastSocket* socket,
- scoped_refptr<Logger> logger,
- std::unique_ptr<CastTransport::Delegate> inner_delegate,
- base::TimeDelta ping_interval,
- base::TimeDelta liveness_timeout);
-
- ~KeepAliveDelegate() override;
-
- // Creates a keep-alive message (e.g. PING or PONG).
- static CastMessage CreateKeepAliveMessage(const char* message_type);
-
- void SetTimersForTest(std::unique_ptr<base::Timer> injected_ping_timer,
- std::unique_ptr<base::Timer> injected_liveness_timer);
-
- // CastTransport::Delegate implementation.
- void Start() override;
- void OnError(ChannelError error_state) override;
- void OnMessage(const CastMessage& message) override;
-
- static const char kHeartbeatPingType[];
- static const char kHeartbeatPongType[];
-
- private:
- // Restarts the ping/liveness timeout timers. Called when a message
- // is received from the remote end.
- void ResetTimers();
-
- // Sends a formatted PING or PONG message to the remote side.
- void SendKeepAliveMessage(const CastMessage& message,
- const char* message_type);
-
- // Callback for SendKeepAliveMessage.
- void SendKeepAliveMessageComplete(const char* message_type, int rv);
-
- // Called when the liveness timer expires, indicating that the remote
- // end has not responded within the |liveness_timeout_| interval.
- void LivenessTimeout();
-
- // Stops the ping and liveness timers if they are started.
- // To be called after an error.
- void Stop();
-
- // Indicates that Start() was called.
- bool started_;
-
- // Socket that is managed by the keep-alive object.
- CastSocket* socket_;
-
- // Logging object.
- scoped_refptr<Logger> logger_;
-
- // Delegate object which receives all non-keep alive messages.
- std::unique_ptr<CastTransport::Delegate> inner_delegate_;
-
- // Amount of idle time to wait before disconnecting.
- base::TimeDelta liveness_timeout_;
-
- // Amount of idle time to wait before pinging the receiver.
- base::TimeDelta ping_interval_;
-
- // Fired when |ping_interval_| is exceeded or when triggered by test code.
- std::unique_ptr<base::Timer> ping_timer_;
-
- // Fired when |liveness_timer_| is exceeded.
- std::unique_ptr<base::Timer> liveness_timer_;
-
- // The PING message to send over the wire.
- CastMessage ping_message_;
-
- // The PONG message to send over the wire.
- CastMessage pong_message_;
-
- THREAD_CHECKER(thread_checker_);
-
- DISALLOW_COPY_AND_ASSIGN(KeepAliveDelegate);
-};
-
-} // namespace cast_channel
-
-#endif // COMPONENTS_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_
« no previous file with comments | « components/cast_channel/cast_transport_unittest.cc ('k') | components/cast_channel/keep_alive_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698