OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dev/ppb_transport_dev.h" | 10 #include "ppapi/c/pp_instance.h" |
11 #include "third_party/libjingle/source/talk/base/sigslot.h" | 11 #include "webkit/plugins/ppapi/plugin_delegate.h" |
12 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" | |
13 #include "webkit/plugins/ppapi/callbacks.h" | |
14 #include "webkit/plugins/ppapi/resource.h" | 12 #include "webkit/plugins/ppapi/resource.h" |
15 | 13 |
16 namespace talk_base { | 14 struct PPB_Transport_Dev; |
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 | |
26 | 15 |
27 namespace webkit { | 16 namespace webkit { |
28 namespace ppapi { | 17 namespace ppapi { |
29 | 18 |
30 class PPB_Transport_Impl : public Resource, public sigslot::has_slots<> { | 19 class PPB_Transport_Impl : public Resource { |
31 public: | 20 public: |
32 static const PPB_Transport_Dev* GetInterface(); | |
33 | |
34 explicit PPB_Transport_Impl(PluginInstance* instance); | 21 explicit PPB_Transport_Impl(PluginInstance* instance); |
35 virtual ~PPB_Transport_Impl(); | 22 virtual ~PPB_Transport_Impl(); |
36 | 23 |
37 bool Init(const char* name, const char* proto); | 24 static const PPB_Transport_Dev* GetInterface(); |
38 | |
39 // Resource override. | |
40 virtual PPB_Transport_Impl* AsPPB_Transport_Impl(); | 25 virtual PPB_Transport_Impl* AsPPB_Transport_Impl(); |
41 | 26 |
42 bool IsWritable() const; | 27 bool Init(const char* name, |
43 int32_t Connect(PP_CompletionCallback cb); | 28 const char* proto); |
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(); | |
49 | 29 |
50 private: | 30 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 | |
73 DISALLOW_COPY_AND_ASSIGN(PPB_Transport_Impl); | 31 DISALLOW_COPY_AND_ASSIGN(PPB_Transport_Impl); |
74 }; | 32 }; |
75 | 33 |
76 } // namespace ppapi | 34 } // namespace ppapi |
77 } // namespace webkit | 35 } // namespace webkit |
78 | 36 |
79 #endif // WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ | 37 #endif // WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_ |
| 38 |
OLD | NEW |