| 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_font_proxy.h" | 5 #include "ppapi/proxy/ppb_font_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "ppapi/c/dev/ppb_font_dev.h" | 9 #include "ppapi/c/dev/ppb_font_dev.h" |
| 10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/proxy/ppb_image_data_proxy.h" | 12 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 13 #include "ppapi/proxy/serialized_var.h" | 13 #include "ppapi/proxy/serialized_var.h" |
| 14 #include "ppapi/shared_impl/ppapi_preferences.h" | 14 #include "ppapi/shared_impl/ppapi_preferences.h" |
| 15 #include "ppapi/shared_impl/resource_object_base.h" | 15 #include "ppapi/shared_impl/resource.h" |
| 16 #include "ppapi/shared_impl/var.h" | 16 #include "ppapi/shared_impl/var.h" |
| 17 #include "ppapi/thunk/enter.h" | 17 #include "ppapi/thunk/enter.h" |
| 18 #include "ppapi/thunk/ppb_image_data_api.h" | 18 #include "ppapi/thunk/ppb_image_data_api.h" |
| 19 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
| 20 | 20 |
| 21 using ppapi::HostResource; | 21 using ppapi::HostResource; |
| 22 using ppapi::Resource; |
| 22 using ppapi::StringVar; | 23 using ppapi::StringVar; |
| 23 using ppapi::thunk::EnterResourceNoLock; | 24 using ppapi::thunk::EnterResourceNoLock; |
| 24 using ppapi::thunk::PPB_ImageData_API; | 25 using ppapi::thunk::PPB_ImageData_API; |
| 25 using ppapi::WebKitForwarding; | 26 using ppapi::WebKitForwarding; |
| 26 | 27 |
| 27 namespace pp { | 28 namespace pp { |
| 28 namespace proxy { | 29 namespace proxy { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 89 } |
| 89 | 90 |
| 90 bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) { | 91 bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 91 // There aren't any font messages. | 92 // There aren't any font messages. |
| 92 NOTREACHED(); | 93 NOTREACHED(); |
| 93 return false; | 94 return false; |
| 94 } | 95 } |
| 95 | 96 |
| 96 Font::Font(const HostResource& resource, | 97 Font::Font(const HostResource& resource, |
| 97 const PP_FontDescription_Dev& desc) | 98 const PP_FontDescription_Dev& desc) |
| 98 : PluginResource(resource), | 99 : Resource(resource), |
| 99 webkit_event_(false, false) { | 100 webkit_event_(false, false) { |
| 100 TRACE_EVENT0("ppapi proxy", "Font::Font"); | 101 TRACE_EVENT0("ppapi proxy", "Font::Font"); |
| 101 scoped_refptr<StringVar> face(StringVar::FromPPVar(desc.face)); | 102 scoped_refptr<StringVar> face(StringVar::FromPPVar(desc.face)); |
| 102 | 103 |
| 103 WebKitForwarding* forwarding = GetDispatcher()->GetWebKitForwarding(); | 104 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); |
| 105 WebKitForwarding* forwarding = dispatcher->GetWebKitForwarding(); |
| 104 | 106 |
| 105 RunOnWebKitThread(true, | 107 RunOnWebKitThread(true, |
| 106 base::Bind(&WebKitForwarding::CreateFontForwarding, | 108 base::Bind(&WebKitForwarding::CreateFontForwarding, |
| 107 base::Unretained(forwarding), | 109 base::Unretained(forwarding), |
| 108 &webkit_event_, desc, | 110 &webkit_event_, desc, |
| 109 face.get() ? face->value() : std::string(), | 111 face.get() ? face->value() : std::string(), |
| 110 GetDispatcher()->preferences(), | 112 dispatcher->preferences(), |
| 111 &font_forwarding_)); | 113 &font_forwarding_)); |
| 112 } | 114 } |
| 113 | 115 |
| 114 Font::~Font() { | 116 Font::~Font() { |
| 115 RunOnWebKitThread(false, base::Bind(&DeleteFontForwarding, font_forwarding_)); | 117 RunOnWebKitThread(false, base::Bind(&DeleteFontForwarding, font_forwarding_)); |
| 116 } | 118 } |
| 117 | 119 |
| 118 ppapi::thunk::PPB_Font_API* Font::AsPPB_Font_API() { | 120 ppapi::thunk::PPB_Font_API* Font::AsPPB_Font_API() { |
| 119 return this; | 121 return this; |
| 120 } | 122 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return -1; | 216 return -1; |
| 215 int32_t result = -1; | 217 int32_t result = -1; |
| 216 RunOnWebKitThread(true, | 218 RunOnWebKitThread(true, |
| 217 base::Bind(&WebKitForwarding::Font::PixelOffsetForCharacter, | 219 base::Bind(&WebKitForwarding::Font::PixelOffsetForCharacter, |
| 218 base::Unretained(font_forwarding_), | 220 base::Unretained(font_forwarding_), |
| 219 &webkit_event_, run, char_offset, &result)); | 221 &webkit_event_, run, char_offset, &result)); |
| 220 return result; | 222 return result; |
| 221 } | 223 } |
| 222 | 224 |
| 223 void Font::RunOnWebKitThread(bool blocking, const base::Closure& task) { | 225 void Font::RunOnWebKitThread(bool blocking, const base::Closure& task) { |
| 224 GetDispatcher()->PostToWebKitThread(FROM_HERE, task); | 226 PluginDispatcher::GetForResource(this)->PostToWebKitThread(FROM_HERE, task); |
| 225 if (blocking) | 227 if (blocking) |
| 226 webkit_event_.Wait(); | 228 webkit_event_.Wait(); |
| 227 } | 229 } |
| 228 | 230 |
| 229 // static | 231 // static |
| 230 void Font::DeleteFontForwarding( | 232 void Font::DeleteFontForwarding( |
| 231 ppapi::WebKitForwarding::Font* font_forwarding) { | 233 ppapi::WebKitForwarding::Font* font_forwarding) { |
| 232 delete font_forwarding; | 234 delete font_forwarding; |
| 233 } | 235 } |
| 234 | 236 |
| 235 } // namespace proxy | 237 } // namespace proxy |
| 236 } // namespace pp | 238 } // namespace pp |
| OLD | NEW |