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 <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "extensions/common/api/cast_channel/logging.pb.h" | 23 #include "extensions/common/api/cast_channel/logging.pb.h" |
| 24 #include "net/base/ip_endpoint.h" | 24 #include "net/base/ip_endpoint.h" |
| 25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 26 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
| 27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 28 | 28 |
| 29 // Default timeout interval for connection setup. | 29 // Default timeout interval for connection setup. |
| 30 // Used if not otherwise specified at ConnectInfo::timeout. | 30 // Used if not otherwise specified at ConnectInfo::timeout. |
| 31 const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. | 31 const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. |
| 32 | 32 |
| 33 // Cast device capabilities. | |
| 34 enum CastDeviceCapability { | |
| 35 VIDEO_OUT = (1 << 0), | |
|
mark a. foltz
2015/01/12 22:01:57
I don't think the parenthesis are necessary.
vadimgo
2015/01/13 00:08:27
Removed parenthesis.
| |
| 36 VIDEO_IN = (1 << 1), | |
| 37 AUDIO_OUT = (1 << 2), | |
| 38 AUDIO_IN = (1 << 3), | |
| 39 DEV_MODE = (1 << 4) | |
| 40 }; | |
| 41 | |
| 33 namespace extensions { | 42 namespace extensions { |
| 34 | 43 |
| 35 namespace Close = cast_channel::Close; | 44 namespace Close = cast_channel::Close; |
| 36 namespace OnError = cast_channel::OnError; | 45 namespace OnError = cast_channel::OnError; |
| 37 namespace OnMessage = cast_channel::OnMessage; | 46 namespace OnMessage = cast_channel::OnMessage; |
| 38 namespace Open = cast_channel::Open; | 47 namespace Open = cast_channel::Open; |
| 39 namespace Send = cast_channel::Send; | 48 namespace Send = cast_channel::Send; |
| 40 using cast_channel::CastMessage; | 49 using cast_channel::CastMessage; |
| 41 using cast_channel::CastSocket; | 50 using cast_channel::CastSocket; |
| 42 using cast_channel::ChannelAuthType; | 51 using cast_channel::ChannelAuthType; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 if (test_socket.get()) { | 350 if (test_socket.get()) { |
| 342 socket = test_socket.release(); | 351 socket = test_socket.release(); |
| 343 } else { | 352 } else { |
| 344 socket = new cast_channel::CastSocketImpl( | 353 socket = new cast_channel::CastSocketImpl( |
| 345 extension_->id(), *ip_endpoint_, channel_auth_, | 354 extension_->id(), *ip_endpoint_, channel_auth_, |
| 346 ExtensionsBrowserClient::Get()->GetNetLog(), | 355 ExtensionsBrowserClient::Get()->GetNetLog(), |
| 347 base::TimeDelta::FromMilliseconds(connect_info_->timeout.get() | 356 base::TimeDelta::FromMilliseconds(connect_info_->timeout.get() |
| 348 ? *connect_info_->timeout | 357 ? *connect_info_->timeout |
| 349 : kDefaultConnectTimeoutMillis), | 358 : kDefaultConnectTimeoutMillis), |
| 350 api_->GetLogger()); | 359 api_->GetLogger()); |
| 360 | |
| 361 // If device capabilities are available in the connect information, pass the | |
|
mark a. foltz
2015/01/12 22:01:56
Slightly prefer to pass the capabilities in the Ca
vadimgo
2015/01/13 00:08:27
Changed to pass device capabilities to the socket
| |
| 362 // claimed video out capability to the socket for audio only policy | |
| 363 // enforcement. | |
| 364 if (connect_info_->capabilities.get()) { | |
| 365 bool has_video_out = | |
| 366 (*connect_info_->capabilities & CastDeviceCapability::VIDEO_OUT) == | |
| 367 CastDeviceCapability::VIDEO_OUT; | |
| 368 socket->set_has_video_out(has_video_out); | |
|
mark a. foltz
2015/01/12 22:01:56
ISTM we should have an API like
socket->HasCapabi
vadimgo
2015/01/13 00:08:27
This code is removed with the new api design.
| |
| 369 } | |
| 351 } | 370 } |
| 352 new_channel_id_ = AddSocket(socket); | 371 new_channel_id_ = AddSocket(socket); |
| 353 scoped_ptr<CastMessageHandler> delegate(new CastMessageHandler(api_, socket)); | 372 scoped_ptr<CastMessageHandler> delegate(new CastMessageHandler(api_, socket)); |
| 354 api_->GetLogger()->LogNewSocketEvent(*socket); | 373 api_->GetLogger()->LogNewSocketEvent(*socket); |
| 355 socket->Connect(delegate.Pass(), | 374 socket->Connect(delegate.Pass(), |
| 356 base::Bind(&CastChannelOpenFunction::OnOpen, this)); | 375 base::Bind(&CastChannelOpenFunction::OnOpen, this)); |
| 357 } | 376 } |
| 358 | 377 |
| 359 void CastChannelOpenFunction::OnOpen(cast_channel::ChannelError result) { | 378 void CastChannelOpenFunction::OnOpen(cast_channel::ChannelError result) { |
| 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 379 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 std::string& signature = params_->signature; | 581 std::string& signature = params_->signature; |
| 563 if (signature.empty() || keys.empty() || | 582 if (signature.empty() || keys.empty() || |
| 564 !cast_channel::SetTrustedCertificateAuthorities(keys, signature)) { | 583 !cast_channel::SetTrustedCertificateAuthorities(keys, signature)) { |
| 565 SetError("Unable to set authority keys."); | 584 SetError("Unable to set authority keys."); |
| 566 } | 585 } |
| 567 | 586 |
| 568 AsyncWorkCompleted(); | 587 AsyncWorkCompleted(); |
| 569 } | 588 } |
| 570 | 589 |
| 571 } // namespace extensions | 590 } // namespace extensions |
| OLD | NEW |