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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ExtendableEvent.cpp

Issue 2877543003: [ServiceWorker] Allow waitUntil to be called multiple times asynchronously (Closed)
Patch Set: Let RespondWithObserver call WaitUntilObserver::WaitUntil to add extend lifetime promise 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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const ExtendableEventInit& event_init, 45 const ExtendableEventInit& event_init,
46 WaitUntilObserver* observer) { 46 WaitUntilObserver* observer) {
47 return new ExtendableEvent(type, event_init, observer); 47 return new ExtendableEvent(type, event_init, observer);
48 } 48 }
49 49
50 ExtendableEvent::~ExtendableEvent() {} 50 ExtendableEvent::~ExtendableEvent() {}
51 51
52 void ExtendableEvent::waitUntil(ScriptState* script_state, 52 void ExtendableEvent::waitUntil(ScriptState* script_state,
53 ScriptPromise script_promise, 53 ScriptPromise script_promise,
54 ExceptionState& exception_state) { 54 ExceptionState& exception_state) {
55 if (observer_) 55 // WPT test:
56 observer_->WaitUntil(script_state, script_promise, exception_state); 56 // external/wpt/service-workers/service-worker/
57 // extendable-event-async-waituntil.https.html
58 // 'Test calling waitUntil on a script constructed ExtendableEvent throws
59 // exception'
falken 2017/05/25 07:23:23 Ah sorry I meant to just link in the codereview.
leonhsl(Using Gerrit) 2017/05/25 10:11:36 Oops, got it, removed this comment and updated CL
60 if (!observer_) {
61 exception_state.ThrowDOMException(
62 kInvalidStateError,
63 "Can not call waitUntil on a script constructed ExtendableEvent.");
64 return;
65 }
66
67 observer_->WaitUntil(script_state, script_promise, exception_state);
57 } 68 }
58 69
59 ExtendableEvent::ExtendableEvent(const AtomicString& type, 70 ExtendableEvent::ExtendableEvent(const AtomicString& type,
60 const ExtendableEventInit& initializer) 71 const ExtendableEventInit& initializer)
61 : Event(type, initializer) {} 72 : Event(type, initializer) {}
62 73
63 ExtendableEvent::ExtendableEvent(const AtomicString& type, 74 ExtendableEvent::ExtendableEvent(const AtomicString& type,
64 const ExtendableEventInit& initializer, 75 const ExtendableEventInit& initializer,
65 WaitUntilObserver* observer) 76 WaitUntilObserver* observer)
66 : Event(type, initializer), observer_(observer) {} 77 : Event(type, initializer), observer_(observer) {}
67 78
68 const AtomicString& ExtendableEvent::InterfaceName() const { 79 const AtomicString& ExtendableEvent::InterfaceName() const {
69 return EventNames::ExtendableEvent; 80 return EventNames::ExtendableEvent;
70 } 81 }
71 82
72 DEFINE_TRACE(ExtendableEvent) { 83 DEFINE_TRACE(ExtendableEvent) {
73 visitor->Trace(observer_); 84 visitor->Trace(observer_);
74 Event::Trace(visitor); 85 Event::Trace(visitor);
75 } 86 }
76 87
77 } // namespace blink 88 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698