Replace WTF::move with WTFMove
[WebKit-https.git] / Source / WebCore / workers / WorkerGlobalScope.cpp
index a599e6f..0020408 100644 (file)
 #include "DOMWindow.h"
 #include "ErrorEvent.h"
 #include "Event.h"
-#include "EventException.h"
 #include "ExceptionCode.h"
 #include "InspectorConsoleInstrumentation.h"
 #include "MessagePort.h"
 #include "ScheduledAction.h"
 #include "ScriptSourceCode.h"
 #include "SecurityOrigin.h"
+#include "SecurityOriginPolicy.h"
 #include "URL.h"
-#include "WorkerInspectorController.h"
 #include "WorkerLocation.h"
 #include "WorkerNavigator.h"
 #include "WorkerObjectProxy.h"
@@ -52,6 +51,7 @@
 #include "WorkerThreadableLoader.h"
 #include "XMLHttpRequestException.h"
 #include <bindings/ScriptValue.h>
+#include <inspector/ConsoleMessage.h>
 #include <inspector/ScriptCallStack.h>
 #include <wtf/RefPtr.h>
 
@@ -63,20 +63,16 @@ using namespace Inspector;
 
 namespace WebCore {
 
-WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, std::unique_ptr<GroupSettings> settings, WorkerThread& thread, PassRefPtr<SecurityOrigin> topOrigin)
+WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, WorkerThread& thread, PassRefPtr<SecurityOrigin> topOrigin)
     : m_url(url)
     , m_userAgent(userAgent)
-    , m_groupSettings(WTF::move(settings))
     , m_script(std::make_unique<WorkerScriptController>(this))
     , m_thread(thread)
-#if ENABLE(INSPECTOR)
-    , m_workerInspectorController(std::make_unique<WorkerInspectorController>(*this))
-#endif
     , m_closing(false)
     , m_eventQueue(*this)
     , m_topOrigin(topOrigin)
 {
-    setSecurityOrigin(SecurityOrigin::create(url));
+    setSecurityOriginPolicy(SecurityOriginPolicy::create(SecurityOrigin::create(url)));
 }
 
 WorkerGlobalScope::~WorkerGlobalScope()
@@ -149,12 +145,12 @@ WorkerNavigator* WorkerGlobalScope::navigator() const
 
 void WorkerGlobalScope::postTask(Task task)
 {
-    thread().runLoop().postTask(WTF::move(task));
+    thread().runLoop().postTask(WTFMove(task));
 }
 
 int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    return DOMTimer::install(*this, WTF::move(action), timeout, true);
+    return DOMTimer::install(*this, WTFMove(action), timeout, true);
 }
 
 void WorkerGlobalScope::clearTimeout(int timeoutId)
@@ -164,7 +160,7 @@ void WorkerGlobalScope::clearTimeout(int timeoutId)
 
 int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    return DOMTimer::install(*this, WTF::move(action), timeout, false);
+    return DOMTimer::install(*this, WTFMove(action), timeout, false);
 }
 
 void WorkerGlobalScope::clearInterval(int timeoutId)
@@ -176,21 +172,19 @@ void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode&
 {
     ASSERT(contentSecurityPolicy());
     ec = 0;
-    Vector<String>::const_iterator urlsEnd = urls.end();
     Vector<URL> completedURLs;
-    for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) {
-        const URL& url = scriptExecutionContext()->completeURL(*it);
+    for (auto& entry : urls) {
+        URL url = scriptExecutionContext()->completeURL(entry);
         if (!url.isValid()) {
             ec = SYNTAX_ERR;
             return;
         }
-        completedURLs.append(url);
+        completedURLs.append(WTFMove(url));
     }
-    Vector<URL>::const_iterator end = completedURLs.end();
 
-    for (Vector<URL>::const_iterator it = completedURLs.begin(); it != end; ++it) {
-        RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create());
-        scriptLoader->loadSynchronously(scriptExecutionContext(), *it, AllowCrossOriginRequests);
+    for (auto& url : completedURLs) {
+        Ref<WorkerScriptLoader> scriptLoader = WorkerScriptLoader::create();
+        scriptLoader->loadSynchronously(scriptExecutionContext(), url, AllowCrossOriginRequests);
 
         // If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps.
         if (scriptLoader->failed()) {
@@ -200,9 +194,9 @@ void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode&
 
         InspectorInstrumentation::scriptImported(scriptExecutionContext(), scriptLoader->identifier(), scriptLoader->script());
 
-        Deprecated::ScriptValue exception;
-        m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), &exception);
-        if (!exception.hasNoValue()) {
+        NakedPtr<JSC::Exception> exception;
+        m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), exception);
+        if (exception) {
             m_script->setException(exception);
             return;
         }
@@ -214,7 +208,7 @@ EventTarget* WorkerGlobalScope::errorEventTarget()
     return this;
 }
 
-void WorkerGlobalScope::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>)
+void WorkerGlobalScope::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<ScriptCallStack>&&)
 {
     thread().workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, columnNumber, sourceURL);
 }
@@ -230,7 +224,7 @@ void WorkerGlobalScope::addConsoleMessage(MessageSource source, MessageLevel lev
     addMessageToWorkerConsole(source, level, message, String(), 0, 0, 0, 0, requestIdentifier);
 }
 
-void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack> callStack, JSC::ExecState* state, unsigned long requestIdentifier)
+void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<ScriptCallStack>&& callStack, JSC::ExecState* state, unsigned long requestIdentifier)
 {
     if (!isContextThread()) {
         postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
@@ -238,16 +232,21 @@ void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, con
     }
 
     thread().workerReportingProxy().postConsoleMessageToWorkerObject(source, level, message, lineNumber, columnNumber, sourceURL);
-    addMessageToWorkerConsole(source, level, message, sourceURL, lineNumber, columnNumber, callStack, state, requestIdentifier);
+    addMessageToWorkerConsole(source, level, message, sourceURL, lineNumber, columnNumber, WTFMove(callStack), state, requestIdentifier);
 }
 
-void WorkerGlobalScope::addMessageToWorkerConsole(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack> callStack, JSC::ExecState* state, unsigned long requestIdentifier)
+void WorkerGlobalScope::addMessageToWorkerConsole(MessageSource source, MessageLevel level, const String& messageText, const String& suggestedURL, unsigned suggestedLineNumber, unsigned suggestedColumnNumber, RefPtr<ScriptCallStack>&& callStack, JSC::ExecState* state, unsigned long requestIdentifier)
 {
     ASSERT(isContextThread());
+
+    std::unique_ptr<Inspector::ConsoleMessage> message;
+
     if (callStack)
-        InspectorInstrumentation::addMessageToConsole(this, source, MessageType::Log, level, message, callStack, requestIdentifier);
+        message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, WTFMove(callStack), requestIdentifier);
     else
-        InspectorInstrumentation::addMessageToConsole(this, source, MessageType::Log, level, message, sourceURL, lineNumber, columnNumber, state, requestIdentifier);
+        message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, suggestedURL, suggestedLineNumber, suggestedColumnNumber, state, requestIdentifier);
+
+    InspectorInstrumentation::addMessageToConsole(this, WTFMove(message));
 }
 
 bool WorkerGlobalScope::isContextThread() const