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

Side by Side Diff: Source/core/dom/ExecutionContext.h

Issue 27311002: Introduce ExecutionContextClient (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix clang build error Created 7 years, 2 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/dom/Document.cpp ('k') | Source/core/dom/ExecutionContext.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 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. 3 * Copyright (C) 2012 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * 25 *
26 */ 26 */
27 27
28 #ifndef ExecutionContext_h 28 #ifndef ExecutionContext_h
29 #define ExecutionContext_h 29 #define ExecutionContext_h
30 30
31 #include "core/dom/ActiveDOMObject.h" 31 #include "core/dom/ActiveDOMObject.h"
32 #include "core/dom/ExecutionContextClient.h"
32 #include "core/dom/SecurityContext.h" 33 #include "core/dom/SecurityContext.h"
33 #include "core/events/ErrorEvent.h" 34 #include "core/events/ErrorEvent.h"
34 #include "core/fetch/CrossOriginAccessControl.h" 35 #include "core/fetch/CrossOriginAccessControl.h"
35 #include "core/frame/ConsoleTypes.h" 36 #include "core/frame/ConsoleTypes.h"
36 #include "core/frame/DOMTimer.h" 37 #include "core/frame/DOMTimer.h"
37 #include "core/platform/LifecycleContext.h" 38 #include "core/platform/LifecycleContext.h"
38 #include "weborigin/KURL.h" 39 #include "weborigin/KURL.h"
39 #include "wtf/HashSet.h" 40 #include "wtf/HashSet.h"
40 #include "wtf/OwnPtr.h" 41 #include "wtf/OwnPtr.h"
41 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
(...skipping 14 matching lines...) Expand all
56 class MessagePort; 57 class MessagePort;
57 class PublicURLManager; 58 class PublicURLManager;
58 class ScriptCallStack; 59 class ScriptCallStack;
59 class ScriptState; 60 class ScriptState;
60 61
61 class ExecutionContext : public LifecycleContext, public SecurityContext { 62 class ExecutionContext : public LifecycleContext, public SecurityContext {
62 public: 63 public:
63 ExecutionContext(); 64 ExecutionContext();
64 virtual ~ExecutionContext(); 65 virtual ~ExecutionContext();
65 66
66 virtual bool isDocument() const { return false; } 67 // Delegating to ExecutionContextClient
67 virtual bool isWorkerGlobalScope() const { return false; } 68 void setClient(ExecutionContextClient* client) { m_client = client; }
68 69 bool isDocument() const { return m_client && m_client->isDocument(); }
69 virtual bool isJSExecutionForbidden() const = 0; 70 bool isWorkerGlobalScope() { return m_client && m_client->isWorkerGlobalScop e(); }
70 71 bool isJSExecutionForbidden() { return m_client && m_client->isJSExecutionFo rbidden(); }
71 virtual DOMWindow* executingWindow() { return 0; } 72 EventQueue* eventQueue() const;
72 virtual void userEventWasHandled() { } 73 const KURL& url() const;
73 74 KURL completeURL(const String& url) const;
74 const KURL& url() const { return virtualURL(); } 75 void userEventWasHandled();
75 KURL completeURL(const String& url) const { return virtualCompleteURL(url); } 76 void disableEval(const String& errorMessage);
76 77 DOMWindow* executingWindow() const;
77 virtual String userAgent(const KURL&) const = 0; 78 String userAgent(const KURL&) const;
78 79 void postTask(PassOwnPtr<ExecutionContextTask>);
79 virtual void disableEval(const String& errorMessage) = 0; 80 double timerAlignmentInterval() const;
80 81
81 bool shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus) ; 82 bool shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus) ;
82 void reportException(PassRefPtr<ErrorEvent>, PassRefPtr<ScriptCallStack>, Ac cessControlStatus); 83 void reportException(PassRefPtr<ErrorEvent>, PassRefPtr<ScriptCallStack>, Ac cessControlStatus);
83 84
84 void addConsoleMessage(MessageSource, MessageLevel, const String& message, c onst String& sourceURL, unsigned lineNumber); 85 void addConsoleMessage(MessageSource, MessageLevel, const String& message, c onst String& sourceURL, unsigned lineNumber);
85 void addConsoleMessage(MessageSource, MessageLevel, const String& message, S criptState* = 0); 86 void addConsoleMessage(MessageSource, MessageLevel, const String& message, S criptState* = 0);
86 87
87 PublicURLManager& publicURLManager(); 88 PublicURLManager& publicURLManager();
88 89
89 // Active objects are not garbage collected even if inaccessible, e.g. becau se their activity may result in callbacks being invoked. 90 // Active objects are not garbage collected even if inaccessible, e.g. becau se their activity may result in callbacks being invoked.
(...skipping 13 matching lines...) Expand all
103 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be tracked separately for message dispatch. 104 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be tracked separately for message dispatch.
104 void processMessagePortMessagesSoon(); 105 void processMessagePortMessagesSoon();
105 void dispatchMessagePortEvents(); 106 void dispatchMessagePortEvents();
106 void createdMessagePort(MessagePort*); 107 void createdMessagePort(MessagePort*);
107 void destroyedMessagePort(MessagePort*); 108 void destroyedMessagePort(MessagePort*);
108 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; } 109 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; }
109 110
110 void ref() { refExecutionContext(); } 111 void ref() { refExecutionContext(); }
111 void deref() { derefExecutionContext(); } 112 void deref() { derefExecutionContext(); }
112 113
113 virtual void postTask(PassOwnPtr<ExecutionContextTask>) = 0; // Executes the task on context's thread asynchronously.
114
115 // Gets the next id in a circular sequence from 1 to 2^31-1. 114 // Gets the next id in a circular sequence from 1 to 2^31-1.
116 int circularSequentialID(); 115 int circularSequentialID();
117 116
118 void didChangeTimerAlignmentInterval(); 117 void didChangeTimerAlignmentInterval();
119 virtual double timerAlignmentInterval() const;
120
121 virtual EventQueue* eventQueue() const = 0;
122 118
123 void setDatabaseContext(DatabaseContext*); 119 void setDatabaseContext(DatabaseContext*);
124 120
125 protected: 121 protected:
126 122
127 ContextLifecycleNotifier* lifecycleNotifier(); 123 ContextLifecycleNotifier* lifecycleNotifier();
128 124
129 private: 125 private:
130 friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() be low. 126 friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() be low.
131 127
132 virtual const KURL& virtualURL() const = 0;
133 virtual KURL virtualCompleteURL(const String&) const = 0;
134
135 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, ScriptState*) = 0;
136 virtual EventTarget* errorEventTarget() = 0;
137 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) = 0;
138 bool dispatchErrorEvent(PassRefPtr<ErrorEvent>, AccessControlStatus); 128 bool dispatchErrorEvent(PassRefPtr<ErrorEvent>, AccessControlStatus);
139 129
140 void closeMessagePorts(); 130 void closeMessagePorts();
141 131
142 virtual void refExecutionContext() = 0; 132 virtual void refExecutionContext() = 0;
143 virtual void derefExecutionContext() = 0; 133 virtual void derefExecutionContext() = 0;
144 virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE; 134 virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE;
145 135
146 // Implementation details for DOMTimer. No other classes should call these f unctions. 136 // Implementation details for DOMTimer. No other classes should call these f unctions.
147 int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleS hot); 137 int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleS hot);
148 void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer ins tance destructed. 138 void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer ins tance destructed.
149 139
140 ExecutionContextClient* m_client;
150 HashSet<MessagePort*> m_messagePorts; 141 HashSet<MessagePort*> m_messagePorts;
151 142
152 int m_circularSequentialID; 143 int m_circularSequentialID;
153 typedef HashMap<int, OwnPtr<DOMTimer> > TimeoutMap; 144 typedef HashMap<int, OwnPtr<DOMTimer> > TimeoutMap;
154 TimeoutMap m_timeouts; 145 TimeoutMap m_timeouts;
155 146
156 bool m_inDispatchErrorEvent; 147 bool m_inDispatchErrorEvent;
157 class PendingException; 148 class PendingException;
158 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions; 149 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions;
159 150
160 bool m_activeDOMObjectsAreSuspended; 151 bool m_activeDOMObjectsAreSuspended;
161 bool m_activeDOMObjectsAreStopped; 152 bool m_activeDOMObjectsAreStopped;
162 153
163 OwnPtr<PublicURLManager> m_publicURLManager; 154 OwnPtr<PublicURLManager> m_publicURLManager;
164 155
165 RefPtr<DatabaseContext> m_databaseContext; 156 RefPtr<DatabaseContext> m_databaseContext;
166 157
167 // The location of this member is important; to make sure contextDestroyed() notification on 158 // The location of this member is important; to make sure contextDestroyed() notification on
168 // ExecutionContext's members (notably m_timeouts) is called before they are destructed, 159 // ExecutionContext's members (notably m_timeouts) is called before they are destructed,
169 // m_lifecycleNotifer should be placed *after* such members. 160 // m_lifecycleNotifer should be placed *after* such members.
170 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; 161 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier;
171 }; 162 };
172 163
173 } // namespace WebCore 164 } // namespace WebCore
174 165
175 #endif // ExecutionContext_h 166 #endif // ExecutionContext_h
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/ExecutionContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698