OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "ppapi/c/pp_instance.h" | 10 #include "ppapi/c/dev/ppb_transport_dev.h" |
11 #include "webkit/plugins/ppapi/plugin_delegate.h" | 11 #include "third_party/libjingle/source/talk/base/sigslot.h" |
| 12 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" |
| 13 #include "webkit/plugins/ppapi/callbacks.h" |
12 #include "webkit/plugins/ppapi/resource.h" | 14 #include "webkit/plugins/ppapi/resource.h" |
13 | 15 |
14 struct PPB_Transport_Dev; | 16 namespace talk_base { |
| 17 class NetworkManager; |
| 18 } // namespace talk_base |
| 19 |
| 20 namespace cricket { |
| 21 class HttpPortAllocator; |
| 22 class P2PTransportChannel; |
| 23 class TransportChannel; |
| 24 class TransportChannelImpl; |
| 25 } // namespace cricket |
15 | 26 |
16 namespace webkit { | 27 namespace webkit { |
17 namespace ppapi { | 28 namespace ppapi { |
18 | 29 |
19 class PPB_Transport_Impl : public Resource { | 30 class PPB_Transport_Impl : public Resource, public sigslot::has_slots<> { |
20 public: | 31 public: |
| 32 static const PPB_Transport_Dev* GetInterface(); |
| 33 |
21 explicit PPB_Transport_Impl(PluginInstance* instance); | 34 explicit PPB_Transport_Impl(PluginInstance* instance); |
22 virtual ~PPB_Transport_Impl(); | 35 virtual ~PPB_Transport_Impl(); |
23 | 36 |
24 static const PPB_Transport_Dev* GetInterface(); | 37 bool Init(const char* name, const char* proto); |
| 38 |
| 39 // Resource override. |
25 virtual PPB_Transport_Impl* AsPPB_Transport_Impl(); | 40 virtual PPB_Transport_Impl* AsPPB_Transport_Impl(); |
26 | 41 |
27 bool Init(const char* name, | 42 bool IsWritable() const; |
28 const char* proto); | 43 int32_t Connect(PP_CompletionCallback cb); |
| 44 int32_t GetNextAddress(PP_Var* address, PP_CompletionCallback cb); |
| 45 int32_t ReceiveRemoteAddress(PP_Var address); |
| 46 int32_t Recv(void* data, uint32_t len, PP_CompletionCallback cb); |
| 47 int32_t Send(const void* data, uint32_t len, PP_CompletionCallback cb); |
| 48 int32_t Close(); |
29 | 49 |
30 private: | 50 private: |
| 51 void OnRequestSignaling(); |
| 52 void OnCandidateReady(cricket::TransportChannelImpl* channel, |
| 53 const cricket::Candidate& candidate); |
| 54 void OnWriteableState(cricket::TransportChannel*); |
| 55 void OnReadPacket(cricket::TransportChannel*, const char*, size_t); |
| 56 |
| 57 bool Serialize(const cricket::Candidate& candidate, PP_Var* address); |
| 58 bool Deserialize(PP_Var address, cricket::Candidate* candidate); |
| 59 |
| 60 scoped_ptr<talk_base::NetworkManager> network_manager_; |
| 61 scoped_ptr<cricket::HttpPortAllocator> allocator_; |
| 62 scoped_ptr<cricket::P2PTransportChannel> channel_; |
| 63 std::list<cricket::Candidate> local_candidates_; |
| 64 |
| 65 scoped_refptr<TrackedCompletionCallback> connect_callback_; |
| 66 |
| 67 scoped_refptr<TrackedCompletionCallback> next_address_callback_; |
| 68 |
| 69 scoped_refptr<TrackedCompletionCallback> recv_callback_; |
| 70 void* recv_buffer_; |
| 71 uint32_t recv_buffer_size_; |
| 72 |
31 DISALLOW_COPY_AND_ASSIGN(PPB_Transport_Impl); | 73 DISALLOW_COPY_AND_ASSIGN(PPB_Transport_Impl); |
32 }; | 74 }; |
33 | 75 |
34 } // namespace ppapi | 76 } // namespace ppapi |
35 } // namespace webkit | 77 } // namespace webkit |
36 | 78 |
37 #endif // WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ | 79 #endif // WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ |
38 | |
OLD | NEW |