Chromium Code Reviews| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 SetError("livenessTimeout and pingInterval must be set together."); | 271 SetError("livenessTimeout and pingInterval must be set together."); |
| 272 } else if (liveness_timeout_ < ping_interval_) { | 272 } else if (liveness_timeout_ < ping_interval_) { |
| 273 SetError("livenessTimeout must be longer than pingTimeout."); | 273 SetError("livenessTimeout must be longer than pingTimeout."); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 if (!GetError().empty()) { | 277 if (!GetError().empty()) { |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 | 280 |
| 281 channel_auth_ = | 281 channel_auth_ = |
|
imcheng
2017/06/14 22:25:34
channel_auth_ isn't used anymore and can be remove
zhaobin
2017/06/15 02:22:22
Done.
| |
| 282 api::cast_channel::ToChannelAuthTypeInternal(connect_info.auth); | 282 api::cast_channel::ToChannelAuthTypeInternal(connect_info.auth); |
| 283 ip_endpoint_.reset(ParseConnectInfo(connect_info)); | 283 ip_endpoint_.reset(ParseConnectInfo(connect_info)); |
| 284 return true; | 284 return true; |
| 285 } | 285 } |
| 286 | 286 |
| 287 void CastChannelOpenFunction::AsyncWorkStart() { | 287 void CastChannelOpenFunction::AsyncWorkStart() { |
| 288 DCHECK(api_); | 288 DCHECK(api_); |
| 289 DCHECK(ip_endpoint_.get()); | 289 DCHECK(ip_endpoint_.get()); |
| 290 const ConnectInfo& connect_info = params_->connect_info; | 290 const ConnectInfo& connect_info = params_->connect_info; |
| 291 CastSocket* socket; | 291 CastSocket* socket; |
| 292 std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest(); | 292 std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest(); |
| 293 if (test_socket.get()) { | 293 if (test_socket.get()) { |
| 294 socket = test_socket.release(); | 294 socket = test_socket.release(); |
| 295 } else { | 295 } else { |
| 296 socket = new CastSocketImpl( | 296 socket = new CastSocketImpl( |
| 297 extension_->id(), *ip_endpoint_, channel_auth_, | 297 *ip_endpoint_, ExtensionsBrowserClient::Get()->GetNetLog(), |
| 298 ExtensionsBrowserClient::Get()->GetNetLog(), | |
| 299 base::TimeDelta::FromMilliseconds(connect_info.timeout.get() | 298 base::TimeDelta::FromMilliseconds(connect_info.timeout.get() |
| 300 ? *connect_info.timeout | 299 ? *connect_info.timeout |
| 301 : kDefaultConnectTimeoutMillis), | 300 : kDefaultConnectTimeoutMillis), |
| 302 liveness_timeout_ > base::TimeDelta(), api_->GetLogger(), | 301 liveness_timeout_ > base::TimeDelta(), api_->GetLogger(), |
| 303 connect_info.capabilities.get() ? *connect_info.capabilities | 302 connect_info.capabilities.get() ? *connect_info.capabilities |
| 304 : CastDeviceCapability::NONE); | 303 : CastDeviceCapability::NONE); |
| 305 } | 304 } |
| 306 new_channel_id_ = cast_socket_service_->AddSocket(base::WrapUnique(socket)); | 305 new_channel_id_ = cast_socket_service_->AddSocket(base::WrapUnique(socket)); |
| 307 | 306 |
| 308 // Construct read delegates. | 307 // Construct read delegates. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 331 | 330 |
| 332 void CastChannelOpenFunction::OnOpen(ChannelError result) { | 331 void CastChannelOpenFunction::OnOpen(ChannelError result) { |
| 333 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 332 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 334 VLOG(1) << "Connect finished, OnOpen invoked."; | 333 VLOG(1) << "Connect finished, OnOpen invoked."; |
| 335 // TODO: If we failed to open the CastSocket, we may want to clean up here, | 334 // TODO: If we failed to open the CastSocket, we may want to clean up here, |
| 336 // rather than relying on the extension to call close(). This can be done by | 335 // rather than relying on the extension to call close(). This can be done by |
| 337 // calling RemoveSocket() and api_->GetLogger()->ClearLastErrors(channel_id). | 336 // calling RemoveSocket() and api_->GetLogger()->ClearLastErrors(channel_id). |
| 338 if (result != ChannelError::UNKNOWN) { | 337 if (result != ChannelError::UNKNOWN) { |
| 339 CastSocket* socket = cast_socket_service_->GetSocket(new_channel_id_); | 338 CastSocket* socket = cast_socket_service_->GetSocket(new_channel_id_); |
| 340 CHECK(socket); | 339 CHECK(socket); |
| 341 SetResultFromSocket(*socket); | 340 SetResultFromSocket(*socket); |
|
mark a. foltz
2017/06/14 22:33:21
In FillChannelInfo, you can hard code SSL_VERIFIED
zhaobin
2017/06/15 02:22:22
Done.
| |
| 342 } else { | 341 } else { |
| 343 // The socket is being destroyed. | 342 // The socket is being destroyed. |
| 344 SetResultFromError(new_channel_id_, | 343 SetResultFromError(new_channel_id_, |
| 345 api::cast_channel::CHANNEL_ERROR_UNKNOWN); | 344 api::cast_channel::CHANNEL_ERROR_UNKNOWN); |
| 346 } | 345 } |
| 347 | 346 |
| 348 AsyncWorkCompleted(); | 347 AsyncWorkCompleted(); |
| 349 } | 348 } |
| 350 | 349 |
| 351 CastChannelSendFunction::CastChannelSendFunction() { } | 350 CastChannelSendFunction::CastChannelSendFunction() { } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 std::move(results))); | 504 std::move(results))); |
| 506 BrowserThread::PostTask( | 505 BrowserThread::PostTask( |
| 507 BrowserThread::UI, FROM_HERE, | 506 BrowserThread::UI, FROM_HERE, |
| 508 base::Bind(ui_dispatch_cb_, base::Passed(std::move(event)))); | 507 base::Bind(ui_dispatch_cb_, base::Passed(std::move(event)))); |
| 509 } | 508 } |
| 510 | 509 |
| 511 void CastChannelOpenFunction::CastMessageHandler::Start() { | 510 void CastChannelOpenFunction::CastMessageHandler::Start() { |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace extensions | 513 } // namespace extensions |
| OLD | NEW |