| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_ | |
| 6 #define CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/memory/linked_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chrome/renderer/extensions/object_backed_native_handler.h" | |
| 13 #include "chrome/renderer/extensions/scoped_persistent.h" | |
| 14 #include "v8/include/v8.h" | |
| 15 | |
| 16 class CastSendTransport; | |
| 17 class CastUdpTransport; | |
| 18 | |
| 19 namespace extensions { | |
| 20 | |
| 21 class ChromeV8Context; | |
| 22 | |
| 23 // Native code that handle chrome.webrtc custom bindings. | |
| 24 class WebRtcNativeHandler : public ObjectBackedNativeHandler { | |
| 25 public: | |
| 26 explicit WebRtcNativeHandler(ChromeV8Context* context); | |
| 27 virtual ~WebRtcNativeHandler(); | |
| 28 | |
| 29 private: | |
| 30 void CreateCastSession( | |
| 31 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 32 | |
| 33 void DestroyCastSendTransport( | |
| 34 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 35 void CreateParamsCastSendTransport( | |
| 36 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 37 void GetCapsCastSendTransport( | |
| 38 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 39 void StartCastSendTransport( | |
| 40 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 41 void StopCastSendTransport( | |
| 42 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 43 | |
| 44 void DestroyCastUdpTransport( | |
| 45 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 46 void StartCastUdpTransport( | |
| 47 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 48 void StopCastUdpTransport( | |
| 49 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 50 | |
| 51 // Helper method to call the v8 callback function after a session is | |
| 52 // created. | |
| 53 void CallCreateCallback(scoped_ptr<CastSendTransport> stream1, | |
| 54 scoped_ptr<CastSendTransport> stream2, | |
| 55 scoped_ptr<CastUdpTransport> udp_transport); | |
| 56 | |
| 57 // Gets the Send or UDP transport indexed by |transport_id|. | |
| 58 // If not found, returns NULL and throws a V8 exception. | |
| 59 CastSendTransport* GetSendTransportOrThrow(int transport_id) const; | |
| 60 CastUdpTransport* GetUdpTransportOrThrow(int transport_id) const; | |
| 61 | |
| 62 int last_transport_id_; | |
| 63 | |
| 64 typedef std::map<int, linked_ptr<CastSendTransport> > SendTransportMap; | |
| 65 SendTransportMap send_transport_map_; | |
| 66 | |
| 67 typedef std::map<int, linked_ptr<CastUdpTransport> > UdpTransportMap; | |
| 68 UdpTransportMap udp_transport_map_; | |
| 69 | |
| 70 base::WeakPtrFactory<WebRtcNativeHandler> weak_factory_; | |
| 71 | |
| 72 extensions::ScopedPersistent<v8::Function> create_callback_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(WebRtcNativeHandler); | |
| 75 }; | |
| 76 | |
| 77 } // namespace extensions | |
| 78 | |
| 79 #endif // CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_ | |
| OLD | NEW |