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

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: rebase with master 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
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationRequest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return rejectWithSandBoxException(scriptState); 182 return rejectWithSandBoxException(scriptState);
183 183
184 WebPresentationClient* client = presentationClient(getExecutionContext()); 184 WebPresentationClient* client = presentationClient(getExecutionContext());
185 if (!client) 185 if (!client)
186 return ScriptPromise::rejectWithDOMException( 186 return ScriptPromise::rejectWithDOMException(
187 scriptState, 187 scriptState,
188 DOMException::create( 188 DOMException::create(
189 InvalidStateError, 189 InvalidStateError,
190 "The PresentationRequest is no longer associated to a frame.")); 190 "The PresentationRequest is no longer associated to a frame."));
191 191
192 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 192 if (!m_availabilityProperty) {
193 client->getAvailability( 193 m_availabilityProperty = new PresentationAvailabilityProperty(
194 m_url, 194 scriptState->getExecutionContext(), this,
195 WTF::makeUnique<PresentationAvailabilityCallbacks>(resolver, m_url)); 195 PresentationAvailabilityProperty::Ready);
196 return resolver->promise(); 196
197 client->getAvailability(m_url,
198 WTF::makeUnique<PresentationAvailabilityCallbacks>(
199 m_availabilityProperty, m_url));
200 }
201 return m_availabilityProperty->promise(scriptState->world());
197 } 202 }
198 203
199 const KURL& PresentationRequest::url() const { 204 const KURL& PresentationRequest::url() const {
200 return m_url; 205 return m_url;
201 } 206 }
202 207
203 DEFINE_TRACE(PresentationRequest) { 208 DEFINE_TRACE(PresentationRequest) {
209 visitor->trace(m_availabilityProperty);
204 EventTargetWithInlineData::trace(visitor); 210 EventTargetWithInlineData::trace(visitor);
205 SuspendableObject::trace(visitor); 211 SuspendableObject::trace(visitor);
206 } 212 }
207 213
208 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, 214 PresentationRequest::PresentationRequest(ExecutionContext* executionContext,
209 const KURL& url) 215 const KURL& url)
210 : SuspendableObject(executionContext), m_url(url) {} 216 : SuspendableObject(executionContext), m_url(url) {}
211 217
212 } // namespace blink 218 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698