Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: Source/core/workers/WorkerGlobalScope.h

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerContextProxy.cpp ('k') | Source/core/workers/WorkerGlobalScope.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 */ 25 */
26 26
27 #ifndef WorkerContext_h 27 #ifndef WorkerGlobalScope_h
28 #define WorkerContext_h 28 #define WorkerGlobalScope_h
29 29
30 #include "bindings/v8/ScriptWrappable.h" 30 #include "bindings/v8/ScriptWrappable.h"
31 #include "bindings/v8/WorkerScriptController.h" 31 #include "bindings/v8/WorkerScriptController.h"
32 #include "core/dom/EventListener.h" 32 #include "core/dom/EventListener.h"
33 #include "core/dom/EventNames.h" 33 #include "core/dom/EventNames.h"
34 #include "core/dom/EventTarget.h" 34 #include "core/dom/EventTarget.h"
35 #include "core/dom/ScriptExecutionContext.h" 35 #include "core/dom/ScriptExecutionContext.h"
36 #include "core/page/ContentSecurityPolicy.h" 36 #include "core/page/ContentSecurityPolicy.h"
37 #include "core/workers/WorkerEventQueue.h" 37 #include "core/workers/WorkerEventQueue.h"
38 #include <wtf/Assertions.h> 38 #include "wtf/Assertions.h"
39 #include <wtf/HashMap.h> 39 #include "wtf/HashMap.h"
40 #include <wtf/OwnPtr.h> 40 #include "wtf/OwnPtr.h"
41 #include <wtf/PassRefPtr.h> 41 #include "wtf/PassRefPtr.h"
42 #include <wtf/RefCounted.h> 42 #include "wtf/RefCounted.h"
43 #include <wtf/RefPtr.h> 43 #include "wtf/RefPtr.h"
44 #include <wtf/text/AtomicStringHash.h> 44 #include "wtf/text/AtomicStringHash.h"
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 class Blob; 48 class Blob;
49 class DOMURL; 49 class DOMURL;
50 class ScheduledAction; 50 class ScheduledAction;
51 class WorkerInspectorController; 51 class WorkerInspectorController;
52 class WorkerLocation; 52 class WorkerLocation;
53 class WorkerNavigator; 53 class WorkerNavigator;
54 class WorkerThread; 54 class WorkerThread;
55 55
56 class WorkerContext : public RefCounted<WorkerContext>, public ScriptWrappab le, public ScriptExecutionContext, public EventTarget { 56 class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public Scrip tWrappable, public ScriptExecutionContext, public EventTarget {
57 public: 57 public:
58 virtual ~WorkerContext(); 58 virtual ~WorkerGlobalScope();
59 59
60 virtual bool isWorkerContext() const OVERRIDE { return true; } 60 virtual bool isWorkerGlobalScope() const OVERRIDE { return true; }
61 61
62 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; 62 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
63 63
64 virtual bool isSharedWorkerContext() const { return false; } 64 virtual bool isSharedWorkerGlobalScope() const { return false; }
65 virtual bool isDedicatedWorkerContext() const { return false; } 65 virtual bool isDedicatedWorkerGlobalScope() const { return false; }
66 66
67 const KURL& url() const { return m_url; } 67 const KURL& url() const { return m_url; }
68 KURL completeURL(const String&) const; 68 KURL completeURL(const String&) const;
69 69
70 virtual String userAgent(const KURL&) const; 70 virtual String userAgent(const KURL&) const;
71 71
72 virtual void disableEval(const String& errorMessage) OVERRIDE; 72 virtual void disableEval(const String& errorMessage) OVERRIDE;
73 73
74 WorkerScriptController* script() { return m_script.get(); } 74 WorkerScriptController* script() { return m_script.get(); }
75 void clearScript() { m_script.clear(); } 75 void clearScript() { m_script.clear(); }
76 void clearInspector(); 76 void clearInspector();
77 77
78 WorkerThread* thread() const { return m_thread; } 78 WorkerThread* thread() const { return m_thread; }
79 79
80 virtual void postTask(PassOwnPtr<Task>) OVERRIDE; // Executes the task o n context's thread asynchronously. 80 virtual void postTask(PassOwnPtr<Task>) OVERRIDE; // Executes the task o n context's thread asynchronously.
81 81
82 // WorkerGlobalScope 82 // WorkerGlobalScope
83 WorkerContext* self() { return this; } 83 WorkerGlobalScope* self() { return this; }
84 WorkerLocation* location() const; 84 WorkerLocation* location() const;
85 void close(); 85 void close();
86 86
87 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 87 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
88 88
89 // WorkerUtils 89 // WorkerUtils
90 virtual void importScripts(const Vector<String>& urls, ExceptionCode&); 90 virtual void importScripts(const Vector<String>& urls, ExceptionCode&);
91 WorkerNavigator* navigator() const; 91 WorkerNavigator* navigator() const;
92 92
93 // Timers 93 // Timers
94 int setTimeout(PassOwnPtr<ScheduledAction>, int timeout); 94 int setTimeout(PassOwnPtr<ScheduledAction>, int timeout);
95 void clearTimeout(int timeoutId); 95 void clearTimeout(int timeoutId);
96 int setInterval(PassOwnPtr<ScheduledAction>, int timeout); 96 int setInterval(PassOwnPtr<ScheduledAction>, int timeout);
97 void clearInterval(int timeoutId); 97 void clearInterval(int timeoutId);
98 98
99 // ScriptExecutionContext 99 // ScriptExecutionContext
100 virtual WorkerEventQueue* eventQueue() const OVERRIDE; 100 virtual WorkerEventQueue* eventQueue() const OVERRIDE;
101 101
102 virtual bool isContextThread() const OVERRIDE; 102 virtual bool isContextThread() const OVERRIDE;
103 virtual bool isJSExecutionForbidden() const OVERRIDE; 103 virtual bool isJSExecutionForbidden() const OVERRIDE;
104 104
105 WorkerInspectorController* workerInspectorController() { return m_worker InspectorController.get(); } 105 WorkerInspectorController* workerInspectorController() { return m_worker InspectorController.get(); }
106 // These methods are used for GC marking. See JSWorkerContext::visitChil drenVirtual(SlotVisitor&) in 106 // These methods are used for GC marking. See JSWorkerGlobalScope::visit ChildrenVirtual(SlotVisitor&) in
107 // JSWorkerContextCustom.cpp. 107 // JSWorkerGlobalScopeCustom.cpp.
108 WorkerNavigator* optionalNavigator() const { return m_navigator.get(); } 108 WorkerNavigator* optionalNavigator() const { return m_navigator.get(); }
109 WorkerLocation* optionalLocation() const { return m_location.get(); } 109 WorkerLocation* optionalLocation() const { return m_location.get(); }
110 110
111 using RefCounted<WorkerContext>::ref; 111 using RefCounted<WorkerGlobalScope>::ref;
112 using RefCounted<WorkerContext>::deref; 112 using RefCounted<WorkerGlobalScope>::deref;
113 113
114 bool isClosing() { return m_closing; } 114 bool isClosing() { return m_closing; }
115 115
116 // An observer interface to be notified when the worker thread is gettin g stopped. 116 // An observer interface to be notified when the worker thread is gettin g stopped.
117 class Observer { 117 class Observer {
118 WTF_MAKE_NONCOPYABLE(Observer); 118 WTF_MAKE_NONCOPYABLE(Observer);
119 public: 119 public:
120 Observer(WorkerContext*); 120 Observer(WorkerGlobalScope*);
121 virtual ~Observer(); 121 virtual ~Observer();
122 virtual void notifyStop() = 0; 122 virtual void notifyStop() = 0;
123 void stopObserving(); 123 void stopObserving();
124 private: 124 private:
125 WorkerContext* m_context; 125 WorkerGlobalScope* m_context;
126 }; 126 };
127 friend class Observer; 127 friend class Observer;
128 void registerObserver(Observer*); 128 void registerObserver(Observer*);
129 void unregisterObserver(Observer*); 129 void unregisterObserver(Observer*);
130 void notifyObserversOfStop(); 130 void notifyObserversOfStop();
131 131
132 virtual const SecurityOrigin* topOrigin() const OVERRIDE { return m_topO rigin.get(); } 132 virtual const SecurityOrigin* topOrigin() const OVERRIDE { return m_topO rigin.get(); }
133 133
134 double timeOrigin() const { return m_timeOrigin; } 134 double timeOrigin() const { return m_timeOrigin; }
135 135
136 protected: 136 protected:
137 WorkerContext(const KURL&, const String& userAgent, WorkerThread*, PassR efPtr<SecurityOrigin> topOrigin, double timeOrigin); 137 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, P assRefPtr<SecurityOrigin> topOrigin, double timeOrigin);
138 void applyContentSecurityPolicyFromString(const String& contentSecurityP olicy, ContentSecurityPolicy::HeaderType); 138 void applyContentSecurityPolicyFromString(const String& contentSecurityP olicy, ContentSecurityPolicy::HeaderType);
139 139
140 virtual void logExceptionToConsole(const String& errorMessage, const Str ing& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) OVERRIDE; 140 virtual void logExceptionToConsole(const String& errorMessage, const Str ing& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;
141 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String & message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallSt ack>, ScriptState* = 0, unsigned long requestIdentifier = 0); 141 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String & message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallSt ack>, ScriptState* = 0, unsigned long requestIdentifier = 0);
142 142
143 private: 143 private:
144 virtual void refScriptExecutionContext() OVERRIDE { ref(); } 144 virtual void refScriptExecutionContext() OVERRIDE { ref(); }
145 virtual void derefScriptExecutionContext() OVERRIDE { deref(); } 145 virtual void derefScriptExecutionContext() OVERRIDE { deref(); }
146 146
147 virtual void refEventTarget() OVERRIDE { ref(); } 147 virtual void refEventTarget() OVERRIDE { ref(); }
(...skipping 27 matching lines...) Expand all
175 175
176 OwnPtr<WorkerEventQueue> m_eventQueue; 176 OwnPtr<WorkerEventQueue> m_eventQueue;
177 177
178 RefPtr<SecurityOrigin> m_topOrigin; 178 RefPtr<SecurityOrigin> m_topOrigin;
179 179
180 double m_timeOrigin; 180 double m_timeOrigin;
181 }; 181 };
182 182
183 } // namespace WebCore 183 } // namespace WebCore
184 184
185 #endif // WorkerContext_h 185 #endif // WorkerGlobalScope_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerContextProxy.cpp ('k') | Source/core/workers/WorkerGlobalScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698