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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp

Issue 2572473003: [Presentation API] PresentationRequest::getAvailability() should return the same promise (Closed)
Patch Set: Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/presentation/PresentationRequest.h" 5 #include "modules/presentation/PresentationRequest.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return rejectWithSandBoxException(scriptState); 185 return rejectWithSandBoxException(scriptState);
186 186
187 WebPresentationClient* client = presentationClient(getExecutionContext()); 187 WebPresentationClient* client = presentationClient(getExecutionContext());
188 if (!client) 188 if (!client)
189 return ScriptPromise::rejectWithDOMException( 189 return ScriptPromise::rejectWithDOMException(
190 scriptState, 190 scriptState,
191 DOMException::create( 191 DOMException::create(
192 InvalidStateError, 192 InvalidStateError,
193 "The PresentationRequest is no longer associated to a frame.")); 193 "The PresentationRequest is no longer associated to a frame."));
194 194
195 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 195 if (!m_availabilityProperty) {
196 client->getAvailability( 196 m_availabilityProperty = new PresentationAvailabilityProperty(
197 m_url, 197 scriptState->getExecutionContext(), this,
198 WTF::makeUnique<PresentationAvailabilityCallbacks>(resolver, m_url)); 198 PresentationAvailabilityProperty::Ready);
199 return resolver->promise(); 199
200 client->getAvailability(m_url,
201 WTF::makeUnique<PresentationAvailabilityCallbacks>(
202 m_availabilityProperty, m_url));
203 }
204 return m_availabilityProperty->promise(scriptState->world());
200 } 205 }
201 206
202 const KURL& PresentationRequest::url() const { 207 const KURL& PresentationRequest::url() const {
203 return m_url; 208 return m_url;
204 } 209 }
205 210
206 DEFINE_TRACE(PresentationRequest) { 211 DEFINE_TRACE(PresentationRequest) {
212 visitor->trace(m_availabilityProperty);
207 EventTargetWithInlineData::trace(visitor); 213 EventTargetWithInlineData::trace(visitor);
208 ActiveDOMObject::trace(visitor); 214 ActiveDOMObject::trace(visitor);
209 } 215 }
210 216
211 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, 217 PresentationRequest::PresentationRequest(ExecutionContext* executionContext,
212 const KURL& url) 218 const KURL& url)
213 : ActiveScriptWrappable(this), 219 : ActiveScriptWrappable(this),
214 ActiveDOMObject(executionContext), 220 ActiveDOMObject(executionContext),
215 m_url(url) {} 221 m_url(url) {}
216 222
217 } // namespace blink 223 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698