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

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

Issue 478243002: bindings: Adds virtual ScriptWrappable::wrap method. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 3 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/WorkerConsole.h ('k') | Source/core/workers/WorkerLocation.h » ('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
(...skipping 29 matching lines...) Expand all
40 #include "wtf/Assertions.h" 40 #include "wtf/Assertions.h"
41 #include "wtf/HashMap.h" 41 #include "wtf/HashMap.h"
42 #include "wtf/OwnPtr.h" 42 #include "wtf/OwnPtr.h"
43 #include "wtf/PassRefPtr.h" 43 #include "wtf/PassRefPtr.h"
44 #include "wtf/RefCounted.h" 44 #include "wtf/RefCounted.h"
45 #include "wtf/RefPtr.h" 45 #include "wtf/RefPtr.h"
46 #include "wtf/text/AtomicStringHash.h" 46 #include "wtf/text/AtomicStringHash.h"
47 47
48 namespace blink { 48 namespace blink {
49 49
50 class Blob; 50 class Blob;
51 class ConsoleMessage; 51 class ConsoleMessage;
52 class ConsoleMessageStorage; 52 class ConsoleMessageStorage;
53 class ExceptionState; 53 class ExceptionState;
54 class ScheduledAction; 54 class ScheduledAction;
55 class WorkerClients; 55 class WorkerClients;
56 class WorkerConsole; 56 class WorkerConsole;
57 class WorkerInspectorController; 57 class WorkerInspectorController;
58 class WorkerLocation; 58 class WorkerLocation;
59 class WorkerNavigator; 59 class WorkerNavigator;
60 class WorkerThread; 60 class WorkerThread;
61 61
62 class WorkerGlobalScope : public RefCountedWillBeGarbageCollectedFinalized<W orkerGlobalScope>, public SecurityContext, public ExecutionContext, public Execu tionContextClient, public WillBeHeapSupplementable<WorkerGlobalScope>, public Ev entTargetWithInlineData, public DOMWindowBase64 { 62 class WorkerGlobalScope : public RefCountedWillBeGarbageCollectedFinalized<Worke rGlobalScope>, public SecurityContext, public ExecutionContext, public Execution ContextClient, public WillBeHeapSupplementable<WorkerGlobalScope>, public EventT argetWithInlineData, public DOMWindowBase64 {
63 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkerGlobalScope); 63 DEFINE_WRAPPERTYPEINFO();
64 REFCOUNTED_EVENT_TARGET(WorkerGlobalScope); 64 REFCOUNTED_EVENT_TARGET(WorkerGlobalScope);
65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkerGlobalScope);
66 public:
67 virtual ~WorkerGlobalScope();
68
69 virtual bool isWorkerGlobalScope() const OVERRIDE FINAL { return true; }
70 virtual bool isSharedWorkerGlobalScope() const OVERRIDE { return false; }
71 virtual bool isDedicatedWorkerGlobalScope() const OVERRIDE { return false; }
72 virtual bool isServiceWorkerGlobalScope() const OVERRIDE { return false; }
73
74 virtual ExecutionContext* executionContext() const OVERRIDE FINAL;
75
76 virtual void countFeature(UseCounter::Feature) const;
77 virtual void countDeprecation(UseCounter::Feature) const;
78
79 const KURL& url() const { return m_url; }
80 KURL completeURL(const String&) const;
81
82 virtual String userAgent(const KURL&) const OVERRIDE FINAL;
83 virtual void disableEval(const String& errorMessage) OVERRIDE FINAL;
84
85 WorkerScriptController* script() { return m_script.get(); }
86 void clearScript() { m_script.clear(); }
87 void clearInspector();
88
89 // FIXME: We can remove this interface when we remove openDatabaseSync.
90 class TerminationObserver {
65 public: 91 public:
66 virtual ~WorkerGlobalScope(); 92 virtual ~TerminationObserver() { }
93 // The function is probably called in the main thread.
94 virtual void wasRequestedToTerminate() = 0;
95 };
96 void registerTerminationObserver(TerminationObserver*);
97 void unregisterTerminationObserver(TerminationObserver*);
98 void wasRequestedToTerminate();
67 99
68 virtual bool isWorkerGlobalScope() const OVERRIDE FINAL { return true; } 100 void dispose();
69 virtual bool isSharedWorkerGlobalScope() const OVERRIDE { return false; }
70 virtual bool isDedicatedWorkerGlobalScope() const OVERRIDE { return fals e; }
71 virtual bool isServiceWorkerGlobalScope() const OVERRIDE { return false; }
72 101
73 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; 102 WorkerThread* thread() const { return m_thread; }
74 103
75 virtual void countFeature(UseCounter::Feature) const; 104 virtual void postTask(PassOwnPtr<ExecutionContextTask>) OVERRIDE FINAL; // E xecutes the task on context's thread asynchronously.
76 virtual void countDeprecation(UseCounter::Feature) const;
77 105
78 const KURL& url() const { return m_url; } 106 // WorkerGlobalScope
79 KURL completeURL(const String&) const; 107 WorkerGlobalScope* self() { return this; }
108 WorkerConsole* console();
109 WorkerLocation* location() const;
110 void close();
80 111
81 virtual String userAgent(const KURL&) const OVERRIDE FINAL; 112 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
82 virtual void disableEval(const String& errorMessage) OVERRIDE FINAL;
83 113
84 WorkerScriptController* script() { return m_script.get(); } 114 // WorkerUtils
85 void clearScript() { m_script.clear(); } 115 virtual void importScripts(const Vector<String>& urls, ExceptionState&);
86 void clearInspector(); 116 WorkerNavigator* navigator() const;
87 117
88 // FIXME: We can remove this interface when we remove openDatabaseSync. 118 // ExecutionContextClient
89 class TerminationObserver { 119 virtual WorkerEventQueue* eventQueue() const OVERRIDE FINAL;
90 public: 120 virtual SecurityContext& securityContext() OVERRIDE FINAL { return *this; }
91 virtual ~TerminationObserver() { }
92 // The function is probably called in the main thread.
93 virtual void wasRequestedToTerminate() = 0;
94 };
95 void registerTerminationObserver(TerminationObserver*);
96 void unregisterTerminationObserver(TerminationObserver*);
97 void wasRequestedToTerminate();
98 121
99 void dispose(); 122 virtual bool isContextThread() const OVERRIDE FINAL;
123 virtual bool isJSExecutionForbidden() const OVERRIDE FINAL;
100 124
101 WorkerThread* thread() const { return m_thread; } 125 virtual double timerAlignmentInterval() const OVERRIDE FINAL;
102 126
103 virtual void postTask(PassOwnPtr<ExecutionContextTask>) OVERRIDE FINAL; // Executes the task on context's thread asynchronously. 127 WorkerInspectorController* workerInspectorController() { return m_workerInsp ectorController.get(); }
104 128
105 // WorkerGlobalScope 129 bool isClosing() { return m_closing; }
106 WorkerGlobalScope* self() { return this; }
107 WorkerConsole* console();
108 WorkerLocation* location() const;
109 void close();
110 130
111 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 131 virtual void stopFetch() { }
112 132
113 // WorkerUtils 133 bool idleNotification();
114 virtual void importScripts(const Vector<String>& urls, ExceptionState&);
115 WorkerNavigator* navigator() const;
116 134
117 // ExecutionContextClient 135 double timeOrigin() const { return m_timeOrigin; }
118 virtual WorkerEventQueue* eventQueue() const OVERRIDE FINAL;
119 virtual SecurityContext& securityContext() OVERRIDE FINAL { return *this ; }
120 136
121 virtual bool isContextThread() const OVERRIDE FINAL; 137 WorkerClients* clients() { return m_workerClients.get(); }
122 virtual bool isJSExecutionForbidden() const OVERRIDE FINAL;
123 138
124 virtual double timerAlignmentInterval() const OVERRIDE FINAL; 139 using SecurityContext::securityOrigin;
140 using SecurityContext::contentSecurityPolicy;
125 141
126 WorkerInspectorController* workerInspectorController() { return m_worker InspectorController.get(); } 142 virtual void addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) OVERRIDE FIN AL;
143 ConsoleMessageStorage* messageStorage();
127 144
128 bool isClosing() { return m_closing; } 145 virtual void trace(Visitor*) OVERRIDE;
129 146
130 virtual void stopFetch() { } 147 protected:
148 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, doubl e timeOrigin, PassOwnPtrWillBeRawPtr<WorkerClients>);
149 void applyContentSecurityPolicyFromString(const String& contentSecurityPolic y, ContentSecurityPolicyHeaderType);
131 150
132 bool idleNotification(); 151 virtual void logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawP tr<ScriptCallStack>) OVERRIDE;
152 void addMessageToWorkerConsole(PassRefPtrWillBeRawPtr<ConsoleMessage>);
133 153
134 double timeOrigin() const { return m_timeOrigin; } 154 private:
135
136 WorkerClients* clients() { return m_workerClients.get(); }
137
138 using SecurityContext::securityOrigin;
139 using SecurityContext::contentSecurityPolicy;
140
141 virtual void addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) OVERRIDE FINAL;
142 ConsoleMessageStorage* messageStorage();
143
144 virtual void trace(Visitor*) OVERRIDE;
145
146 protected:
147 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, d ouble timeOrigin, PassOwnPtrWillBeRawPtr<WorkerClients>);
148 void applyContentSecurityPolicyFromString(const String& contentSecurityP olicy, ContentSecurityPolicyHeaderType);
149
150 virtual void logExceptionToConsole(const String& errorMessage, int scrip tId, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBe RawPtr<ScriptCallStack>) OVERRIDE;
151 void addMessageToWorkerConsole(PassRefPtrWillBeRawPtr<ConsoleMessage>);
152
153 private:
154 #if !ENABLE(OILPAN) 155 #if !ENABLE(OILPAN)
155 virtual void refExecutionContext() OVERRIDE FINAL { ref(); } 156 virtual void refExecutionContext() OVERRIDE FINAL { ref(); }
156 virtual void derefExecutionContext() OVERRIDE FINAL { deref(); } 157 virtual void derefExecutionContext() OVERRIDE FINAL { deref(); }
157 #endif 158 #endif
158 159
159 virtual const KURL& virtualURL() const OVERRIDE FINAL; 160 virtual const KURL& virtualURL() const OVERRIDE FINAL;
160 virtual KURL virtualCompleteURL(const String&) const OVERRIDE FINAL; 161 virtual KURL virtualCompleteURL(const String&) const OVERRIDE FINAL;
161 162
162 virtual void reportBlockedScriptExecutionToInspector(const String& direc tiveText) OVERRIDE FINAL; 163 virtual void reportBlockedScriptExecutionToInspector(const String& directive Text) OVERRIDE FINAL;
163 164
164 virtual EventTarget* errorEventTarget() OVERRIDE FINAL; 165 virtual EventTarget* errorEventTarget() OVERRIDE FINAL;
165 virtual void didUpdateSecurityOrigin() OVERRIDE FINAL { } 166 virtual void didUpdateSecurityOrigin() OVERRIDE FINAL { }
166 167
167 KURL m_url; 168 KURL m_url;
168 String m_userAgent; 169 String m_userAgent;
169 170
170 mutable RefPtrWillBeMember<WorkerConsole> m_console; 171 mutable RefPtrWillBeMember<WorkerConsole> m_console;
171 mutable RefPtrWillBeMember<WorkerLocation> m_location; 172 mutable RefPtrWillBeMember<WorkerLocation> m_location;
172 mutable RefPtrWillBeMember<WorkerNavigator> m_navigator; 173 mutable RefPtrWillBeMember<WorkerNavigator> m_navigator;
173 174
174 OwnPtr<WorkerScriptController> m_script; 175 OwnPtr<WorkerScriptController> m_script;
175 WorkerThread* m_thread; 176 WorkerThread* m_thread;
176 177
177 RefPtrWillBeMember<WorkerInspectorController> m_workerInspectorControlle r; 178 RefPtrWillBeMember<WorkerInspectorController> m_workerInspectorController;
178 bool m_closing; 179 bool m_closing;
179 180
180 OwnPtrWillBeMember<WorkerEventQueue> m_eventQueue; 181 OwnPtrWillBeMember<WorkerEventQueue> m_eventQueue;
181 182
182 OwnPtrWillBeMember<WorkerClients> m_workerClients; 183 OwnPtrWillBeMember<WorkerClients> m_workerClients;
183 184
184 double m_timeOrigin; 185 double m_timeOrigin;
185 TerminationObserver* m_terminationObserver; 186 TerminationObserver* m_terminationObserver;
186 187
187 OwnPtrWillBeMember<ConsoleMessageStorage> m_messageStorage; 188 OwnPtrWillBeMember<ConsoleMessageStorage> m_messageStorage;
188 }; 189 };
189 190
190 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke rGlobalScope(), context.isWorkerGlobalScope()); 191 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke rGlobalScope(), context.isWorkerGlobalScope());
191 192
192 } // namespace blink 193 } // namespace blink
193 194
194 #endif // WorkerGlobalScope_h 195 #endif // WorkerGlobalScope_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerConsole.h ('k') | Source/core/workers/WorkerLocation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698