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

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

Issue 16988003: Revert "Extract ContextLifecycleNotifier from ScriptExecutionContext." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
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 20 matching lines...) Expand all
31 #include "core/dom/ActiveDOMObject.h" 31 #include "core/dom/ActiveDOMObject.h"
32 #include "core/dom/SecurityContext.h" 32 #include "core/dom/SecurityContext.h"
33 #include "core/page/ConsoleTypes.h" 33 #include "core/page/ConsoleTypes.h"
34 #include "core/platform/Supplementable.h" 34 #include "core/platform/Supplementable.h"
35 #include "weborigin/KURL.h" 35 #include "weborigin/KURL.h"
36 #include "wtf/HashSet.h" 36 #include "wtf/HashSet.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 class CachedScript; 40 class CachedScript;
41 class ContextLifecycleNotifier;
42 class DatabaseContext; 41 class DatabaseContext;
43 class DOMTimer; 42 class DOMTimer;
44 class EventListener; 43 class EventListener;
45 class EventQueue; 44 class EventQueue;
46 class EventTarget; 45 class EventTarget;
47 class MessagePort; 46 class MessagePort;
48 class PublicURLManager; 47 class PublicURLManager;
49 class ScriptCallStack; 48 class ScriptCallStack;
50 class ScriptState; 49 class ScriptState;
51 50
(...skipping 20 matching lines...) Expand all
72 71
73 void addConsoleMessage(MessageSource, MessageLevel, const String& message, c onst String& sourceURL, unsigned lineNumber, ScriptState* = 0, unsigned long req uestIdentifier = 0); 72 void addConsoleMessage(MessageSource, MessageLevel, const String& message, c onst String& sourceURL, unsigned lineNumber, ScriptState* = 0, unsigned long req uestIdentifier = 0);
74 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& me ssage, unsigned long requestIdentifier = 0) = 0; 73 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& me ssage, unsigned long requestIdentifier = 0) = 0;
75 74
76 virtual const SecurityOrigin* topOrigin() const = 0; 75 virtual const SecurityOrigin* topOrigin() const = 0;
77 76
78 PublicURLManager& publicURLManager(); 77 PublicURLManager& publicURLManager();
79 78
80 // Active objects are not garbage collected even if inaccessible, e.g. becau se their activity may result in callbacks being invoked. 79 // Active objects are not garbage collected even if inaccessible, e.g. becau se their activity may result in callbacks being invoked.
81 bool canSuspendActiveDOMObjects(); 80 bool canSuspendActiveDOMObjects();
82 bool hasPendingActivity();
83
84 // Active objects can be asked to suspend even if canSuspendActiveDOMObjects () returns 'false' - 81 // Active objects can be asked to suspend even if canSuspendActiveDOMObjects () returns 'false' -
85 // step-by-step JS debugging is one example. 82 // step-by-step JS debugging is one example.
86 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); 83 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension);
87 virtual void resumeActiveDOMObjects(); 84 virtual void resumeActiveDOMObjects();
88 virtual void stopActiveDOMObjects(); 85 virtual void stopActiveDOMObjects();
89 86
90 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp ended; } 87 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp ended; }
91 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe d; } 88 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe d; }
92 89
90 // Called from the constructor and destructors of ActiveDOMObject.
91 void didCreateActiveDOMObject(ActiveDOMObject*);
92 void willDestroyActiveDOMObject(ActiveDOMObject*);
93
93 // Called after the construction of an ActiveDOMObject to synchronize suspen d state. 94 // Called after the construction of an ActiveDOMObject to synchronize suspen d state.
94 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); 95 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*);
95 96
96 // Called from the constructor and destructors of ContextDestructionObserver 97 typedef HashSet<ActiveDOMObject*> ActiveDOMObjectsSet;
97 void wasObservedBy(ContextDestructionObserver*, ContextDestructionObserver:: Type as); 98 const ActiveDOMObjectsSet& activeDOMObjects() const { return m_activeDOMObje cts; }
98 void wasUnobservedBy(ContextDestructionObserver*, ContextDestructionObserver ::Type as); 99
100 void didCreateDestructionObserver(ContextDestructionObserver*);
101 void willDestroyDestructionObserver(ContextDestructionObserver*);
99 102
100 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be tracked separately for message dispatch. 103 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be tracked separately for message dispatch.
101 void processMessagePortMessagesSoon(); 104 void processMessagePortMessagesSoon();
102 void dispatchMessagePortEvents(); 105 void dispatchMessagePortEvents();
103 void createdMessagePort(MessagePort*); 106 void createdMessagePort(MessagePort*);
104 void destroyedMessagePort(MessagePort*); 107 void destroyedMessagePort(MessagePort*);
105 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; } 108 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; }
106 109
107 void ref() { refScriptExecutionContext(); } 110 void ref() { refScriptExecutionContext(); }
108 void deref() { derefScriptExecutionContext(); } 111 void deref() { derefScriptExecutionContext(); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 : m_source(source) 152 : m_source(source)
150 , m_level(level) 153 , m_level(level)
151 , m_message(message.isolatedCopy()) 154 , m_message(message.isolatedCopy())
152 { 155 {
153 } 156 }
154 MessageSource m_source; 157 MessageSource m_source;
155 MessageLevel m_level; 158 MessageLevel m_level;
156 String m_message; 159 String m_message;
157 }; 160 };
158 161
159 ContextLifecycleNotifier* lifecycleNotifier();
160
161 private: 162 private:
162 virtual const KURL& virtualURL() const = 0; 163 virtual const KURL& virtualURL() const = 0;
163 virtual KURL virtualCompleteURL(const String&) const = 0; 164 virtual KURL virtualCompleteURL(const String&) const = 0;
164 165
165 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip tState* = 0, unsigned long requestIdentifier = 0) = 0; 166 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip tState* = 0, unsigned long requestIdentifier = 0) = 0;
166 virtual EventTarget* errorEventTarget() = 0; 167 virtual EventTarget* errorEventTarget() = 0;
167 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0; 168 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0;
168 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const St ring& sourceURL, CachedScript*); 169 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const St ring& sourceURL, CachedScript*);
169 170
170 void closeMessagePorts(); 171 void closeMessagePorts();
171 172
172 virtual void refScriptExecutionContext() = 0; 173 virtual void refScriptExecutionContext() = 0;
173 virtual void derefScriptExecutionContext() = 0; 174 virtual void derefScriptExecutionContext() = 0;
174 virtual PassOwnPtr<ContextLifecycleNotifier> createLifecycleNotifier();
175 175
176 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier;
177 HashSet<MessagePort*> m_messagePorts; 176 HashSet<MessagePort*> m_messagePorts;
177 HashSet<ContextDestructionObserver*> m_destructionObservers;
178 ActiveDOMObjectsSet m_activeDOMObjects;
179 bool m_iteratingActiveDOMObjects;
180 bool m_inDestructor;
178 181
179 int m_circularSequentialID; 182 int m_circularSequentialID;
180 typedef HashMap<int, DOMTimer*> TimeoutMap; 183 typedef HashMap<int, DOMTimer*> TimeoutMap;
181 TimeoutMap m_timeouts; 184 TimeoutMap m_timeouts;
182 185
183 bool m_inDispatchErrorEvent; 186 bool m_inDispatchErrorEvent;
184 class PendingException; 187 class PendingException;
185 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions; 188 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions;
186 189
187 bool m_activeDOMObjectsAreSuspended; 190 bool m_activeDOMObjectsAreSuspended;
188 ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects; 191 ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects;
189 bool m_activeDOMObjectsAreStopped; 192 bool m_activeDOMObjectsAreStopped;
190 193
191 OwnPtr<PublicURLManager> m_publicURLManager; 194 OwnPtr<PublicURLManager> m_publicURLManager;
192 195
193 RefPtr<DatabaseContext> m_databaseContext; 196 RefPtr<DatabaseContext> m_databaseContext;
194 }; 197 };
195 198
196 } // namespace WebCore 199 } // namespace WebCore
197 200
198 #endif // ScriptExecutionContext_h 201 #endif // ScriptExecutionContext_h
OLDNEW
« no previous file with comments | « Source/core/dom/DocumentLifecycleObserver.cpp ('k') | Source/core/dom/ScriptExecutionContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698