| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "extensions/browser/api/cast_channel/cast_channel_api.h" | 5 #include "extensions/browser/api/cast_channel/cast_channel_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Fills |channel_info| from the destination and state of |socket|. | 75 // Fills |channel_info| from the destination and state of |socket|. |
| 76 void FillChannelInfo(const CastSocket& socket, ChannelInfo* channel_info) { | 76 void FillChannelInfo(const CastSocket& socket, ChannelInfo* channel_info) { |
| 77 DCHECK(channel_info); | 77 DCHECK(channel_info); |
| 78 channel_info->channel_id = socket.id(); | 78 channel_info->channel_id = socket.id(); |
| 79 const net::IPEndPoint& ip_endpoint = socket.ip_endpoint(); | 79 const net::IPEndPoint& ip_endpoint = socket.ip_endpoint(); |
| 80 channel_info->connect_info.ip_address = ip_endpoint.ToStringWithoutPort(); | 80 channel_info->connect_info.ip_address = ip_endpoint.ToStringWithoutPort(); |
| 81 channel_info->connect_info.port = ip_endpoint.port(); | 81 channel_info->connect_info.port = ip_endpoint.port(); |
| 82 channel_info->connect_info.auth = | 82 channel_info->connect_info.auth = |
| 83 api::cast_channel::ToChannelAuthType(socket.channel_auth()); | 83 api::cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED; |
| 84 channel_info->ready_state = | 84 channel_info->ready_state = |
| 85 api::cast_channel::ToReadyState(socket.ready_state()); | 85 api::cast_channel::ToReadyState(socket.ready_state()); |
| 86 channel_info->error_state = | 86 channel_info->error_state = |
| 87 api::cast_channel::ToChannelError(socket.error_state()); | 87 api::cast_channel::ToChannelError(socket.error_state()); |
| 88 channel_info->keep_alive = socket.keep_alive(); | 88 channel_info->keep_alive = socket.keep_alive(); |
| 89 channel_info->audio_only = socket.audio_only(); | 89 channel_info->audio_only = socket.audio_only(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Fills |error_info| from |error_state| and |last_error|. | 92 // Fills |error_info| from |error_state| and |last_error|. |
| 93 void FillErrorInfo(api::cast_channel::ChannelError error_state, | 93 void FillErrorInfo(api::cast_channel::ChannelError error_state, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 SetError("livenessTimeout and pingInterval must be set together."); | 272 SetError("livenessTimeout and pingInterval must be set together."); |
| 273 } else if (liveness_timeout_ < ping_interval_) { | 273 } else if (liveness_timeout_ < ping_interval_) { |
| 274 SetError("livenessTimeout must be longer than pingTimeout."); | 274 SetError("livenessTimeout must be longer than pingTimeout."); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (!GetError().empty()) { | 278 if (!GetError().empty()) { |
| 279 return false; | 279 return false; |
| 280 } | 280 } |
| 281 | 281 |
| 282 channel_auth_ = | |
| 283 api::cast_channel::ToChannelAuthTypeInternal(connect_info.auth); | |
| 284 ip_endpoint_.reset(ParseConnectInfo(connect_info)); | 282 ip_endpoint_.reset(ParseConnectInfo(connect_info)); |
| 285 return true; | 283 return true; |
| 286 } | 284 } |
| 287 | 285 |
| 288 void CastChannelOpenFunction::AsyncWorkStart() { | 286 void CastChannelOpenFunction::AsyncWorkStart() { |
| 289 DCHECK(api_); | 287 DCHECK(api_); |
| 290 DCHECK(ip_endpoint_.get()); | 288 DCHECK(ip_endpoint_.get()); |
| 291 const ConnectInfo& connect_info = params_->connect_info; | 289 const ConnectInfo& connect_info = params_->connect_info; |
| 292 CastSocket* socket; | 290 CastSocket* socket; |
| 293 std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest(); | 291 std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest(); |
| 294 if (test_socket.get()) { | 292 if (test_socket.get()) { |
| 295 socket = test_socket.release(); | 293 socket = test_socket.release(); |
| 296 } else { | 294 } else { |
| 297 socket = new CastSocketImpl( | 295 socket = new CastSocketImpl( |
| 298 extension_->id(), *ip_endpoint_, channel_auth_, | 296 *ip_endpoint_, ExtensionsBrowserClient::Get()->GetNetLog(), |
| 299 ExtensionsBrowserClient::Get()->GetNetLog(), | |
| 300 base::TimeDelta::FromMilliseconds(connect_info.timeout.get() | 297 base::TimeDelta::FromMilliseconds(connect_info.timeout.get() |
| 301 ? *connect_info.timeout | 298 ? *connect_info.timeout |
| 302 : kDefaultConnectTimeoutMillis), | 299 : kDefaultConnectTimeoutMillis), |
| 303 liveness_timeout_ > base::TimeDelta(), api_->GetLogger(), | 300 liveness_timeout_ > base::TimeDelta(), api_->GetLogger(), |
| 304 connect_info.capabilities.get() ? *connect_info.capabilities | 301 connect_info.capabilities.get() ? *connect_info.capabilities |
| 305 : CastDeviceCapability::NONE); | 302 : CastDeviceCapability::NONE); |
| 306 } | 303 } |
| 307 new_channel_id_ = cast_socket_service_->AddSocket(base::WrapUnique(socket)); | 304 new_channel_id_ = cast_socket_service_->AddSocket(base::WrapUnique(socket)); |
| 308 | 305 |
| 309 // Construct read delegates. | 306 // Construct read delegates. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 std::move(results))); | 503 std::move(results))); |
| 507 BrowserThread::PostTask( | 504 BrowserThread::PostTask( |
| 508 BrowserThread::UI, FROM_HERE, | 505 BrowserThread::UI, FROM_HERE, |
| 509 base::Bind(ui_dispatch_cb_, base::Passed(std::move(event)))); | 506 base::Bind(ui_dispatch_cb_, base::Passed(std::move(event)))); |
| 510 } | 507 } |
| 511 | 508 |
| 512 void CastChannelOpenFunction::CastMessageHandler::Start() { | 509 void CastChannelOpenFunction::CastMessageHandler::Start() { |
| 513 } | 510 } |
| 514 | 511 |
| 515 } // namespace extensions | 512 } // namespace extensions |
| OLD | NEW |