Changeset 235159 in webkit
- Timestamp:
- Aug 21, 2018 9:58:26 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r235155 r235159 1 2018-08-21 Yusuke Suzuki <yusukesuzuki@slowstart.org> 2 3 Support "name" option for dedicated workers 4 https://bugs.webkit.org/show_bug.cgi?id=188779 5 6 Reviewed by Joseph Pecoraro. 7 8 * http/wpt/workers/name-property-enhanced-expected.txt: Added. 9 * http/wpt/workers/name-property-enhanced.html: Added. 10 * http/wpt/workers/name-property-no-name-expected.txt: Added. 11 * http/wpt/workers/name-property-no-name.html: Added. 12 * http/wpt/workers/support/name.js: Added. 13 (test): 14 * http/wpt/workers/support/no-name.js: Added. 15 (test): 16 1 17 2018-08-21 Ryan Haddad <ryanhaddad@apple.com> 2 18 -
trunk/LayoutTests/imported/w3c/ChangeLog
r235155 r235159 1 2018-08-21 Yusuke Suzuki <yusukesuzuki@slowstart.org> 2 3 Support "name" option for dedicated workers 4 https://bugs.webkit.org/show_bug.cgi?id=188779 5 6 Reviewed by Joseph Pecoraro. 7 8 * web-platform-tests/workers/interfaces.worker-expected.txt: 9 * web-platform-tests/workers/name-property-expected.txt: 10 1 11 2018-08-21 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces.worker-expected.txt
r235155 r235159 69 69 PASS DedicatedWorkerGlobalScope interface: existence and properties of interface prototype object's "constructor" property 70 70 PASS DedicatedWorkerGlobalScope interface: existence and properties of interface prototype object's @@unscopables property 71 FAIL DedicatedWorkerGlobalScope interface: attribute name assert_own_property: The global object must have a property "name" expected property "name" missing 71 PASS DedicatedWorkerGlobalScope interface: attribute name 72 72 PASS Unscopable handled correctly for name property on DedicatedWorkerGlobalScope 73 73 PASS DedicatedWorkerGlobalScope interface: operation postMessage(any, [object Object]) … … 87 87 PASS DedicatedWorkerGlobalScope must be primary interface of self 88 88 PASS Stringification of self 89 FAIL DedicatedWorkerGlobalScope interface: self must inherit property "name" with the proper type assert_own_property: expected property "name" missing 89 PASS DedicatedWorkerGlobalScope interface: self must inherit property "name" with the proper type 90 90 PASS DedicatedWorkerGlobalScope interface: self must inherit property "postMessage(any, [object Object])" with the proper type 91 91 PASS DedicatedWorkerGlobalScope interface: calling postMessage(any, [object Object]) on self with too few arguments must throw TypeError -
trunk/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt
r235155 r235159 2 2 3 3 FAIL Test the name property of shared and dedicated workers via the name constructor option ReferenceError: Can't find variable: SharedWorker 4 PASS name property value for DedicatedWorkerGlobalScope 5 PASS name property is replaceable for DedicatedWorkerGlobalScope 4 6 PASS Declaring name as an accidental global must not cause a harness error for DedicatedWorkerGlobalScope 5 FAIL name property value for DedicatedWorkerGlobalScope assert_true: property exists on the global expected true got false6 PASS name property is replaceable for DedicatedWorkerGlobalScope7 7 -
trunk/Source/WebCore/ChangeLog
r235158 r235159 1 2018-08-21 Yusuke Suzuki <yusukesuzuki@slowstart.org> 2 3 Support "name" option for dedicated workers 4 https://bugs.webkit.org/show_bug.cgi?id=188779 5 6 Reviewed by Joseph Pecoraro. 7 8 This patch adds `new Worker(url, { name: "Worker Name" })` option support[1]. 9 This name can be accessible from `self.name` of DedicatedWorkerGlobalScope. 10 It is useful for debugging dedicated workers if the inspector can show the 11 names of the workers. This enhancement is tracked by [2]. 12 13 [1]: https://github.com/whatwg/html/issues/2477 14 [2]: https://bugs.webkit.org/show_bug.cgi?id=164678 15 16 Tests: http/wpt/workers/name-property-enhanced.html 17 http/wpt/workers/name-property-no-name.html 18 19 * workers/DedicatedWorkerGlobalScope.cpp: 20 (WebCore::DedicatedWorkerGlobalScope::create): 21 (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope): 22 Hold `name` member. 23 24 * workers/DedicatedWorkerGlobalScope.h: 25 * workers/DedicatedWorkerGlobalScope.idl: 26 Add `name` attribute. 27 28 * workers/DedicatedWorkerThread.cpp: 29 (WebCore::DedicatedWorkerThread::DedicatedWorkerThread): 30 (WebCore::DedicatedWorkerThread::createWorkerGlobalScope): 31 * workers/DedicatedWorkerThread.h: 32 * workers/Worker.cpp: 33 (WebCore::Worker::Worker): 34 (WebCore::Worker::create): 35 (WebCore::Worker::notifyFinished): 36 * workers/Worker.h: 37 * workers/Worker.idl: 38 Add WorkerOptions for dedicated worker creation. 39 40 * workers/WorkerGlobalScopeProxy.h: 41 * workers/WorkerMessagingProxy.cpp: 42 (WebCore::WorkerMessagingProxy::startWorkerGlobalScope): 43 * workers/WorkerMessagingProxy.h: 44 * workers/WorkerThread.cpp: 45 (WebCore::WorkerThreadStartupData::WorkerThreadStartupData): 46 Isolate copy the given `name` to pass the worker thread. 47 48 (WebCore::WorkerThread::WorkerThread): 49 (WebCore::WorkerThread::workerThread): 50 * workers/WorkerThread.h: 51 * workers/service/context/ServiceWorkerThread.cpp: 52 (WebCore::ServiceWorkerThread::ServiceWorkerThread): 53 (WebCore::ServiceWorkerThread::createWorkerGlobalScope): 54 * workers/service/context/ServiceWorkerThread.h: 55 1 56 2018-08-21 Ryosuke Niwa <rniwa@webkit.org> 2 57 -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
r235155 r235159 42 42 namespace WebCore { 43 43 44 Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID)44 Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) 45 45 { 46 auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID));46 auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), name, identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)); 47 47 if (!shouldBypassMainWorldContentSecurityPolicy) 48 48 context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders); … … 50 50 } 51 51 52 DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID)52 DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) 53 53 : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID) 54 , m_name(name) 54 55 { 55 56 } -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h
r235155 r235159 49 49 class DedicatedWorkerGlobalScope final : public WorkerGlobalScope { 50 50 public: 51 static Ref<DedicatedWorkerGlobalScope> create(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID);51 static Ref<DedicatedWorkerGlobalScope> create(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); 52 52 virtual ~DedicatedWorkerGlobalScope(); 53 54 const String& name() const { return m_name; } 53 55 54 56 ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&); … … 59 61 using Base = WorkerGlobalScope; 60 62 61 DedicatedWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID);63 DedicatedWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); 62 64 63 65 bool isDedicatedWorkerGlobalScope() const final { return true; } 64 66 ExceptionOr<void> importScripts(const Vector<String>& urls) final; 65 67 EventTargetInterface eventTargetInterface() const final; 68 69 String m_name; 66 70 }; 67 71 -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl
r235155 r235159 38 38 IsImmutablePrototypeExoticObjectOnPrototype, 39 39 ] interface DedicatedWorkerGlobalScope : WorkerGlobalScope { 40 [Replaceable] readonly attribute DOMString name; 41 40 42 [CallWith=ScriptState, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []); 41 43 -
trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp
r235155 r235159 39 39 namespace WebCore { 40 40 41 DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID)42 : WorkerThread(url, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID)41 DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) 42 : WorkerThread(url, name, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID) 43 43 , m_workerObjectProxy(workerObjectProxy) 44 44 { … … 47 47 DedicatedWorkerThread::~DedicatedWorkerThread() = default; 48 48 49 Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID)49 Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) 50 50 { 51 return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID);51 return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), name, identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); 52 52 } 53 53 -
trunk/Source/WebCore/workers/DedicatedWorkerThread.h
r235155 r235159 50 50 51 51 protected: 52 Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) override;52 Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) override; 53 53 void runEventLoop() override; 54 54 55 55 private: 56 DedicatedWorkerThread(const URL&, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID);56 DedicatedWorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); 57 57 58 58 WorkerObjectProxy& m_workerObjectProxy; -
trunk/Source/WebCore/workers/Worker.cpp
r235155 r235159 58 58 } 59 59 60 inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags )60 inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const Options& options) 61 61 : ActiveDOMObject(&context) 62 , m_name(options.name) 62 63 , m_identifier("worker:" + Inspector::IdentifiersFactory::createIdentifier()) 63 64 , m_contextProxy(WorkerGlobalScopeProxy::create(*this)) … … 74 75 } 75 76 76 ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url )77 ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url, const Options& options) 77 78 { 78 79 ASSERT(isMainThread()); … … 81 82 ASSERT_WITH_SECURITY_IMPLICATION(context.isDocument()); 82 83 83 auto worker = adoptRef(*new Worker(context, runtimeFlags ));84 auto worker = adoptRef(*new Worker(context, runtimeFlags, options)); 84 85 85 86 worker->suspendIfNeeded(); … … 104 105 request.setInitiatorIdentifier(worker->m_identifier); 105 106 106 FetchOptions options;107 options.mode = FetchOptions::Mode::SameOrigin;108 options.cache = FetchOptions::Cache::Default;109 options.redirect = FetchOptions::Redirect::Follow;110 options.destination = FetchOptions::Destination::Worker;111 worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove( options), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker);107 FetchOptions fetchOptions; 108 fetchOptions.mode = FetchOptions::Mode::SameOrigin; 109 fetchOptions.cache = FetchOptions::Cache::Default; 110 fetchOptions.redirect = FetchOptions::Redirect::Follow; 111 fetchOptions.destination = FetchOptions::Destination::Worker; 112 worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker); 112 113 return WTFMove(worker); 113 114 } … … 186 187 bool isOnline = platformStrategies()->loaderStrategy()->isOnLine(); 187 188 const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders(); 188 m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID);189 m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID); 189 190 InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); 190 191 } -
trunk/Source/WebCore/workers/Worker.h
r235155 r235159 51 51 class Worker final : public AbstractWorker, public ActiveDOMObject, private WorkerScriptLoaderClient { 52 52 public: 53 static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url); 53 struct Options { 54 String name; 55 }; 56 static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url, const Options&); 54 57 virtual ~Worker(); 55 58 … … 65 68 66 69 private: 67 explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags );70 explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags, const Options&); 68 71 69 72 EventTargetInterface eventTargetInterface() const final { return WorkerEventTargetInterfaceType; } … … 81 84 82 85 RefPtr<WorkerScriptLoader> m_scriptLoader; 86 String m_name; 83 87 String m_identifier; 84 88 WorkerGlobalScopeProxy& m_contextProxy; // The proxy outlives the worker to perform thread shutdown. -
trunk/Source/WebCore/workers/Worker.idl
r235155 r235159 27 27 [ 28 28 ActiveDOMObject, 29 Constructor(USVString scriptUrl ),29 Constructor(USVString scriptUrl, optional WorkerOptions options), 30 30 ConstructorCallWith=ScriptExecutionContext&RuntimeFlags, 31 31 ConstructorMayThrowException … … 37 37 }; 38 38 39 dictionary WorkerOptions { 40 DOMString name = ""; 41 }; 42 39 43 Worker implements AbstractWorker; -
trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h
r235155 r235159 51 51 static WorkerGlobalScopeProxy& create(Worker&); 52 52 53 virtual void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) = 0;53 virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) = 0; 54 54 virtual void terminateWorkerGlobalScope() = 0; 55 55 virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0; -
trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp
r235155 r235159 73 73 } 74 74 75 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID)75 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) 76 76 { 77 77 // FIXME: This need to be revisited when we support nested worker one day … … 89 89 SocketProvider* socketProvider = document.socketProvider(); 90 90 91 auto thread = DedicatedWorkerThread::create(scriptURL, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID);91 auto thread = DedicatedWorkerThread::create(scriptURL, name, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID); 92 92 93 93 workerThreadCreated(thread.get()); -
trunk/Source/WebCore/workers/WorkerMessagingProxy.h
r235155 r235159 47 47 // Implementations of WorkerGlobalScopeProxy. 48 48 // (Only use these functions in the worker object thread.) 49 void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final;49 void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final; 50 50 void terminateWorkerGlobalScope() final; 51 51 void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final; -
trunk/Source/WebCore/workers/WorkerThread.cpp
r235155 r235159 73 73 WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED; 74 74 public: 75 WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID);75 WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID); 76 76 77 77 URL m_scriptURL; 78 78 Ref<SecurityOrigin> m_origin; 79 String m_name; 79 80 String m_identifier; 80 81 String m_userAgent; … … 89 90 }; 90 91 91 WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID)92 WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) 92 93 : m_scriptURL(scriptURL.isolatedCopy()) 93 94 , m_origin(SecurityOrigin::create(m_scriptURL)->isolatedCopy()) 95 , m_name(name.isolatedCopy()) 94 96 , m_identifier(identifier.isolatedCopy()) 95 97 , m_userAgent(userAgent.isolatedCopy()) … … 105 107 } 106 108 107 WorkerThread::WorkerThread(const URL& scriptURL, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID)109 WorkerThread::WorkerThread(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) 108 110 : m_workerLoaderProxy(workerLoaderProxy) 109 111 , m_workerDebuggerProxy(workerDebuggerProxy) 110 112 , m_workerReportingProxy(workerReportingProxy) 111 113 , m_runtimeFlags(runtimeFlags) 112 , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID))114 , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, name, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID)) 113 115 #if ENABLE(INDEXED_DATABASE) 114 116 , m_idbConnectionProxy(connectionProxy) … … 168 170 // be called before we've finished creating the WorkerGlobalScope. 169 171 LockHolder lock(m_threadCreationAndWorkerGlobalScopeMutex); 170 m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, WTFMove(m_startupData->m_origin), m_startupData->m_ identifier, m_startupData->m_userAgent, m_startupData->m_isOnline, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin, m_startupData->m_sessionID);172 m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, WTFMove(m_startupData->m_origin), m_startupData->m_name, m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_isOnline, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin, m_startupData->m_sessionID); 171 173 172 174 scriptController = m_workerGlobalScope->script(); -
trunk/Source/WebCore/workers/WorkerThread.h
r235155 r235159 88 88 89 89 protected: 90 WorkerThread(const URL&, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID);90 WorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); 91 91 92 92 // Factory method for creating a new worker context for the thread. 93 virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) = 0;93 virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) = 0; 94 94 95 95 // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop. -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
r235155 r235159 73 73 74 74 ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, PAL::SessionID, String&& userAgent, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider) 75 : WorkerThread(data.scriptURL, "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID)75 : WorkerThread(data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID) 76 76 , m_data(data.isolatedCopy()) 77 77 , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared()) … … 82 82 ServiceWorkerThread::~ServiceWorkerThread() = default; 83 83 84 Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID)84 Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) 85 85 { 86 UNUSED_PARAM(name); 86 87 return ServiceWorkerGlobalScope::create(m_data, url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicy, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); 87 88 } -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h
r235155 r235159 67 67 68 68 protected: 69 Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final;69 Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final; 70 70 void runEventLoop() override; 71 71
Note: See TracChangeset
for help on using the changeset viewer.