| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "core/workers/SharedWorkerContext.h" | 33 #include "core/workers/SharedWorkerGlobalScope.h" |
| 34 | 34 |
| 35 #include "core/dom/EventNames.h" | 35 #include "core/dom/EventNames.h" |
| 36 #include "core/dom/MessageEvent.h" | 36 #include "core/dom/MessageEvent.h" |
| 37 #include "core/inspector/ScriptCallStack.h" | 37 #include "core/inspector/ScriptCallStack.h" |
| 38 #include "core/page/DOMWindow.h" | 38 #include "core/page/DOMWindow.h" |
| 39 #include "core/workers/SharedWorkerThread.h" | 39 #include "core/workers/SharedWorkerThread.h" |
| 40 #include "wtf/CurrentTime.h" | 40 #include "wtf/CurrentTime.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 PassRefPtr<MessageEvent> createConnectEvent(PassRefPtr<MessagePort> port) | 44 PassRefPtr<MessageEvent> createConnectEvent(PassRefPtr<MessagePort> port) |
| 45 { | 45 { |
| 46 RefPtr<MessageEvent> event = MessageEvent::create(adoptPtr(new MessagePortAr
ray(1, port))); | 46 RefPtr<MessageEvent> event = MessageEvent::create(adoptPtr(new MessagePortAr
ray(1, port))); |
| 47 event->initEvent(eventNames().connectEvent, false, false); | 47 event->initEvent(eventNames().connectEvent, false, false); |
| 48 return event.release(); | 48 return event.release(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 PassRefPtr<SharedWorkerContext> SharedWorkerContext::create(const String& name,
const KURL& url, const String& userAgent, SharedWorkerThread* thread, const Stri
ng& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPoli
cyType) | 52 PassRefPtr<SharedWorkerGlobalScope> SharedWorkerGlobalScope::create(const String
& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, co
nst String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecu
rityPolicyType) |
| 53 { | 53 { |
| 54 RefPtr<SharedWorkerContext> context = adoptRef(new SharedWorkerContext(name,
url, userAgent, thread)); | 54 RefPtr<SharedWorkerGlobalScope> context = adoptRef(new SharedWorkerGlobalSco
pe(name, url, userAgent, thread)); |
| 55 context->applyContentSecurityPolicyFromString(contentSecurityPolicy, content
SecurityPolicyType); | 55 context->applyContentSecurityPolicyFromString(contentSecurityPolicy, content
SecurityPolicyType); |
| 56 return context.release(); | 56 return context.release(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, co
nst String& userAgent, SharedWorkerThread* thread) | 59 SharedWorkerGlobalScope::SharedWorkerGlobalScope(const String& name, const KURL&
url, const String& userAgent, SharedWorkerThread* thread) |
| 60 : WorkerContext(url, userAgent, thread, 0, monotonicallyIncreasingTime()) | 60 : WorkerGlobalScope(url, userAgent, thread, 0, monotonicallyIncreasingTime()
) |
| 61 , m_name(name) | 61 , m_name(name) |
| 62 { | 62 { |
| 63 ScriptWrappable::init(this); | 63 ScriptWrappable::init(this); |
| 64 } | 64 } |
| 65 | 65 |
| 66 SharedWorkerContext::~SharedWorkerContext() | 66 SharedWorkerGlobalScope::~SharedWorkerGlobalScope() |
| 67 { | 67 { |
| 68 } | 68 } |
| 69 | 69 |
| 70 const AtomicString& SharedWorkerContext::interfaceName() const | 70 const AtomicString& SharedWorkerGlobalScope::interfaceName() const |
| 71 { | 71 { |
| 72 return eventNames().interfaceForSharedWorkerContext; | 72 return eventNames().interfaceForSharedWorkerGlobalScope; |
| 73 } | 73 } |
| 74 | 74 |
| 75 SharedWorkerThread* SharedWorkerContext::thread() | 75 SharedWorkerThread* SharedWorkerGlobalScope::thread() |
| 76 { | 76 { |
| 77 return static_cast<SharedWorkerThread*>(Base::thread()); | 77 return static_cast<SharedWorkerThread*>(Base::thread()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void SharedWorkerContext::logExceptionToConsole(const String& errorMessage, cons
t String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack) | 80 void SharedWorkerGlobalScope::logExceptionToConsole(const String& errorMessage,
const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack) |
| 81 { | 81 { |
| 82 WorkerContext::logExceptionToConsole(errorMessage, sourceURL, lineNumber, ca
llStack); | 82 WorkerGlobalScope::logExceptionToConsole(errorMessage, sourceURL, lineNumber
, callStack); |
| 83 addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage,
sourceURL, lineNumber, callStack); | 83 addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage,
sourceURL, lineNumber, callStack); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace WebCore | 86 } // namespace WebCore |
| OLD | NEW |