| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 CHECK_EQ(2, args.Length()); | 502 CHECK_EQ(2, args.Length()); |
| 503 CHECK(args[0]->IsInt32()); | 503 CHECK(args[0]->IsInt32()); |
| 504 CHECK(args[1]->IsObject()); | 504 CHECK(args[1]->IsObject()); |
| 505 | 505 |
| 506 const int transport_id = args[0]->ToInt32(args.GetIsolate())->Value(); | 506 const int transport_id = args[0]->ToInt32(args.GetIsolate())->Value(); |
| 507 CastUdpTransport* transport = GetUdpTransportOrThrow(transport_id); | 507 CastUdpTransport* transport = GetUdpTransportOrThrow(transport_id); |
| 508 if (!transport) | 508 if (!transport) |
| 509 return; | 509 return; |
| 510 | 510 |
| 511 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 511 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 512 base::Value* options_value = | 512 std::unique_ptr<base::DictionaryValue> options = base::DictionaryValue::From( |
| 513 converter->FromV8Value(args[1], context()->v8_context()); | 513 converter->FromV8Value(args[1], context()->v8_context())); |
| 514 base::DictionaryValue* options; | 514 if (!options) { |
| 515 if (!options_value || !options_value->GetAsDictionary(&options)) { | |
| 516 delete options_value; | |
| 517 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 515 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
| 518 v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); | 516 v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); |
| 519 return; | 517 return; |
| 520 } | 518 } |
| 521 transport->SetOptions(base::WrapUnique(options)); | 519 transport->SetOptions(std::move(options)); |
| 522 } | 520 } |
| 523 | 521 |
| 524 void CastStreamingNativeHandler::ToggleLogging( | 522 void CastStreamingNativeHandler::ToggleLogging( |
| 525 const v8::FunctionCallbackInfo<v8::Value>& args) { | 523 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 526 CHECK_EQ(2, args.Length()); | 524 CHECK_EQ(2, args.Length()); |
| 527 CHECK(args[0]->IsInt32()); | 525 CHECK(args[0]->IsInt32()); |
| 528 CHECK(args[1]->IsBoolean()); | 526 CHECK(args[1]->IsBoolean()); |
| 529 | 527 |
| 530 const int stream_id = args[0]->ToInt32(args.GetIsolate())->Value(); | 528 const int stream_id = args[0]->ToInt32(args.GetIsolate())->Value(); |
| 531 CastRtpStream* stream = GetRtpStreamOrThrow(stream_id); | 529 CastRtpStream* stream = GetRtpStreamOrThrow(stream_id); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 LOG(ERROR) << "Failed to add Cast audio track to media stream."; | 877 LOG(ERROR) << "Failed to add Cast audio track to media stream."; |
| 880 } | 878 } |
| 881 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote | 879 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote |
| 882 true, // is_readonly | 880 true, // is_readonly |
| 883 &web_stream)) { | 881 &web_stream)) { |
| 884 LOG(ERROR) << "Failed to add Cast video track to media stream."; | 882 LOG(ERROR) << "Failed to add Cast video track to media stream."; |
| 885 } | 883 } |
| 886 } | 884 } |
| 887 | 885 |
| 888 } // namespace extensions | 886 } // namespace extensions |
| OLD | NEW |