| 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/webrtc_native_handler.h" |    5 #include "chrome/renderer/extensions/webrtc_native_handler.h" | 
|    6  |    6  | 
|    7 #include <functional> |    7 #include <functional> | 
|    8  |    8  | 
|    9 #include "base/logging.h" |    9 #include "base/logging.h" | 
|   10 #include "chrome/common/extensions/api/webrtc_cast_send_transport.h" |   10 #include "chrome/common/extensions/api/webrtc_cast_send_transport.h" | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  219  |  219  | 
|  220   const int transport_id = args[0]->ToInt32()->Value(); |  220   const int transport_id = args[0]->ToInt32()->Value(); | 
|  221   CastSendTransport* transport = GetSendTransportOrThrow(transport_id); |  221   CastSendTransport* transport = GetSendTransportOrThrow(transport_id); | 
|  222   if (!transport) |  222   if (!transport) | 
|  223     return; |  223     return; | 
|  224  |  224  | 
|  225   scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |  225   scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 
|  226   scoped_ptr<Value> params_value( |  226   scoped_ptr<Value> params_value( | 
|  227       converter->FromV8Value(args[1], context()->v8_context())); |  227       converter->FromV8Value(args[1], context()->v8_context())); | 
|  228   if (!params_value) { |  228   if (!params_value) { | 
|  229     v8::ThrowException(v8::Exception::TypeError( |  229     args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 
|  230         v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertParams))); |  230         v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertParams))); | 
|  231     return; |  231     return; | 
|  232   } |  232   } | 
|  233   scoped_ptr<RtpParams> params = RtpParams::FromValue(*params_value); |  233   scoped_ptr<RtpParams> params = RtpParams::FromValue(*params_value); | 
|  234   if (!params) { |  234   if (!params) { | 
|  235     v8::ThrowException(v8::Exception::TypeError( |  235     args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 
|  236         v8::String::NewFromUtf8(args.GetIsolate(), kInvalidRtpParams))); |  236         v8::String::NewFromUtf8(args.GetIsolate(), kInvalidRtpParams))); | 
|  237     return; |  237     return; | 
|  238   } |  238   } | 
|  239  |  239  | 
|  240   CastRtpCaps cast_params; |  240   CastRtpCaps cast_params; | 
|  241   ToCastRtpParams(*params, &cast_params); |  241   ToCastRtpParams(*params, &cast_params); | 
|  242   transport->Start(cast_params); |  242   transport->Start(cast_params); | 
|  243 } |  243 } | 
|  244  |  244  | 
|  245 void WebRtcNativeHandler::StopCastSendTransport( |  245 void WebRtcNativeHandler::StopCastSendTransport( | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  287  |  287  | 
|  288   const int transport_id = args[0]->ToInt32()->Value(); |  288   const int transport_id = args[0]->ToInt32()->Value(); | 
|  289   CastUdpTransport* transport = GetUdpTransportOrThrow(transport_id); |  289   CastUdpTransport* transport = GetUdpTransportOrThrow(transport_id); | 
|  290   if (!transport) |  290   if (!transport) | 
|  291     return; |  291     return; | 
|  292  |  292  | 
|  293   scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |  293   scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 
|  294   scoped_ptr<Value> udp_params_value( |  294   scoped_ptr<Value> udp_params_value( | 
|  295       converter->FromV8Value(args[1], context()->v8_context())); |  295       converter->FromV8Value(args[1], context()->v8_context())); | 
|  296   if (!udp_params_value) { |  296   if (!udp_params_value) { | 
|  297     v8::ThrowException(v8::Exception::TypeError( |  297     args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 
|  298         v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); |  298         v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); | 
|  299     return; |  299     return; | 
|  300   } |  300   } | 
|  301   scoped_ptr<UdpParams> udp_params = UdpParams::FromValue(*udp_params_value); |  301   scoped_ptr<UdpParams> udp_params = UdpParams::FromValue(*udp_params_value); | 
|  302   if (!udp_params) { |  302   if (!udp_params) { | 
|  303     v8::ThrowException(v8::Exception::TypeError( |  303     args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 
|  304         v8::String::NewFromUtf8(args.GetIsolate(), kInvalidUdpParams))); |  304         v8::String::NewFromUtf8(args.GetIsolate(), kInvalidUdpParams))); | 
|  305     return; |  305     return; | 
|  306   } |  306   } | 
|  307   transport->Start(net::HostPortPair(udp_params->address, udp_params->port)); |  307   transport->Start(net::HostPortPair(udp_params->address, udp_params->port)); | 
|  308 } |  308 } | 
|  309  |  309  | 
|  310 CastSendTransport* WebRtcNativeHandler::GetSendTransportOrThrow( |  310 CastSendTransport* WebRtcNativeHandler::GetSendTransportOrThrow( | 
|  311     int transport_id) const { |  311     int transport_id) const { | 
|  312   SendTransportMap::const_iterator iter = send_transport_map_.find( |  312   SendTransportMap::const_iterator iter = send_transport_map_.find( | 
|  313       transport_id); |  313       transport_id); | 
|  314   if (iter != send_transport_map_.end()) |  314   if (iter != send_transport_map_.end()) | 
|  315     return iter->second.get(); |  315     return iter->second.get(); | 
|  316   v8::Isolate* isolate = context()->v8_context()->GetIsolate(); |  316   v8::Isolate* isolate = context()->v8_context()->GetIsolate(); | 
|  317   v8::ThrowException(v8::Exception::RangeError( |  317   isolate->ThrowException(v8::Exception::RangeError( | 
|  318       v8::String::NewFromUtf8(isolate, kSendTransportNotFound))); |  318       v8::String::NewFromUtf8(isolate, kSendTransportNotFound))); | 
|  319   return NULL; |  319   return NULL; | 
|  320 } |  320 } | 
|  321  |  321  | 
|  322 CastUdpTransport* WebRtcNativeHandler::GetUdpTransportOrThrow( |  322 CastUdpTransport* WebRtcNativeHandler::GetUdpTransportOrThrow( | 
|  323     int transport_id) const { |  323     int transport_id) const { | 
|  324   UdpTransportMap::const_iterator iter = udp_transport_map_.find( |  324   UdpTransportMap::const_iterator iter = udp_transport_map_.find( | 
|  325       transport_id); |  325       transport_id); | 
|  326   if (iter != udp_transport_map_.end()) |  326   if (iter != udp_transport_map_.end()) | 
|  327     return iter->second.get(); |  327     return iter->second.get(); | 
|  328   v8::Isolate* isolate = context()->v8_context()->GetIsolate(); |  328   v8::Isolate* isolate = context()->v8_context()->GetIsolate(); | 
|  329   v8::ThrowException(v8::Exception::RangeError( |  329   isolate->ThrowException(v8::Exception::RangeError( | 
|  330       v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); |  330       v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); | 
|  331   return NULL; |  331   return NULL; | 
|  332 } |  332 } | 
|  333  |  333  | 
|  334 }  // namespace extensions |  334 }  // namespace extensions | 
| OLD | NEW |