Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / ppapi_plugin / ppapi_webkitplatformsupport_impl.cc
index 049fe20..bdaf47d 100644 (file)
@@ -8,11 +8,12 @@
 
 #include "base/logging.h"
 #include "base/strings/string16.h"
-#include "base/synchronization/lock.h"
+#include "base/threading/platform_thread.h"
 #include "build/build_config.h"
 #include "content/child/child_thread.h"
 #include "content/common/child_process_messages.h"
 #include "ppapi/proxy/plugin_globals.h"
+#include "ppapi/shared_impl/proxy_lock.h"
 #include "third_party/WebKit/public/platform/WebString.h"
 
 #if defined(OS_WIN)
 #include "third_party/icu/source/common/unicode/utf16.h"
 #endif
 
-using WebKit::WebSandboxSupport;
-using WebKit::WebString;
-using WebKit::WebUChar;
-using WebKit::WebUChar32;
+using blink::WebSandboxSupport;
+using blink::WebString;
+using blink::WebUChar;
+using blink::WebUChar32;
 
 typedef struct CGFont* CGFontRef;
 
@@ -50,19 +51,21 @@ class PpapiWebKitPlatformSupportImpl::SandboxSupport
 #elif defined(OS_ANDROID)
   // Empty class.
 #elif defined(OS_POSIX)
+  SandboxSupport();
   virtual void getFontFamilyForCharacter(
       WebUChar32 character,
       const char* preferred_locale,
-      WebKit::WebFontFamily* family);
+      blink::WebFontFamily* family);
   virtual void getRenderStyleForStrike(
-      const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
+      const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out);
 
  private:
   // WebKit likes to ask us for the correct font family to use for a set of
   // unicode code points. It needs this information frequently so we cache it
   // here.
-  base::Lock unicode_font_families_mutex_;
-  std::map<int32_t, WebKit::WebFontFamily> unicode_font_families_;
+  std::map<int32_t, blink::WebFontFamily> unicode_font_families_;
+  // For debugging crbug.com/312965
+  base::PlatformThreadId creation_thread_;
 #endif
 };
 
@@ -98,13 +101,19 @@ bool PpapiWebKitPlatformSupportImpl::SandboxSupport::loadFont(
 
 #elif defined(OS_POSIX)
 
+PpapiWebKitPlatformSupportImpl::SandboxSupport::SandboxSupport()
+    : creation_thread_(base::PlatformThread::CurrentId()) {
+}
+
 void
 PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter(
     WebUChar32 character,
     const char* preferred_locale,
-    WebKit::WebFontFamily* family) {
-  base::AutoLock lock(unicode_font_families_mutex_);
-  const std::map<int32_t, WebKit::WebFontFamily>::const_iterator iter =
+    blink::WebFontFamily* family) {
+  ppapi::ProxyLock::AssertAcquired();
+  // For debugging crbug.com/312965
+  CHECK_EQ(creation_thread_, base::PlatformThread::CurrentId());
+  const std::map<int32_t, blink::WebFontFamily>::const_iterator iter =
       unicode_font_families_.find(character);
   if (iter != unicode_font_families_.end()) {
     family->name = iter->second.name;
@@ -118,7 +127,7 @@ PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter(
 }
 
 void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike(
-    const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) {
+    const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out) {
   GetRenderStyleForStrike(family, sizeAndStyle, out);
 }
 
@@ -131,22 +140,29 @@ PpapiWebKitPlatformSupportImpl::PpapiWebKitPlatformSupportImpl()
 PpapiWebKitPlatformSupportImpl::~PpapiWebKitPlatformSupportImpl() {
 }
 
-WebKit::WebClipboard* PpapiWebKitPlatformSupportImpl::clipboard() {
+void PpapiWebKitPlatformSupportImpl::Shutdown() {
+  // SandboxSupport contains a map of WebFontFamily objects, which hold
+  // WebCStrings, which become invalidated when blink is shut down. Hence, we
+  // need to clear that map now, just before blink::shutdown() is called.
+  sandbox_support_.reset();
+}
+
+blink::WebClipboard* PpapiWebKitPlatformSupportImpl::clipboard() {
   NOTREACHED();
   return NULL;
 }
 
-WebKit::WebMimeRegistry* PpapiWebKitPlatformSupportImpl::mimeRegistry() {
+blink::WebMimeRegistry* PpapiWebKitPlatformSupportImpl::mimeRegistry() {
   NOTREACHED();
   return NULL;
 }
 
-WebKit::WebFileUtilities* PpapiWebKitPlatformSupportImpl::fileUtilities() {
+blink::WebFileUtilities* PpapiWebKitPlatformSupportImpl::fileUtilities() {
   NOTREACHED();
   return NULL;
 }
 
-WebKit::WebSandboxSupport* PpapiWebKitPlatformSupportImpl::sandboxSupport() {
+blink::WebSandboxSupport* PpapiWebKitPlatformSupportImpl::sandboxSupport() {
   return sandbox_support_.get();
 }
 
@@ -167,72 +183,74 @@ bool PpapiWebKitPlatformSupportImpl::isLinkVisited(
   return false;
 }
 
-WebKit::WebMessagePortChannel*
-PpapiWebKitPlatformSupportImpl::createMessagePortChannel() {
+void PpapiWebKitPlatformSupportImpl::createMessageChannel(
+    blink::WebMessagePortChannel** channel1,
+    blink::WebMessagePortChannel** channel2) {
   NOTREACHED();
-  return NULL;
+  *channel1 = NULL;
+  *channel2 = NULL;
 }
 
 void PpapiWebKitPlatformSupportImpl::setCookies(
-    const WebKit::WebURL& url,
-    const WebKit::WebURL& first_party_for_cookies,
-    const WebKit::WebString& value) {
+    const blink::WebURL& url,
+    const blink::WebURL& first_party_for_cookies,
+    const blink::WebString& value) {
   NOTREACHED();
 }
 
-WebKit::WebString PpapiWebKitPlatformSupportImpl::cookies(
-    const WebKit::WebURL& url,
-    const WebKit::WebURL& first_party_for_cookies) {
+blink::WebString PpapiWebKitPlatformSupportImpl::cookies(
+    const blink::WebURL& url,
+    const blink::WebURL& first_party_for_cookies) {
   NOTREACHED();
-  return WebKit::WebString();
+  return blink::WebString();
 }
 
-WebKit::WebString PpapiWebKitPlatformSupportImpl::defaultLocale() {
+blink::WebString PpapiWebKitPlatformSupportImpl::defaultLocale() {
   NOTREACHED();
-  return WebKit::WebString();
+  return blink::WebString();
 }
 
-WebKit::WebThemeEngine* PpapiWebKitPlatformSupportImpl::themeEngine() {
+blink::WebThemeEngine* PpapiWebKitPlatformSupportImpl::themeEngine() {
   NOTREACHED();
   return NULL;
 }
 
-WebKit::WebURLLoader* PpapiWebKitPlatformSupportImpl::createURLLoader() {
+blink::WebURLLoader* PpapiWebKitPlatformSupportImpl::createURLLoader() {
   NOTREACHED();
   return NULL;
 }
 
-WebKit::WebSocketStreamHandle*
+blink::WebSocketStreamHandle*
     PpapiWebKitPlatformSupportImpl::createSocketStreamHandle() {
   NOTREACHED();
   return NULL;
 }
 
 void PpapiWebKitPlatformSupportImpl::getPluginList(bool refresh,
-    WebKit::WebPluginListBuilder* builder) {
+    blink::WebPluginListBuilder* builder) {
   NOTREACHED();
 }
 
-WebKit::WebData PpapiWebKitPlatformSupportImpl::loadResource(const char* name) {
+blink::WebData PpapiWebKitPlatformSupportImpl::loadResource(const char* name) {
   NOTREACHED();
-  return WebKit::WebData();
+  return blink::WebData();
 }
 
-WebKit::WebStorageNamespace*
+blink::WebStorageNamespace*
 PpapiWebKitPlatformSupportImpl::createLocalStorageNamespace() {
   NOTREACHED();
   return 0;
 }
 
 void PpapiWebKitPlatformSupportImpl::dispatchStorageEvent(
-    const WebKit::WebString& key, const WebKit::WebString& old_value,
-    const WebKit::WebString& new_value, const WebKit::WebString& origin,
-    const WebKit::WebURL& url, bool is_local_storage) {
+    const blink::WebString& key, const blink::WebString& old_value,
+    const blink::WebString& new_value, const blink::WebString& origin,
+    const blink::WebURL& url, bool is_local_storage) {
   NOTREACHED();
 }
 
 int PpapiWebKitPlatformSupportImpl::databaseDeleteFile(
-    const WebKit::WebString& vfs_file_name, bool sync_dir) {
+    const blink::WebString& vfs_file_name, bool sync_dir) {
   NOTREACHED();
   return 0;
 }