Index: Source/core/inspector/PromiseTracker.h |
diff --git a/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h b/Source/core/inspector/PromiseTracker.h |
similarity index 51% |
copy from Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h |
copy to Source/core/inspector/PromiseTracker.h |
index 4b01763f0c3fd90706e5dd6b34bc2665b9cc23cb..150930d7e361dfd1b5df6a8e47963ffecfa714c1 100644 |
--- a/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h |
+++ b/Source/core/inspector/PromiseTracker.h |
@@ -28,37 +28,60 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef ServiceWorkerGlobalScopeClient_h |
-#define ServiceWorkerGlobalScopeClient_h |
+#ifndef PromiseTracker_h |
+#define PromiseTracker_h |
-#include "core/workers/WorkerClients.h" |
-#include "wtf/Forward.h" |
+#include "bindings/v8/custom/V8PromiseCustom.h" |
+#include "bindings/v8/ScriptObjectTraits.h" |
+#include "core/inspector/ScriptCallStack.h" |
+#include "wtf/HashMap.h" |
#include "wtf/Noncopyable.h" |
+#include "wtf/RefPtr.h" |
namespace WebCore { |
class ExecutionContext; |
-class Response; |
-class WorkerClients; |
-class ServiceWorkerGlobalScopeClient : public Supplement<WorkerClients> { |
- WTF_MAKE_NONCOPYABLE(ServiceWorkerGlobalScopeClient); |
+class PromiseTracker { |
+ WTF_MAKE_NONCOPYABLE(PromiseTracker); |
public: |
- virtual ~ServiceWorkerGlobalScopeClient() { } |
+ PromiseTracker() : m_isEnabled(false) { } |
- virtual void didHandleInstallEvent(int installEventID) = 0; |
- // A null response means no valid response was provided by the service worker, so fallback to native. |
- virtual void didHandleFetchEvent(int fetchEventID, PassRefPtr<Response> = nullptr) = 0; |
+ bool isEnabled() const { return m_isEnabled; } |
+ void enable(); |
+ void disable(); |
- static const char* supplementName(); |
- static ServiceWorkerGlobalScopeClient* from(ExecutionContext*); |
+ void clear(); |
-protected: |
- ServiceWorkerGlobalScopeClient() { } |
-}; |
+ void didCreatePromise(const ScriptObject& promise); |
+ void didUpdatePromiseParent(const ScriptObject& promise, const ScriptObject& parentPromise); |
+ void didUpdatePromiseState(const ScriptObject& promise, V8PromiseCustom::PromiseState, const ScriptValue& result); |
+ |
+private: |
+ class PromiseData : public RefCounted<PromiseData> { |
+ public: |
+ PromiseData(const ScriptObject& promise, const ScriptObject& parentPromise, const ScriptValue& result, V8PromiseCustom::PromiseState state, double timestamp); |
+ |
+ void didSettlePromise(double timestamp); |
+ |
+ ScriptObject m_promise; |
+ ScriptObject m_parentPromise; |
+ ScriptValue m_result; |
+ V8PromiseCustom::PromiseState m_state; |
-void provideServiceWorkerGlobalScopeClientToWorker(WorkerClients*, PassOwnPtr<ServiceWorkerGlobalScopeClient>); |
+ // Time in milliseconds. |
+ double m_timeOnCreate; |
+ double m_timeOnSettle; |
+ |
+ RefPtr<ScriptCallStack> m_callStackOnCreate; |
+ RefPtr<ScriptCallStack> m_callStackOnSettle; |
+ }; |
+ |
+ bool m_isEnabled; |
+ typedef HashMap<ScriptObject, RefPtr<PromiseData>, ScriptObjectHash, ScriptObjectHashTraits> PromiseDataMap; |
+ PromiseDataMap m_promiseDataMap; |
+}; |
} // namespace WebCore |
-#endif // ServiceWorkerGlobalScopeClient_h |
+#endif // !defined(PromiseTracker_h) |