OLD | NEW |
---|---|
1 // Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_TRANSPORT_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_ |
7 | 7 |
8 #include <list> | |
9 | |
8 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
9 #include "ppapi/c/pp_instance.h" | 11 #include "ppapi/c/dev/ppb_transport_dev.h" |
10 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | 12 #include "third_party/libjingle/source/talk/base/sigslot.h" |
13 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" | |
11 #include "webkit/glue/plugins/pepper_resource.h" | 14 #include "webkit/glue/plugins/pepper_resource.h" |
12 | 15 |
13 struct PPB_Transport_Dev; | 16 namespace talk_base { |
17 class NetworkManager; | |
18 } | |
19 | |
20 namespace cricket { | |
21 class HttpPortAllocator; | |
22 class P2PTransportChannel; | |
23 class TransportChannel; | |
24 class TransportChannelImpl; | |
25 } | |
14 | 26 |
15 namespace pepper { | 27 namespace pepper { |
brettw
2010/12/21 21:55:50
Sorry, you'll have to rebase this patch on the lat
| |
16 | 28 |
17 class Transport : public Resource { | 29 class Transport : public Resource, public sigslot::has_slots<> { |
18 public: | 30 public: |
31 static const PPB_Transport_Dev* GetInterface(); | |
32 | |
19 explicit Transport(PluginModule* module); | 33 explicit Transport(PluginModule* module); |
20 virtual ~Transport(); | 34 virtual ~Transport(); |
21 static const PPB_Transport_Dev* GetInterface(); | 35 |
36 bool Init(const char* name, const char* proto); | |
37 | |
38 // Resource override. | |
22 virtual Transport* AsTransport() { | 39 virtual Transport* AsTransport() { |
23 return this; | 40 return this; |
24 } | 41 } |
25 bool Init(const char* name, | 42 |
26 const char* proto); | 43 bool IsWritable() const; |
44 int32_t Connect(PP_CompletionCallback cb); | |
45 int32_t GetNextAddress(PP_Var* address, PP_CompletionCallback cb); | |
46 int32_t ReceiveRemoteAddress(PP_Var address); | |
47 int32_t Recv(void* data, uint32_t len, PP_CompletionCallback cb); | |
48 int32_t Send(const void* data, size_t len, PP_CompletionCallback cb); | |
49 int32_t Close(); | |
50 | |
27 private: | 51 private: |
52 struct CompletionContext { | |
53 explicit CompletionContext(PP_CompletionCallback cb) { | |
brettw
2010/12/21 21:55:50
Can you unify this with the stuff in webkit/plugin
| |
54 callback = cb; | |
55 } | |
56 void Callback(int32_t result) { | |
57 PP_RunCompletionCallback(&callback, result); | |
58 } | |
59 PP_CompletionCallback callback; | |
60 }; | |
61 typedef CompletionContext ConnectContext; | |
62 struct GetNextAddressContext : CompletionContext { | |
63 GetNextAddressContext(PP_Var* a, PP_CompletionCallback cb) | |
64 : CompletionContext(cb), address(a) { | |
65 } | |
66 PP_Var* address; | |
67 }; | |
68 struct RecvContext : CompletionContext { | |
69 RecvContext(void* d, uint32_t l, PP_CompletionCallback cb) | |
70 : CompletionContext(cb), data(d), len(l) { | |
71 } | |
72 void* data; | |
73 uint32_t len; | |
74 }; | |
28 | 75 |
29 DISALLOW_COPY_AND_ASSIGN(Transport); | 76 void OnRequestSignaling(); |
brettw
2010/12/21 21:55:50
Are these functions implementation of some interfa
| |
77 void OnCandidateReady(cricket::TransportChannelImpl*, | |
brettw
2010/12/21 21:55:50
Normally we would name all arguments here.
| |
78 const cricket::Candidate& candidate); | |
79 void OnWriteableState(cricket::TransportChannel*); | |
80 void OnReadPacket(cricket::TransportChannel*, const char*, size_t); | |
81 | |
82 bool Serialize(const cricket::Candidate& candidate, PP_Var* address); | |
83 bool Deserialize(PP_Var address, cricket::Candidate* candidate); | |
84 | |
85 scoped_ptr<talk_base::NetworkManager> network_manager_; | |
86 scoped_ptr<cricket::HttpPortAllocator> allocator_; | |
87 scoped_ptr<cricket::P2PTransportChannel> channel_; | |
88 std::list<cricket::Candidate> local_candidates_; | |
brettw
2010/12/21 21:55:50
Can you provide documentation for this member?
Th
| |
89 scoped_ptr<ConnectContext> connect_cx_; | |
90 scoped_ptr<GetNextAddressContext> next_address_cx_; | |
91 scoped_ptr<RecvContext> recv_cx_; | |
30 }; | 92 }; |
31 | 93 |
32 } // namespace pepper | 94 } // namespace pepper |
33 | 95 |
34 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_ | 96 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_ |
35 | |
OLD | NEW |