Index: chrome/browser/extensions/api/cast_channel/cast_channel_api.cc |
diff --git a/chrome/browser/extensions/api/cast_channel/cast_channel_api.cc b/chrome/browser/extensions/api/cast_channel/cast_channel_api.cc |
index d1a84e4a31261a8f61178ce6c93e854619311df5..9071b6a65821be928946c5c094c1dc2a76bc97d4 100644 |
--- a/chrome/browser/extensions/api/cast_channel/cast_channel_api.cc |
+++ b/chrome/browser/extensions/api/cast_channel/cast_channel_api.cc |
@@ -20,6 +20,10 @@ |
#include "net/base/net_util.h" |
#include "url/gurl.h" |
+// Default timeout interval for connection setup. |
+// Used if not otherwise specified at ConnectInfo::timeout. |
+const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. |
+ |
namespace extensions { |
namespace Close = cast_channel::Close; |
@@ -83,13 +87,14 @@ CastChannelAPI::GetFactoryInstance() { |
scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket( |
const std::string& extension_id, const net::IPEndPoint& ip_endpoint, |
- ChannelAuthType channel_auth) { |
+ ChannelAuthType channel_auth, int timeout_millis) { |
if (socket_for_test_.get()) { |
return socket_for_test_.Pass(); |
} else { |
return scoped_ptr<CastSocket>( |
new CastSocket(extension_id, ip_endpoint, channel_auth, this, |
- g_browser_process->net_log())); |
+ g_browser_process->net_log(), |
+ timeout_millis)); |
} |
} |
@@ -244,7 +249,7 @@ bool CastChannelOpenFunction::ParseChannelUrl(const GURL& url, |
cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED : |
cast_channel::CHANNEL_AUTH_TYPE_SSL; |
return true; |
-}; |
+} |
net::IPEndPoint* CastChannelOpenFunction::ParseConnectInfo( |
const ConnectInfo& connect_info) { |
@@ -300,7 +305,11 @@ void CastChannelOpenFunction::AsyncWorkStart() { |
DCHECK(api_); |
DCHECK(ip_endpoint_.get()); |
scoped_ptr<CastSocket> socket = api_->CreateCastSocket( |
- extension_->id(), *ip_endpoint_, channel_auth_); |
+ extension_->id(), |
+ *ip_endpoint_, |
+ channel_auth_, |
+ (connect_info_->timeout.get() ? *connect_info_->timeout |
+ : kDefaultConnectTimeoutMillis)); |
new_channel_id_ = AddSocket(socket.release()); |
GetSocket(new_channel_id_)->Connect( |
base::Bind(&CastChannelOpenFunction::OnOpen, this)); |