OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_flash_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_proxy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "ppapi/c/dev/ppb_font_dev.h" | 10 #include "ppapi/c/dev/ppb_font_dev.h" |
11 #include "ppapi/c/dev/ppb_var_deprecated.h" | 11 #include "ppapi/c/dev/ppb_var_deprecated.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
14 #include "ppapi/c/private/ppb_flash.h" | 14 #include "ppapi/c/private/ppb_flash.h" |
15 #include "ppapi/proxy/host_dispatcher.h" | 15 #include "ppapi/proxy/host_dispatcher.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/plugin_globals.h" | 17 #include "ppapi/proxy/plugin_globals.h" |
18 #include "ppapi/proxy/plugin_proxy_delegate.h" | 18 #include "ppapi/proxy/plugin_proxy_delegate.h" |
19 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
20 #include "ppapi/proxy/proxy_module.h" | 20 #include "ppapi/proxy/proxy_module.h" |
21 #include "ppapi/proxy/serialized_var.h" | 21 #include "ppapi/proxy/serialized_var.h" |
22 #include "ppapi/shared_impl/ppapi_globals.h" | 22 #include "ppapi/shared_impl/ppapi_globals.h" |
23 #include "ppapi/shared_impl/proxy_lock.h" | |
24 #include "ppapi/shared_impl/resource.h" | 23 #include "ppapi/shared_impl/resource.h" |
25 #include "ppapi/shared_impl/resource_tracker.h" | 24 #include "ppapi/shared_impl/resource_tracker.h" |
26 #include "ppapi/shared_impl/scoped_pp_resource.h" | 25 #include "ppapi/shared_impl/scoped_pp_resource.h" |
27 #include "ppapi/shared_impl/var.h" | 26 #include "ppapi/shared_impl/var.h" |
28 #include "ppapi/thunk/enter.h" | 27 #include "ppapi/thunk/enter.h" |
29 #include "ppapi/thunk/ppb_url_request_info_api.h" | 28 #include "ppapi/thunk/ppb_url_request_info_api.h" |
30 #include "ppapi/thunk/resource_creation_api.h" | 29 #include "ppapi/thunk/resource_creation_api.h" |
31 | 30 |
32 namespace ppapi { | 31 namespace ppapi { |
33 namespace proxy { | 32 namespace proxy { |
34 | 33 |
35 namespace { | 34 namespace { |
36 | 35 |
37 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { | 36 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { |
38 ProxyAutoLock lock; | |
39 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); | 37 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); |
40 if (dispatcher) { | 38 if (dispatcher) { |
41 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( | 39 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( |
42 API_ID_PPB_FLASH, pp_instance, on_top)); | 40 API_ID_PPB_FLASH, pp_instance, on_top)); |
43 } | 41 } |
44 } | 42 } |
45 | 43 |
46 PP_Bool DrawGlyphs(PP_Instance instance, | 44 PP_Bool DrawGlyphs(PP_Instance instance, |
47 PP_Resource pp_image_data, | 45 PP_Resource pp_image_data, |
48 const PP_FontDescription_Dev* font_desc, | 46 const PP_FontDescription_Dev* font_desc, |
49 uint32_t color, | 47 uint32_t color, |
50 const PP_Point* position, | 48 const PP_Point* position, |
51 const PP_Rect* clip, | 49 const PP_Rect* clip, |
52 const float transformation[3][3], | 50 const float transformation[3][3], |
53 PP_Bool allow_subpixel_aa, | 51 PP_Bool allow_subpixel_aa, |
54 uint32_t glyph_count, | 52 uint32_t glyph_count, |
55 const uint16_t glyph_indices[], | 53 const uint16_t glyph_indices[], |
56 const PP_Point glyph_advances[]) { | 54 const PP_Point glyph_advances[]) { |
57 ProxyAutoLock lock; | |
58 Resource* image_data = | 55 Resource* image_data = |
59 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); | 56 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); |
60 if (!image_data) | 57 if (!image_data) |
61 return PP_FALSE; | 58 return PP_FALSE; |
62 // The instance parameter isn't strictly necessary but we check that it | 59 // The instance parameter isn't strictly necessary but we check that it |
63 // matches anyway. | 60 // matches anyway. |
64 if (image_data->pp_instance() != instance) | 61 if (image_data->pp_instance() != instance) |
65 return PP_FALSE; | 62 return PP_FALSE; |
66 | 63 |
67 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | 64 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( |
(...skipping 29 matching lines...) Expand all Loading... |
97 PP_Bool DrawGlyphs11(PP_Instance instance, | 94 PP_Bool DrawGlyphs11(PP_Instance instance, |
98 PP_Resource pp_image_data, | 95 PP_Resource pp_image_data, |
99 const PP_FontDescription_Dev* font_desc, | 96 const PP_FontDescription_Dev* font_desc, |
100 uint32_t color, | 97 uint32_t color, |
101 PP_Point position, | 98 PP_Point position, |
102 PP_Rect clip, | 99 PP_Rect clip, |
103 const float transformation[3][3], | 100 const float transformation[3][3], |
104 uint32_t glyph_count, | 101 uint32_t glyph_count, |
105 const uint16_t glyph_indices[], | 102 const uint16_t glyph_indices[], |
106 const PP_Point glyph_advances[]) { | 103 const PP_Point glyph_advances[]) { |
107 // Backwards-compatible version. DrawGlyphs locks; no need to lock here. | 104 // Backwards-compatible version. |
108 return DrawGlyphs(instance, pp_image_data, font_desc, color, &position, | 105 return DrawGlyphs(instance, pp_image_data, font_desc, color, &position, |
109 &clip, transformation, PP_TRUE, glyph_count, glyph_indices, | 106 &clip, transformation, PP_TRUE, glyph_count, glyph_indices, |
110 glyph_advances); | 107 glyph_advances); |
111 } | 108 } |
112 | 109 |
113 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { | 110 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { |
114 ProxyAutoLock lock; | |
115 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 111 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
116 if (!dispatcher) | 112 if (!dispatcher) |
117 return PP_MakeUndefined(); | 113 return PP_MakeUndefined(); |
118 | 114 |
119 ReceiveSerializedVarReturnValue result; | 115 ReceiveSerializedVarReturnValue result; |
120 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | 116 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( |
121 API_ID_PPB_FLASH, instance, url, &result)); | 117 API_ID_PPB_FLASH, instance, url, &result)); |
122 return result.Return(dispatcher); | 118 return result.Return(dispatcher); |
123 } | 119 } |
124 | 120 |
(...skipping 13 matching lines...) Expand all Loading... |
138 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( | 134 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( |
139 API_ID_PPB_FLASH, | 135 API_ID_PPB_FLASH, |
140 instance, enter.object()->GetData(), target, from_user_action, | 136 instance, enter.object()->GetData(), target, from_user_action, |
141 &result)); | 137 &result)); |
142 return result; | 138 return result; |
143 } | 139 } |
144 | 140 |
145 int32_t Navigate11(PP_Resource request_id, | 141 int32_t Navigate11(PP_Resource request_id, |
146 const char* target, | 142 const char* target, |
147 bool from_user_action) { | 143 bool from_user_action) { |
148 // Backwards-compatible version. Navigate locks; no need to lock here. | 144 // Backwards-compatible version. |
149 return Navigate(request_id, target, PP_FromBool(from_user_action)); | 145 return Navigate(request_id, target, PP_FromBool(from_user_action)); |
150 } | 146 } |
151 | 147 |
152 void RunMessageLoop(PP_Instance instance) { | 148 void RunMessageLoop(PP_Instance instance) { |
153 ProxyAutoLock lock; | |
154 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 149 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
155 if (!dispatcher) | 150 if (!dispatcher) |
156 return; | 151 return; |
157 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( | 152 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( |
158 API_ID_PPB_FLASH, instance); | 153 API_ID_PPB_FLASH, instance); |
159 msg->EnableMessagePumping(); | 154 msg->EnableMessagePumping(); |
160 dispatcher->Send(msg); | 155 dispatcher->Send(msg); |
161 } | 156 } |
162 | 157 |
163 void QuitMessageLoop(PP_Instance instance) { | 158 void QuitMessageLoop(PP_Instance instance) { |
164 ProxyAutoLock lock; | |
165 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 159 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
166 if (!dispatcher) | 160 if (!dispatcher) |
167 return; | 161 return; |
168 dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( | 162 dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( |
169 API_ID_PPB_FLASH, instance)); | 163 API_ID_PPB_FLASH, instance)); |
170 } | 164 } |
171 | 165 |
172 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { | 166 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { |
173 ProxyAutoLock lock; | |
174 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 167 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
175 if (!dispatcher) | 168 if (!dispatcher) |
176 return 0.0; | 169 return 0.0; |
177 | 170 |
178 // TODO(brettw) on Windows it should be possible to do the time calculation | 171 // TODO(brettw) on Windows it should be possible to do the time calculation |
179 // in-process since it doesn't need to read files on disk. This will improve | 172 // in-process since it doesn't need to read files on disk. This will improve |
180 // performance. | 173 // performance. |
181 // | 174 // |
182 // On Linux, it would be better to go directly to the browser process for | 175 // On Linux, it would be better to go directly to the browser process for |
183 // this message rather than proxy it through some instance in a renderer. | 176 // this message rather than proxy it through some instance in a renderer. |
184 double result = 0; | 177 double result = 0; |
185 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( | 178 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( |
186 API_ID_PPB_FLASH, instance, t, &result)); | 179 API_ID_PPB_FLASH, instance, t, &result)); |
187 return result; | 180 return result; |
188 } | 181 } |
189 | 182 |
190 PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) { | 183 PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) { |
191 ProxyAutoLock lock; | |
192 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); | 184 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); |
193 return StringVar::StringToPPVar(args); | 185 return StringVar::StringToPPVar(args); |
194 } | 186 } |
195 | 187 |
196 void PreLoadFontWin(const void* logfontw) { | 188 void PreLoadFontWin(const void* logfontw) { |
197 ProxyAutoLock lock; | |
198 PluginGlobals::Get()->plugin_proxy_delegate()->PreCacheFont(logfontw); | 189 PluginGlobals::Get()->plugin_proxy_delegate()->PreCacheFont(logfontw); |
199 } | 190 } |
200 | 191 |
201 const PPB_Flash_11 flash_interface_11 = { | 192 const PPB_Flash_11 flash_interface_11 = { |
202 &SetInstanceAlwaysOnTop, | 193 &SetInstanceAlwaysOnTop, |
203 &DrawGlyphs11, | 194 &DrawGlyphs11, |
204 &GetProxyForURL, | 195 &GetProxyForURL, |
205 &Navigate11, | 196 &Navigate11, |
206 &RunMessageLoop, | 197 &RunMessageLoop, |
207 &QuitMessageLoop, | 198 &QuitMessageLoop, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 344 } |
354 | 345 |
355 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, | 346 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, |
356 PP_Time t, | 347 PP_Time t, |
357 double* result) { | 348 double* result) { |
358 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); | 349 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); |
359 } | 350 } |
360 | 351 |
361 } // namespace proxy | 352 } // namespace proxy |
362 } // namespace ppapi | 353 } // namespace ppapi |
OLD | NEW |