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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.h

Issue 2867023002: [ServiceWorker] waitUntil() should wait until all promises got resolved/rejected. (Closed)
Patch Set: Remove old FIXME Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WaitUntilObserver_h 5 #ifndef WaitUntilObserver_h
6 #define WaitUntilObserver_h 6 #define WaitUntilObserver_h
7 7
8 #include "modules/ModulesExport.h" 8 #include "modules/ModulesExport.h"
9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" 9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
10 #include "platform/Timer.h" 10 #include "platform/Timer.h"
(...skipping 24 matching lines...) Expand all
35 kBackgroundFetchAbort, 35 kBackgroundFetchAbort,
36 kBackgroundFetchClick, 36 kBackgroundFetchClick,
37 kBackgroundFetchFail, 37 kBackgroundFetchFail,
38 kBackgroundFetched 38 kBackgroundFetched
39 }; 39 };
40 40
41 static WaitUntilObserver* Create(ExecutionContext*, EventType, int event_id); 41 static WaitUntilObserver* Create(ExecutionContext*, EventType, int event_id);
42 42
43 // Must be called before and after dispatching the event. 43 // Must be called before and after dispatching the event.
44 void WillDispatchEvent(); 44 void WillDispatchEvent();
45 void DidDispatchEvent(bool error_occurred); 45 void DidDispatchEvent(bool error_occurred);
falken 2017/05/09 08:07:31 I see, it's not from your patch but |error_occurre
leonhsl(Using Gerrit) 2017/05/10 05:03:34 Done.
46 46
47 // Observes the promise and delays calling the continuation until 47 // Observes the promise and delays calling the continuation until
48 // the given promise is resolved or rejected. 48 // the given promise is resolved or rejected.
49 void WaitUntil(ScriptState*, ScriptPromise, ExceptionState&); 49 void WaitUntil(ScriptState*, ScriptPromise, ExceptionState&);
50 50
51 // These methods can be called when the lifecycle of ExtendableEvent 51 // These methods can be called when the lifecycle of ExtendableEvent
52 // observed by this WaitUntilObserver should be extended by other reason 52 // observed by this WaitUntilObserver should be extended by other reason
53 // than ExtendableEvent.waitUntil. 53 // than ExtendableEvent.waitUntil.
54 // Note: There is no need to call decrementPendingActivity() after the context 54 // Note: There is no need to call decrementPendingActivity() after the context
55 // is being destroyed. 55 // is being destroyed.
56 void IncrementPendingActivity(); 56 void IncrementPendingActivity();
57 void DecrementPendingActivity(); 57 void DecrementPendingActivity();
58 58
59 DECLARE_VIRTUAL_TRACE(); 59 DECLARE_VIRTUAL_TRACE();
60 60
61 private: 61 private:
62 friend class InternalsServiceWorker; 62 friend class InternalsServiceWorker;
63 class ThenFunction; 63 class ThenFunction;
64 64
65 WaitUntilObserver(ExecutionContext*, EventType, int event_id); 65 WaitUntilObserver(ExecutionContext*, EventType, int event_id);
66 66
67 void ReportError(const ScriptValue&); 67 void ReportPromiseRejected(const ScriptValue&);
falken 2017/05/09 08:07:31 Maybe just "OnPromiseRejected", as it's not really
leonhsl(Using Gerrit) 2017/05/10 05:03:34 Removed this method, DecrementPendingActivity() co
68 68
69 void ConsumeWindowInteraction(TimerBase*); 69 void ConsumeWindowInteraction(TimerBase*);
70 70
71 Member<ExecutionContext> execution_context_; 71 Member<ExecutionContext> execution_context_;
72 EventType type_; 72 EventType type_;
73 int event_id_; 73 int event_id_;
74 int pending_activity_ = 0; 74 int pending_activity_ = 0;
75 bool has_error_ = false; 75 bool has_error_ = false;
76 bool has_rejected_promise_ = false;
76 bool event_dispatched_ = false; 77 bool event_dispatched_ = false;
falken 2017/05/09 08:07:31 Actually, instead of |has_error_| and |event_dispa
leonhsl(Using Gerrit) 2017/05/10 05:03:34 Done.
77 double event_dispatch_time_ = 0; 78 double event_dispatch_time_ = 0;
78 TaskRunnerTimer<WaitUntilObserver> consume_window_interaction_timer_; 79 TaskRunnerTimer<WaitUntilObserver> consume_window_interaction_timer_;
79 }; 80 };
80 81
81 } // namespace blink 82 } // namespace blink
82 83
83 #endif // WaitUntilObserver_h 84 #endif // WaitUntilObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698