| Index: chrome/browser/extensions/api/cast_channel/cast_socket.h
|
| diff --git a/chrome/browser/extensions/api/cast_channel/cast_socket.h b/chrome/browser/extensions/api/cast_channel/cast_socket.h
|
| index dba56d7196f75314ba0a6c59b4f4db566a787a12..22b45ef6e4fd8a0eb2a26f49e3777e0838cdf9fc 100644
|
| --- a/chrome/browser/extensions/api/cast_channel/cast_socket.h
|
| +++ b/chrome/browser/extensions/api/cast_channel/cast_socket.h
|
| @@ -10,10 +10,13 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "base/callback.h"
|
| +#include "base/cancelable_callback.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/task/cancelable_task_tracker.h"
|
| #include "base/threading/thread_checker.h"
|
| +#include "base/timer/timer.h"
|
| #include "chrome/common/extensions/api/cast_channel.h"
|
| #include "extensions/browser/api/api_resource.h"
|
| #include "extensions/browser/api/api_resource_manager.h"
|
| @@ -68,7 +71,8 @@ class CastSocket : public ApiResource,
|
| const net::IPEndPoint& ip_endpoint,
|
| ChannelAuthType channel_auth,
|
| CastSocket::Delegate* delegate,
|
| - net::NetLog* net_log);
|
| + net::NetLog* net_log,
|
| + int connect_timeout_ms);
|
| virtual ~CastSocket();
|
|
|
| // The IP endpoint for the destination of the channel.
|
| @@ -144,6 +148,7 @@ class CastSocket : public ApiResource,
|
| private:
|
| friend class ApiResourceManager<CastSocket>;
|
| friend class CastSocketTest;
|
| + friend class TestCastSocket;
|
|
|
| static const char* service_name() { return "CastSocketManager"; }
|
|
|
| @@ -191,6 +196,10 @@ class CastSocket : public ApiResource,
|
| // 2. Certificate is rooted to a trusted CA.
|
| virtual bool VerifyChallengeReply();
|
|
|
| + // Invoked by a cancelable closure when connection setup time
|
| + // exceeds the interval specified at |connect_timeout_ms_|.
|
| + void CancelConnect();
|
| +
|
| /////////////////////////////////////////////////////////////////////////////
|
| // Following methods work together to implement the following flow:
|
| // 1. Create a new TCP socket and connect to it
|
| @@ -267,6 +276,8 @@ class CastSocket : public ApiResource,
|
|
|
| virtual bool CalledOnValidThread() const;
|
|
|
| + void InjectTimerForTesting(scoped_ptr<base::Timer> injected_timer);
|
| +
|
| base::ThreadChecker thread_checker_;
|
|
|
| // The id of the channel.
|
| @@ -311,9 +322,16 @@ class CastSocket : public ApiResource,
|
| // Reply received from the receiver to a challenge request.
|
| scoped_ptr<CastMessage> challenge_reply_;
|
|
|
| - // Callback invoked when the socket is connected.
|
| + // Callback invoked when the socket is connected or fails to connect.
|
| net::CompletionCallback connect_callback_;
|
|
|
| + // Number of milliseconds to wait before timing out.
|
| + int timeout_interval_ms_;
|
| + // Timer invoked when the connection has timed out.
|
| + scoped_ptr<base::Timer> connect_timeout_timer_;
|
| + // Used to cancel all pending connection event loop tasks on timeout.
|
| + base::CancelableTaskTracker task_tracker_;
|
| +
|
| // Connection flow state machine state.
|
| ConnectionState connect_state_;
|
| // Write flow state machine state.
|
|
|