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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "core/workers/SharedWorkerContext.h" | 33 #include "core/workers/SharedWorkerContext.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 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 PassRefPtr<MessageEvent> createConnectEvent(PassRefPtr<MessagePort> port) | 44 PassRefPtr<MessageEvent> createConnectEvent(PassRefPtr<MessagePort> port) |
44 { | 45 { |
45 RefPtr<MessageEvent> event = MessageEvent::create(adoptPtr(new MessagePortAr
ray(1, port))); | 46 RefPtr<MessageEvent> event = MessageEvent::create(adoptPtr(new MessagePortAr
ray(1, port))); |
46 event->initEvent(eventNames().connectEvent, false, false); | 47 event->initEvent(eventNames().connectEvent, false, false); |
47 return event.release(); | 48 return event.release(); |
48 } | 49 } |
49 | 50 |
50 // static | 51 // static |
51 PassRefPtr<SharedWorkerContext> SharedWorkerContext::create(const String& name,
const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, Sh
aredWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPo
licy::HeaderType contentSecurityPolicyType) | 52 PassRefPtr<SharedWorkerContext> SharedWorkerContext::create(const String& name,
const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, Sh
aredWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPo
licy::HeaderType contentSecurityPolicyType) |
52 { | 53 { |
53 RefPtr<SharedWorkerContext> context = adoptRef(new SharedWorkerContext(name,
url, userAgent, settings, thread)); | 54 RefPtr<SharedWorkerContext> context = adoptRef(new SharedWorkerContext(name,
url, userAgent, settings, thread)); |
54 context->applyContentSecurityPolicyFromString(contentSecurityPolicy, content
SecurityPolicyType); | 55 context->applyContentSecurityPolicyFromString(contentSecurityPolicy, content
SecurityPolicyType); |
55 return context.release(); | 56 return context.release(); |
56 } | 57 } |
57 | 58 |
58 SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, co
nst String& userAgent, PassOwnPtr<GroupSettings> settings, SharedWorkerThread* t
hread) | 59 SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, co
nst String& userAgent, PassOwnPtr<GroupSettings> settings, SharedWorkerThread* t
hread) |
59 : WorkerContext(url, userAgent, settings, thread, 0) | 60 : WorkerContext(url, userAgent, settings, thread, 0, monotonicallyIncreasing
Time()) |
60 , m_name(name) | 61 , m_name(name) |
61 { | 62 { |
62 ScriptWrappable::init(this); | 63 ScriptWrappable::init(this); |
63 } | 64 } |
64 | 65 |
65 SharedWorkerContext::~SharedWorkerContext() | 66 SharedWorkerContext::~SharedWorkerContext() |
66 { | 67 { |
67 } | 68 } |
68 | 69 |
69 const AtomicString& SharedWorkerContext::interfaceName() const | 70 const AtomicString& SharedWorkerContext::interfaceName() const |
70 { | 71 { |
71 return eventNames().interfaceForSharedWorkerContext; | 72 return eventNames().interfaceForSharedWorkerContext; |
72 } | 73 } |
73 | 74 |
74 SharedWorkerThread* SharedWorkerContext::thread() | 75 SharedWorkerThread* SharedWorkerContext::thread() |
75 { | 76 { |
76 return static_cast<SharedWorkerThread*>(Base::thread()); | 77 return static_cast<SharedWorkerThread*>(Base::thread()); |
77 } | 78 } |
78 | 79 |
79 void SharedWorkerContext::logExceptionToConsole(const String& errorMessage, cons
t String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack) | 80 void SharedWorkerContext::logExceptionToConsole(const String& errorMessage, cons
t String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack) |
80 { | 81 { |
81 WorkerContext::logExceptionToConsole(errorMessage, sourceURL, lineNumber, ca
llStack); | 82 WorkerContext::logExceptionToConsole(errorMessage, sourceURL, lineNumber, ca
llStack); |
82 addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage,
sourceURL, lineNumber, callStack); | 83 addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage,
sourceURL, lineNumber, callStack); |
83 } | 84 } |
84 | 85 |
85 } // namespace WebCore | 86 } // namespace WebCore |
OLD | NEW |