1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WaitUntilObserver_h
6 #define WaitUntilObserver_h
8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
10 #include "wtf/Forward.h"
11 #include "wtf/RefCounted.h"
15 class ExecutionContext;
18 // Created for each InstallPhaseEvent instance.
19 class WaitUntilObserver FINAL :
20 public ContextLifecycleObserver,
21 public RefCounted<WaitUntilObserver> {
23 static PassRefPtr<WaitUntilObserver> create(ExecutionContext*, int eventID);
27 // Must be called before and after dispatching the event.
28 void willDispatchEvent();
29 void didDispatchEvent();
31 // Observes the promise and delays calling didHandleInstallEvent() until
32 // the given promise is resolved or rejected.
33 void waitUntil(const ScriptValue&);
38 WaitUntilObserver(ExecutionContext*, int eventID);
40 void reportError(const ScriptValue&);
42 void incrementPendingActivity();
43 void decrementPendingActivity();
46 int m_pendingActivity;
49 } // namespace WebCore
51 #endif // WaitUntilObserver_h