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