Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / SharedWorkerRepositoryClientImpl.cpp
index 404288c..468492e 100644 (file)
  */
 
 #include "config.h"
-#include "SharedWorkerRepositoryClientImpl.h"
-
-#include "WebContentSecurityPolicy.h"
-#include "WebFrameClient.h"
-#include "WebFrameImpl.h"
-#include "WebKit.h"
-#include "WebSharedWorker.h"
-#include "WebSharedWorkerRepositoryClient.h"
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ExceptionState.h"
+#include "web/SharedWorkerRepositoryClientImpl.h"
+
+#include "bindings/core/v8/ExceptionMessages.h"
+#include "bindings/core/v8/ExceptionState.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/events/Event.h"
-#include "core/events/ThreadLocalEventNames.h"
-#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
 #include "core/inspector/InspectorInstrumentation.h"
 #include "core/workers/SharedWorker.h"
 #include "core/workers/WorkerScriptLoader.h"
 #include "public/platform/WebMessagePortChannel.h"
 #include "public/platform/WebString.h"
 #include "public/platform/WebURL.h"
-
-using namespace WebCore;
+#include "public/web/WebContentSecurityPolicy.h"
+#include "public/web/WebFrameClient.h"
+#include "public/web/WebKit.h"
+#include "public/web/WebSharedWorker.h"
+#include "public/web/WebSharedWorkerRepositoryClient.h"
+#include "web/WebLocalFrameImpl.h"
 
 namespace blink {
 
 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive while connecting.
 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener {
 public:
-    SharedWorkerConnector(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPtr<WebSharedWorkerConnector> webWorkerConnector)
+    SharedWorkerConnector(PassRefPtrWillBeRawPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPtr<WebSharedWorkerConnector> webWorkerConnector)
         : m_worker(worker)
         , m_url(url)
         , m_name(name)
@@ -75,7 +72,7 @@ private:
     virtual void connected() OVERRIDE;
     virtual void scriptLoadFailed() OVERRIDE;
 
-    RefPtr<SharedWorker> m_worker;
+    RefPtrWillBePersistent<SharedWorker> m_worker;
     KURL m_url;
     String m_name;
     OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector;
@@ -84,11 +81,12 @@ private:
 
 SharedWorkerConnector::~SharedWorkerConnector()
 {
-    m_worker->unsetPreventGC();
+    m_worker->setIsBeingConnected(false);
 }
+
 void SharedWorkerConnector::connect()
 {
-    m_worker->setPreventGC();
+    m_worker->setIsBeingConnected(true);
     m_webWorkerConnector->connect(m_channel.leakPtr(), this);
 }
 
@@ -111,14 +109,14 @@ static WebSharedWorkerRepositoryClient::DocumentID getId(void* document)
     return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(document);
 }
 
-void SharedWorkerRepositoryClientImpl::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const String& name, ExceptionState& exceptionState)
+void SharedWorkerRepositoryClientImpl::connect(PassRefPtrWillBeRawPtr<SharedWorker> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const String& name, ExceptionState& exceptionState)
 {
     ASSERT(m_client);
 
     // No nested workers (for now) - connect() should only be called from document context.
     ASSERT(worker->executionContext()->isDocument());
     Document* document = toDocument(worker->executionContext());
-    OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->createSharedWorkerConnector(url, name, getId(document), worker->executionContext()->contentSecurityPolicy()->deprecatedHeader(), static_cast<blink::WebContentSecurityPolicyType>(worker->executionContext()->contentSecurityPolicy()->deprecatedHeaderType())));
+    OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->createSharedWorkerConnector(url, name, getId(document), worker->executionContext()->contentSecurityPolicy()->deprecatedHeader(), static_cast<WebContentSecurityPolicyType>(worker->executionContext()->contentSecurityPolicy()->deprecatedHeaderType())));
     if (!webWorkerConnector) {
         // Existing worker does not match this url, so return an error back to the caller.
         exceptionState.throwDOMException(URLMismatchError, "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL ('" + url.elidedString() + "').");