| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 EXTENSIONS_BROWSER_API_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // details. | 28 // details. |
| 29 // |inner_delegate|: The delegate which processes all non-keep-alive | 29 // |inner_delegate|: The delegate which processes all non-keep-alive |
| 30 // messages. This object assumes ownership of | 30 // messages. This object assumes ownership of |
| 31 // |inner_delegate|. | 31 // |inner_delegate|. |
| 32 // |ping_interval|: The amount of idle time to wait before sending a PING to | 32 // |ping_interval|: The amount of idle time to wait before sending a PING to |
| 33 // the remote end. | 33 // the remote end. |
| 34 // |liveness_timeout|: The amount of idle time to wait before terminating the | 34 // |liveness_timeout|: The amount of idle time to wait before terminating the |
| 35 // connection. | 35 // connection. |
| 36 KeepAliveDelegate(CastSocket* socket, | 36 KeepAliveDelegate(CastSocket* socket, |
| 37 scoped_refptr<Logger> logger, | 37 scoped_refptr<Logger> logger, |
| 38 scoped_ptr<CastTransport::Delegate> inner_delegate, | 38 std::unique_ptr<CastTransport::Delegate> inner_delegate, |
| 39 base::TimeDelta ping_interval, | 39 base::TimeDelta ping_interval, |
| 40 base::TimeDelta liveness_timeout); | 40 base::TimeDelta liveness_timeout); |
| 41 | 41 |
| 42 ~KeepAliveDelegate() override; | 42 ~KeepAliveDelegate() override; |
| 43 | 43 |
| 44 // Creates a keep-alive message (e.g. PING or PONG). | 44 // Creates a keep-alive message (e.g. PING or PONG). |
| 45 static CastMessage CreateKeepAliveMessage(const char* message_type); | 45 static CastMessage CreateKeepAliveMessage(const char* message_type); |
| 46 | 46 |
| 47 void SetTimersForTest(scoped_ptr<base::Timer> injected_ping_timer, | 47 void SetTimersForTest(std::unique_ptr<base::Timer> injected_ping_timer, |
| 48 scoped_ptr<base::Timer> injected_liveness_timer); | 48 std::unique_ptr<base::Timer> injected_liveness_timer); |
| 49 | 49 |
| 50 // CastTransport::Delegate implementation. | 50 // CastTransport::Delegate implementation. |
| 51 void Start() override; | 51 void Start() override; |
| 52 void OnError(ChannelError error_state) override; | 52 void OnError(ChannelError error_state) override; |
| 53 void OnMessage(const CastMessage& message) override; | 53 void OnMessage(const CastMessage& message) override; |
| 54 | 54 |
| 55 static const char kHeartbeatPingType[]; | 55 static const char kHeartbeatPingType[]; |
| 56 static const char kHeartbeatPongType[]; | 56 static const char kHeartbeatPongType[]; |
| 57 | 57 |
| 58 private: | 58 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 // Indicates that Start() was called. | 78 // Indicates that Start() was called. |
| 79 bool started_; | 79 bool started_; |
| 80 | 80 |
| 81 // Socket that is managed by the keep-alive object. | 81 // Socket that is managed by the keep-alive object. |
| 82 CastSocket* socket_; | 82 CastSocket* socket_; |
| 83 | 83 |
| 84 // Logging object. | 84 // Logging object. |
| 85 scoped_refptr<Logger> logger_; | 85 scoped_refptr<Logger> logger_; |
| 86 | 86 |
| 87 // Delegate object which receives all non-keep alive messages. | 87 // Delegate object which receives all non-keep alive messages. |
| 88 scoped_ptr<CastTransport::Delegate> inner_delegate_; | 88 std::unique_ptr<CastTransport::Delegate> inner_delegate_; |
| 89 | 89 |
| 90 // Amount of idle time to wait before disconnecting. | 90 // Amount of idle time to wait before disconnecting. |
| 91 base::TimeDelta liveness_timeout_; | 91 base::TimeDelta liveness_timeout_; |
| 92 | 92 |
| 93 // Amount of idle time to wait before pinging the receiver. | 93 // Amount of idle time to wait before pinging the receiver. |
| 94 base::TimeDelta ping_interval_; | 94 base::TimeDelta ping_interval_; |
| 95 | 95 |
| 96 // Fired when |ping_interval_| is exceeded or when triggered by test code. | 96 // Fired when |ping_interval_| is exceeded or when triggered by test code. |
| 97 scoped_ptr<base::Timer> ping_timer_; | 97 std::unique_ptr<base::Timer> ping_timer_; |
| 98 | 98 |
| 99 // Fired when |liveness_timer_| is exceeded. | 99 // Fired when |liveness_timer_| is exceeded. |
| 100 scoped_ptr<base::Timer> liveness_timer_; | 100 std::unique_ptr<base::Timer> liveness_timer_; |
| 101 | 101 |
| 102 // The PING message to send over the wire. | 102 // The PING message to send over the wire. |
| 103 CastMessage ping_message_; | 103 CastMessage ping_message_; |
| 104 | 104 |
| 105 // The PONG message to send over the wire. | 105 // The PONG message to send over the wire. |
| 106 CastMessage pong_message_; | 106 CastMessage pong_message_; |
| 107 | 107 |
| 108 base::ThreadChecker thread_checker_; | 108 base::ThreadChecker thread_checker_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(KeepAliveDelegate); | 110 DISALLOW_COPY_AND_ASSIGN(KeepAliveDelegate); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace cast_channel | 113 } // namespace cast_channel |
| 114 } // namespace api | 114 } // namespace api |
| 115 } // namespace extensions | 115 } // namespace extensions |
| 116 | 116 |
| 117 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_ | 117 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_KEEP_ALIVE_DELEGATE_H_ |
| OLD | NEW |