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 const void* target_interface) { | 41 return new PPP_Messaging_Proxy(dispatcher); |
42 return new PPP_Messaging_Proxy(dispatcher, target_interface); | |
43 } | 42 } |
44 | 43 |
45 } // namespace | 44 } // namespace |
46 | 45 |
47 PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher, | 46 PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher) |
48 const void* target_interface) | 47 : InterfaceProxy(dispatcher), |
49 : InterfaceProxy(dispatcher, target_interface) { | 48 ppp_messaging_impl_(NULL) { |
| 49 if (dispatcher->IsPlugin()) { |
| 50 ppp_messaging_impl_ = static_cast<const PPP_Messaging*>( |
| 51 dispatcher->local_get_interface()(PPP_MESSAGING_INTERFACE)); |
| 52 } |
50 } | 53 } |
51 | 54 |
52 PPP_Messaging_Proxy::~PPP_Messaging_Proxy() { | 55 PPP_Messaging_Proxy::~PPP_Messaging_Proxy() { |
53 } | 56 } |
54 | 57 |
55 // static | 58 // static |
56 const InterfaceProxy::Info* PPP_Messaging_Proxy::GetInfo() { | 59 const InterfaceProxy::Info* PPP_Messaging_Proxy::GetInfo() { |
57 static const Info info = { | 60 static const Info info = { |
58 &messaging_interface, | 61 &messaging_interface, |
59 PPP_MESSAGING_INTERFACE, | 62 PPP_MESSAGING_INTERFACE, |
(...skipping 13 matching lines...) Expand all Loading... |
73 IPC_END_MESSAGE_MAP() | 76 IPC_END_MESSAGE_MAP() |
74 return handled; | 77 return handled; |
75 } | 78 } |
76 | 79 |
77 void PPP_Messaging_Proxy::OnMsgHandleMessage( | 80 void PPP_Messaging_Proxy::OnMsgHandleMessage( |
78 PP_Instance instance, SerializedVarReceiveInput message_data) { | 81 PP_Instance instance, SerializedVarReceiveInput message_data) { |
79 PP_Var received_var(message_data.Get(dispatcher())); | 82 PP_Var received_var(message_data.Get(dispatcher())); |
80 // SerializedVarReceiveInput will decrement the reference count, but we want | 83 // SerializedVarReceiveInput will decrement the reference count, but we want |
81 // to give the recipient a reference. | 84 // to give the recipient a reference. |
82 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(received_var); | 85 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(received_var); |
83 ppp_messaging_target()->HandleMessage(instance, received_var); | 86 ppp_messaging_impl_->HandleMessage(instance, received_var); |
84 } | 87 } |
85 | 88 |
86 } // namespace proxy | 89 } // namespace proxy |
87 } // namespace ppapi | 90 } // namespace ppapi |
OLD | NEW |