OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 #include "core/dom/ActiveDOMObject.h" | 31 #include "core/dom/ActiveDOMObject.h" |
32 #include "core/dom/ExecutionContextClient.h" | 32 #include "core/dom/ExecutionContextClient.h" |
33 #include "core/dom/SandboxFlags.h" | 33 #include "core/dom/SandboxFlags.h" |
34 #include "core/dom/SecurityContext.h" | 34 #include "core/dom/SecurityContext.h" |
35 #include "core/events/ErrorEvent.h" | 35 #include "core/events/ErrorEvent.h" |
36 #include "core/fetch/CrossOriginAccessControl.h" | 36 #include "core/fetch/CrossOriginAccessControl.h" |
37 #include "core/frame/ConsoleTypes.h" | 37 #include "core/frame/ConsoleTypes.h" |
38 #include "core/frame/DOMTimer.h" | 38 #include "core/frame/DOMTimer.h" |
39 #include "platform/LifecycleContext.h" | 39 #include "platform/LifecycleContext.h" |
40 #include "platform/Supplementable.h" | 40 #include "platform/Supplementable.h" |
| 41 #include "platform/heap/Handle.h" |
41 #include "platform/weborigin/KURL.h" | 42 #include "platform/weborigin/KURL.h" |
42 #include "wtf/Functional.h" | 43 #include "wtf/Functional.h" |
43 #include "wtf/OwnPtr.h" | 44 #include "wtf/OwnPtr.h" |
44 #include "wtf/PassOwnPtr.h" | 45 #include "wtf/PassOwnPtr.h" |
45 | 46 |
46 namespace WTF { | 47 namespace WTF { |
47 class OrdinalNumber; | 48 class OrdinalNumber; |
48 } | 49 } |
49 | 50 |
50 namespace WebCore { | 51 namespace WebCore { |
51 | 52 |
52 class ContextLifecycleNotifier; | 53 class ContextLifecycleNotifier; |
53 class DOMWindow; | 54 class DOMWindow; |
54 class EventListener; | 55 class EventListener; |
55 class EventQueue; | 56 class EventQueue; |
56 class EventTarget; | 57 class EventTarget; |
57 class ExecutionContextTask; | 58 class ExecutionContextTask; |
58 class ScriptState; | 59 class ScriptState; |
59 class PublicURLManager; | 60 class PublicURLManager; |
60 class SecurityOrigin; | 61 class SecurityOrigin; |
61 class ScriptCallStack; | 62 class ScriptCallStack; |
62 | 63 |
63 class ExecutionContext : public LifecycleContext<ExecutionContext>, public Suppl
ementable<ExecutionContext> { | 64 class ExecutionContext |
| 65 : public WillBeGarbageCollectedMixin |
| 66 , public LifecycleContext<ExecutionContext> |
| 67 , public Supplementable<ExecutionContext> { |
64 public: | 68 public: |
65 ExecutionContext(); | 69 ExecutionContext(); |
66 virtual ~ExecutionContext(); | 70 virtual ~ExecutionContext(); |
67 | 71 |
68 // Delegating to ExecutionContextClient | 72 // Delegating to ExecutionContextClient |
69 void setClient(ExecutionContextClient* client) { m_client = client; } | 73 void setClient(ExecutionContextClient* client) { m_client = client; } |
70 bool isDocument() const { return m_client && m_client->isDocument(); } | 74 bool isDocument() const { return m_client && m_client->isDocument(); } |
71 bool isWorkerGlobalScope() const { return m_client && m_client->isWorkerGlob
alScope(); } | 75 bool isWorkerGlobalScope() const { return m_client && m_client->isWorkerGlob
alScope(); } |
72 bool isJSExecutionForbidden() { return m_client && m_client->isJSExecutionFo
rbidden(); } | 76 bool isJSExecutionForbidden() { return m_client && m_client->isJSExecutionFo
rbidden(); } |
73 SecurityOrigin* securityOrigin() const; | 77 SecurityOrigin* securityOrigin() const; |
(...skipping 26 matching lines...) Expand all Loading... |
100 virtual void suspendScheduledTasks(); | 104 virtual void suspendScheduledTasks(); |
101 virtual void resumeScheduledTasks(); | 105 virtual void resumeScheduledTasks(); |
102 virtual bool tasksNeedSuspension() { return false; } | 106 virtual bool tasksNeedSuspension() { return false; } |
103 | 107 |
104 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp
ended; } | 108 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp
ended; } |
105 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe
d; } | 109 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe
d; } |
106 bool isIteratingOverObservers() const; | 110 bool isIteratingOverObservers() const; |
107 | 111 |
108 // Called after the construction of an ActiveDOMObject to synchronize suspen
d state. | 112 // Called after the construction of an ActiveDOMObject to synchronize suspen
d state. |
109 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); | 113 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); |
110 | 114 #if !ENABLE(OILPAN) |
111 void ref() { refExecutionContext(); } | 115 void ref() { refExecutionContext(); } |
112 void deref() { derefExecutionContext(); } | 116 void deref() { derefExecutionContext(); } |
| 117 #endif |
113 | 118 |
114 // Gets the next id in a circular sequence from 1 to 2^31-1. | 119 // Gets the next id in a circular sequence from 1 to 2^31-1. |
115 int circularSequentialID(); | 120 int circularSequentialID(); |
116 | 121 |
117 void didChangeTimerAlignmentInterval(); | 122 void didChangeTimerAlignmentInterval(); |
118 | 123 |
119 SandboxFlags sandboxFlags() const { return m_sandboxFlags; } | 124 SandboxFlags sandboxFlags() const { return m_sandboxFlags; } |
120 bool isSandboxed(SandboxFlags mask) const { return m_sandboxFlags & mask; } | 125 bool isSandboxed(SandboxFlags mask) const { return m_sandboxFlags & mask; } |
121 void enforceSandboxFlags(SandboxFlags mask); | 126 void enforceSandboxFlags(SandboxFlags mask); |
122 | 127 |
123 PassOwnPtr<LifecycleNotifier<ExecutionContext> > createLifecycleNotifier(); | 128 PassOwnPtr<LifecycleNotifier<ExecutionContext> > createLifecycleNotifier(); |
124 | 129 |
125 virtual EventQueue* eventQueue() const = 0; | 130 virtual EventQueue* eventQueue() const = 0; |
126 | 131 |
127 protected: | 132 protected: |
128 | 133 |
129 ContextLifecycleNotifier& lifecycleNotifier(); | 134 ContextLifecycleNotifier& lifecycleNotifier(); |
130 | 135 |
131 private: | 136 private: |
132 friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() be
low. | 137 friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() be
low. |
133 | 138 |
134 bool dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent>, AccessControlSta
tus); | 139 bool dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent>, AccessControlSta
tus); |
135 | 140 |
| 141 #if !ENABLE(OILPAN) |
136 virtual void refExecutionContext() = 0; | 142 virtual void refExecutionContext() = 0; |
137 virtual void derefExecutionContext() = 0; | 143 virtual void derefExecutionContext() = 0; |
| 144 #endif |
138 // LifecycleContext implementation. | 145 // LifecycleContext implementation. |
139 | 146 |
140 // Implementation details for DOMTimer. No other classes should call these f
unctions. | 147 // Implementation details for DOMTimer. No other classes should call these f
unctions. |
141 int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleS
hot); | 148 int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleS
hot); |
142 void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer ins
tance destructed. | 149 void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer ins
tance destructed. |
143 | 150 |
144 ExecutionContextClient* m_client; | 151 ExecutionContextClient* m_client; |
145 SandboxFlags m_sandboxFlags; | 152 SandboxFlags m_sandboxFlags; |
146 | 153 |
147 int m_circularSequentialID; | 154 int m_circularSequentialID; |
(...skipping 11 matching lines...) Expand all Loading... |
159 | 166 |
160 // The location of this member is important; to make sure contextDestroyed()
notification on | 167 // The location of this member is important; to make sure contextDestroyed()
notification on |
161 // ExecutionContext's members (notably m_timeouts) is called before they are
destructed, | 168 // ExecutionContext's members (notably m_timeouts) is called before they are
destructed, |
162 // m_lifecycleNotifer should be placed *after* such members. | 169 // m_lifecycleNotifer should be placed *after* such members. |
163 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; | 170 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; |
164 }; | 171 }; |
165 | 172 |
166 } // namespace WebCore | 173 } // namespace WebCore |
167 | 174 |
168 #endif // ExecutionContext_h | 175 #endif // ExecutionContext_h |
OLD | NEW |