Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/extensions/cast_streaming_native_handler.h" | 5 #include "chrome/renderer/extensions/cast_streaming_native_handler.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 base::Unretained(this))); | 177 base::Unretained(this))); |
| 178 RouteFunction("StopCastRtpStream", | 178 RouteFunction("StopCastRtpStream", |
| 179 base::Bind(&CastStreamingNativeHandler::StopCastRtpStream, | 179 base::Bind(&CastStreamingNativeHandler::StopCastRtpStream, |
| 180 base::Unretained(this))); | 180 base::Unretained(this))); |
| 181 RouteFunction("DestroyCastUdpTransport", | 181 RouteFunction("DestroyCastUdpTransport", |
| 182 base::Bind(&CastStreamingNativeHandler::DestroyCastUdpTransport, | 182 base::Bind(&CastStreamingNativeHandler::DestroyCastUdpTransport, |
| 183 base::Unretained(this))); | 183 base::Unretained(this))); |
| 184 RouteFunction("SetDestinationCastUdpTransport", | 184 RouteFunction("SetDestinationCastUdpTransport", |
| 185 base::Bind(&CastStreamingNativeHandler::SetDestinationCastUdpTransport, | 185 base::Bind(&CastStreamingNativeHandler::SetDestinationCastUdpTransport, |
| 186 base::Unretained(this))); | 186 base::Unretained(this))); |
| 187 RouteFunction("SetOptionsCastUdpTransport", | |
| 188 base::Bind(&CastStreamingNativeHandler::SetOptionsCastUdpTransport, | |
| 189 base::Unretained(this))); | |
| 187 RouteFunction("ToggleLogging", | 190 RouteFunction("ToggleLogging", |
| 188 base::Bind(&CastStreamingNativeHandler::ToggleLogging, | 191 base::Bind(&CastStreamingNativeHandler::ToggleLogging, |
| 189 base::Unretained(this))); | 192 base::Unretained(this))); |
| 190 RouteFunction("GetRawEvents", | 193 RouteFunction("GetRawEvents", |
| 191 base::Bind(&CastStreamingNativeHandler::GetRawEvents, | 194 base::Bind(&CastStreamingNativeHandler::GetRawEvents, |
| 192 base::Unretained(this))); | 195 base::Unretained(this))); |
| 193 RouteFunction("GetStats", | 196 RouteFunction("GetStats", |
| 194 base::Bind(&CastStreamingNativeHandler::GetStats, | 197 base::Bind(&CastStreamingNativeHandler::GetStats, |
| 195 base::Unretained(this))); | 198 base::Unretained(this))); |
| 196 } | 199 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 } | 454 } |
| 452 net::IPAddressNumber ip; | 455 net::IPAddressNumber ip; |
| 453 if (!net::ParseIPLiteralToNumber(destination->address, &ip)) { | 456 if (!net::ParseIPLiteralToNumber(destination->address, &ip)) { |
| 454 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 457 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
| 455 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidDestination))); | 458 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidDestination))); |
| 456 return; | 459 return; |
| 457 } | 460 } |
| 458 transport->SetDestination(net::IPEndPoint(ip, destination->port)); | 461 transport->SetDestination(net::IPEndPoint(ip, destination->port)); |
| 459 } | 462 } |
| 460 | 463 |
| 464 void CastStreamingNativeHandler::SetOptionsCastUdpTransport( | |
| 465 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 466 CHECK_EQ(2, args.Length()); | |
| 467 CHECK(args[0]->IsInt32()); | |
| 468 CHECK(args[1]->IsString()); | |
| 469 | |
| 470 const int transport_id = args[0]->ToInt32()->Value(); | |
| 471 CastUdpTransport* transport = GetUdpTransportOrThrow(transport_id); | |
| 472 if (!transport) | |
| 473 return; | |
| 474 | |
| 475 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | |
| 476 std::string option_data; | |
|
Alpha Left Google
2014/09/09 00:30:45
If the option is using the type base::DictionaryVa
hubbe
2014/09/09 20:10:01
Done.
| |
| 477 if (args[1]->IsNull()) { | |
| 478 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | |
| 479 v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); | |
| 480 } else { | |
| 481 option_data = *v8::String::Utf8Value(args[1]); | |
| 482 } | |
| 483 transport->SetOptions(option_data); | |
| 484 } | |
| 485 | |
| 461 void CastStreamingNativeHandler::ToggleLogging( | 486 void CastStreamingNativeHandler::ToggleLogging( |
| 462 const v8::FunctionCallbackInfo<v8::Value>& args) { | 487 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 463 CHECK_EQ(2, args.Length()); | 488 CHECK_EQ(2, args.Length()); |
| 464 CHECK(args[0]->IsInt32()); | 489 CHECK(args[0]->IsInt32()); |
| 465 CHECK(args[1]->IsBoolean()); | 490 CHECK(args[1]->IsBoolean()); |
| 466 | 491 |
| 467 const int stream_id = args[0]->ToInt32()->Value(); | 492 const int stream_id = args[0]->ToInt32()->Value(); |
| 468 CastRtpStream* stream = GetRtpStreamOrThrow(stream_id); | 493 CastRtpStream* stream = GetRtpStreamOrThrow(stream_id); |
| 469 if (!stream) | 494 if (!stream) |
| 470 return; | 495 return; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 transport_id); | 605 transport_id); |
| 581 if (iter != udp_transport_map_.end()) | 606 if (iter != udp_transport_map_.end()) |
| 582 return iter->second.get(); | 607 return iter->second.get(); |
| 583 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); | 608 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); |
| 584 isolate->ThrowException(v8::Exception::RangeError( | 609 isolate->ThrowException(v8::Exception::RangeError( |
| 585 v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); | 610 v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); |
| 586 return NULL; | 611 return NULL; |
| 587 } | 612 } |
| 588 | 613 |
| 589 } // namespace extensions | 614 } // namespace extensions |
| OLD | NEW |