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