OLD | NEW |
1 // Copyright (c) 2011 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 #include "ppapi/proxy/ppp_messaging_proxy.h" | 5 #include "ppapi/proxy/ppp_messaging_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ppapi/c/ppp_messaging.h" | 9 #include "ppapi/c/ppp_messaging.h" |
10 #include "ppapi/proxy/host_dispatcher.h" | 10 #include "ppapi/proxy/host_dispatcher.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 dispatcher->Send(new PpapiMsg_PPPMessaging_HandleMessage( | 30 dispatcher->Send(new PpapiMsg_PPPMessaging_HandleMessage( |
31 INTERFACE_ID_PPP_MESSAGING, | 31 INTERFACE_ID_PPP_MESSAGING, |
32 instance, | 32 instance, |
33 SerializedVarSendInput(dispatcher, message_data))); | 33 SerializedVarSendInput(dispatcher, message_data))); |
34 } | 34 } |
35 | 35 |
36 static const PPP_Messaging messaging_interface = { | 36 static const PPP_Messaging messaging_interface = { |
37 &HandleMessage | 37 &HandleMessage |
38 }; | 38 }; |
39 | 39 |
40 InterfaceProxy* CreateMessagingProxy(Dispatcher* dispatcher) { | 40 InterfaceProxy* CreateMessagingProxy(Dispatcher* dispatcher, |
41 return new PPP_Messaging_Proxy(dispatcher); | 41 const void* target_interface) { |
| 42 return new PPP_Messaging_Proxy(dispatcher, target_interface); |
42 } | 43 } |
43 | 44 |
44 } // namespace | 45 } // namespace |
45 | 46 |
46 PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher) | 47 PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher, |
47 : InterfaceProxy(dispatcher), | 48 const void* target_interface) |
48 ppp_messaging_impl_(NULL) { | 49 : InterfaceProxy(dispatcher, target_interface) { |
49 if (dispatcher->IsPlugin()) { | |
50 ppp_messaging_impl_ = static_cast<const PPP_Messaging*>( | |
51 dispatcher->local_get_interface()(PPP_MESSAGING_INTERFACE)); | |
52 } | |
53 } | 50 } |
54 | 51 |
55 PPP_Messaging_Proxy::~PPP_Messaging_Proxy() { | 52 PPP_Messaging_Proxy::~PPP_Messaging_Proxy() { |
56 } | 53 } |
57 | 54 |
58 // static | 55 // static |
59 const InterfaceProxy::Info* PPP_Messaging_Proxy::GetInfo() { | 56 const InterfaceProxy::Info* PPP_Messaging_Proxy::GetInfo() { |
60 static const Info info = { | 57 static const Info info = { |
61 &messaging_interface, | 58 &messaging_interface, |
62 PPP_MESSAGING_INTERFACE, | 59 PPP_MESSAGING_INTERFACE, |
(...skipping 13 matching lines...) Expand all Loading... |
76 IPC_END_MESSAGE_MAP() | 73 IPC_END_MESSAGE_MAP() |
77 return handled; | 74 return handled; |
78 } | 75 } |
79 | 76 |
80 void PPP_Messaging_Proxy::OnMsgHandleMessage( | 77 void PPP_Messaging_Proxy::OnMsgHandleMessage( |
81 PP_Instance instance, SerializedVarReceiveInput message_data) { | 78 PP_Instance instance, SerializedVarReceiveInput message_data) { |
82 PP_Var received_var(message_data.Get(dispatcher())); | 79 PP_Var received_var(message_data.Get(dispatcher())); |
83 // SerializedVarReceiveInput will decrement the reference count, but we want | 80 // SerializedVarReceiveInput will decrement the reference count, but we want |
84 // to give the recipient a reference. | 81 // to give the recipient a reference. |
85 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(received_var); | 82 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(received_var); |
86 ppp_messaging_impl_->HandleMessage(instance, received_var); | 83 ppp_messaging_target()->HandleMessage(instance, received_var); |
87 } | 84 } |
88 | 85 |
89 } // namespace proxy | 86 } // namespace proxy |
90 } // namespace ppapi | 87 } // namespace ppapi |
OLD | NEW |