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/ppb_testing_proxy.h" | 5 #include "ppapi/proxy/ppb_testing_proxy.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "ppapi/c/dev/ppb_testing_dev.h" | 8 #include "ppapi/c/dev/ppb_testing_dev.h" |
9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 image_object->pp_instance() != graphics_2d_object->pp_instance()) | 30 image_object->pp_instance() != graphics_2d_object->pp_instance()) |
31 return PP_FALSE; | 31 return PP_FALSE; |
32 | 32 |
33 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | 33 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( |
34 image_object->pp_instance()); | 34 image_object->pp_instance()); |
35 if (!dispatcher) | 35 if (!dispatcher) |
36 return PP_FALSE; | 36 return PP_FALSE; |
37 | 37 |
38 PP_Bool result = PP_FALSE; | 38 PP_Bool result = PP_FALSE; |
39 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( | 39 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( |
40 INTERFACE_ID_PPB_TESTING, graphics_2d_object->host_resource(), | 40 API_ID_PPB_TESTING, graphics_2d_object->host_resource(), |
41 image_object->host_resource(), *top_left, &result)); | 41 image_object->host_resource(), *top_left, &result)); |
42 return result; | 42 return result; |
43 } | 43 } |
44 | 44 |
45 void RunMessageLoop(PP_Instance instance) { | 45 void RunMessageLoop(PP_Instance instance) { |
46 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 46 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
47 MessageLoop::current()->SetNestableTasksAllowed(true); | 47 MessageLoop::current()->SetNestableTasksAllowed(true); |
48 MessageLoop::current()->Run(); | 48 MessageLoop::current()->Run(); |
49 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 49 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
50 } | 50 } |
51 | 51 |
52 void QuitMessageLoop(PP_Instance instance) { | 52 void QuitMessageLoop(PP_Instance instance) { |
53 MessageLoop::current()->QuitNow(); | 53 MessageLoop::current()->QuitNow(); |
54 } | 54 } |
55 | 55 |
56 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { | 56 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { |
57 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 57 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
58 if (!dispatcher) | 58 if (!dispatcher) |
59 return static_cast<uint32_t>(-1); | 59 return static_cast<uint32_t>(-1); |
60 | 60 |
61 uint32_t result = 0; | 61 uint32_t result = 0; |
62 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( | 62 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( |
63 INTERFACE_ID_PPB_TESTING, instance_id, &result)); | 63 API_ID_PPB_TESTING, instance_id, &result)); |
64 return result; | 64 return result; |
65 } | 65 } |
66 | 66 |
67 PP_Bool IsOutOfProcess() { | 67 PP_Bool IsOutOfProcess() { |
68 return PP_TRUE; | 68 return PP_TRUE; |
69 } | 69 } |
70 | 70 |
71 const PPB_Testing_Dev testing_interface = { | 71 const PPB_Testing_Dev testing_interface = { |
72 &ReadImageData, | 72 &ReadImageData, |
73 &RunMessageLoop, | 73 &RunMessageLoop, |
(...skipping 18 matching lines...) Expand all Loading... |
92 } | 92 } |
93 | 93 |
94 PPB_Testing_Proxy::~PPB_Testing_Proxy() { | 94 PPB_Testing_Proxy::~PPB_Testing_Proxy() { |
95 } | 95 } |
96 | 96 |
97 // static | 97 // static |
98 const InterfaceProxy::Info* PPB_Testing_Proxy::GetInfo() { | 98 const InterfaceProxy::Info* PPB_Testing_Proxy::GetInfo() { |
99 static const Info info = { | 99 static const Info info = { |
100 &testing_interface, | 100 &testing_interface, |
101 PPB_TESTING_DEV_INTERFACE, | 101 PPB_TESTING_DEV_INTERFACE, |
102 INTERFACE_ID_PPB_TESTING, | 102 API_ID_PPB_TESTING, |
103 false, | 103 false, |
104 &CreateTestingProxy, | 104 &CreateTestingProxy, |
105 }; | 105 }; |
106 return &info; | 106 return &info; |
107 } | 107 } |
108 | 108 |
109 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { | 109 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { |
110 bool handled = true; | 110 bool handled = true; |
111 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) | 111 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) |
112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, | 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, |
(...skipping 22 matching lines...) Expand all Loading... |
135 ppb_testing_impl_->QuitMessageLoop(instance); | 135 ppb_testing_impl_->QuitMessageLoop(instance); |
136 } | 136 } |
137 | 137 |
138 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, | 138 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, |
139 uint32_t* result) { | 139 uint32_t* result) { |
140 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); | 140 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); |
141 } | 141 } |
142 | 142 |
143 } // namespace proxy | 143 } // namespace proxy |
144 } // namespace ppapi | 144 } // namespace ppapi |
OLD | NEW |