Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/renderer/extensions/webrtc_native_handler.h

Issue 83043005: Cast Extensions API: Factory method for creating a cast session (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed scope Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_
6 #define CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_ 6 #define CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/memory/weak_ptr.h"
11 #include "chrome/renderer/extensions/object_backed_native_handler.h" 12 #include "chrome/renderer/extensions/object_backed_native_handler.h"
13 #include "chrome/renderer/extensions/scoped_persistent.h"
12 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
13 15
14 class CastSendTransport; 16 class CastSendTransport;
15 class CastUdpTransport; 17 class CastUdpTransport;
16 18
17 namespace extensions { 19 namespace extensions {
18 20
19 class ChromeV8Context; 21 class ChromeV8Context;
20 22
21 // Native code that handle chrome.webrtc custom bindings. 23 // Native code that handle chrome.webrtc custom bindings.
22 class WebRtcNativeHandler : public ObjectBackedNativeHandler { 24 class WebRtcNativeHandler : public ObjectBackedNativeHandler {
23 public: 25 public:
24 explicit WebRtcNativeHandler(ChromeV8Context* context); 26 explicit WebRtcNativeHandler(ChromeV8Context* context);
25 virtual ~WebRtcNativeHandler(); 27 virtual ~WebRtcNativeHandler();
26 28
27 private: 29 private:
28 void CreateCastSendTransport( 30 void CreateCastSession(
29 const v8::FunctionCallbackInfo<v8::Value>& args); 31 const v8::FunctionCallbackInfo<v8::Value>& args);
32
30 void DestroyCastSendTransport( 33 void DestroyCastSendTransport(
31 const v8::FunctionCallbackInfo<v8::Value>& args); 34 const v8::FunctionCallbackInfo<v8::Value>& args);
32 void CreateParamsCastSendTransport( 35 void CreateParamsCastSendTransport(
33 const v8::FunctionCallbackInfo<v8::Value>& args); 36 const v8::FunctionCallbackInfo<v8::Value>& args);
34 void GetCapsCastSendTransport( 37 void GetCapsCastSendTransport(
35 const v8::FunctionCallbackInfo<v8::Value>& args); 38 const v8::FunctionCallbackInfo<v8::Value>& args);
36 void StartCastSendTransport( 39 void StartCastSendTransport(
37 const v8::FunctionCallbackInfo<v8::Value>& args); 40 const v8::FunctionCallbackInfo<v8::Value>& args);
38 void StopCastSendTransport( 41 void StopCastSendTransport(
39 const v8::FunctionCallbackInfo<v8::Value>& args); 42 const v8::FunctionCallbackInfo<v8::Value>& args);
40 43
41 void CreateCastUdpTransport(
42 const v8::FunctionCallbackInfo<v8::Value>& args);
43 void DestroyCastUdpTransport( 44 void DestroyCastUdpTransport(
44 const v8::FunctionCallbackInfo<v8::Value>& args); 45 const v8::FunctionCallbackInfo<v8::Value>& args);
45 void StartCastUdpTransport( 46 void StartCastUdpTransport(
46 const v8::FunctionCallbackInfo<v8::Value>& args); 47 const v8::FunctionCallbackInfo<v8::Value>& args);
47 void StopCastUdpTransport( 48 void StopCastUdpTransport(
48 const v8::FunctionCallbackInfo<v8::Value>& args); 49 const v8::FunctionCallbackInfo<v8::Value>& args);
49 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
50 // Gets the Send or UDP transport indexed by |transport_id|. 57 // Gets the Send or UDP transport indexed by |transport_id|.
51 // If not found, returns NULL and throws a V8 exception. 58 // If not found, returns NULL and throws a V8 exception.
52 CastSendTransport* GetSendTransportOrThrow(int transport_id) const; 59 CastSendTransport* GetSendTransportOrThrow(int transport_id) const;
53 CastUdpTransport* GetUdpTransportOrThrow(int transport_id) const; 60 CastUdpTransport* GetUdpTransportOrThrow(int transport_id) const;
54 61
55 int last_transport_id_; 62 int last_transport_id_;
56 63
57 typedef std::map<int, linked_ptr<CastSendTransport> > SendTransportMap; 64 typedef std::map<int, linked_ptr<CastSendTransport> > SendTransportMap;
58 SendTransportMap send_transport_map_; 65 SendTransportMap send_transport_map_;
59 66
60 typedef std::map<int, linked_ptr<CastUdpTransport> > UdpTransportMap; 67 typedef std::map<int, linked_ptr<CastUdpTransport> > UdpTransportMap;
61 UdpTransportMap udp_transport_map_; 68 UdpTransportMap udp_transport_map_;
62 69
70 base::WeakPtrFactory<WebRtcNativeHandler> weak_factory_;
71
72 extensions::ScopedPersistent<v8::Function> create_callback_;
73
63 DISALLOW_COPY_AND_ASSIGN(WebRtcNativeHandler); 74 DISALLOW_COPY_AND_ASSIGN(WebRtcNativeHandler);
64 }; 75 };
65 76
66 } // namespace extensions 77 } // namespace extensions
67 78
68 #endif // CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_ 79 #endif // CHROME_RENDERER_EXTENSIONS_WEBRTC_NATIVE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/extensions/webrtc_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698