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

Side by Side Diff: Source/modules/serviceworkers/RespondWithObserver.cpp

Issue 181173002: ScriptPromise should check the constructor paraemter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 9 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 #include "config.h" 5 #include "config.h"
6 #include "modules/serviceworkers/RespondWithObserver.h" 6 #include "modules/serviceworkers/RespondWithObserver.h"
7 7
8 #include "V8Response.h" 8 #include "V8Response.h"
9 #include "bindings/v8/ScriptFunction.h" 9 #include "bindings/v8/ScriptFunction.h"
10 #include "bindings/v8/ScriptPromise.h" 10 #include "bindings/v8/ScriptPromise.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (m_state == Initial) 74 if (m_state == Initial)
75 sendResponse(nullptr); 75 sendResponse(nullptr);
76 } 76 }
77 77
78 void RespondWithObserver::respondWith(const ScriptValue& value) 78 void RespondWithObserver::respondWith(const ScriptValue& value)
79 { 79 {
80 if (m_state != Initial) 80 if (m_state != Initial)
81 return; 81 return;
82 82
83 m_state = Pending; 83 m_state = Pending;
84 ScriptPromise(value).then( 84 ScriptPromise::cast(value).then(
85 ThenFunction::create(this, ThenFunction::Fulfilled), 85 ThenFunction::create(this, ThenFunction::Fulfilled),
86 ThenFunction::create(this, ThenFunction::Rejected)); 86 ThenFunction::create(this, ThenFunction::Rejected));
87 } 87 }
88 88
89 void RespondWithObserver::sendResponse(PassRefPtr<Response> response) 89 void RespondWithObserver::sendResponse(PassRefPtr<Response> response)
90 { 90 {
91 if (!executionContext()) 91 if (!executionContext())
92 return; 92 return;
93 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID, response); 93 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID, response);
94 m_state = Done; 94 m_state = Done;
(...skipping 18 matching lines...) Expand all
113 } 113 }
114 114
115 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) 115 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID)
116 : ContextLifecycleObserver(context) 116 : ContextLifecycleObserver(context)
117 , m_eventID(eventID) 117 , m_eventID(eventID)
118 , m_state(Initial) 118 , m_state(Initial)
119 { 119 {
120 } 120 }
121 121
122 } // namespace WebCore 122 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptPromiseTest.cpp ('k') | Source/modules/serviceworkers/WaitUntilObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698