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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationAvailabilityCallbacks.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
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/PresentationAvailabilityCallbacks.h" 5 #include "modules/presentation/PresentationAvailabilityCallbacks.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "modules/presentation/PresentationAvailability.h" 9 #include "modules/presentation/PresentationAvailability.h"
10 #include "modules/presentation/PresentationError.h" 10 #include "modules/presentation/PresentationError.h"
11 #include "modules/presentation/PresentationRequest.h"
11 #include "public/platform/modules/presentation/WebPresentationError.h" 12 #include "public/platform/modules/presentation/WebPresentationError.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 PresentationAvailabilityCallbacks::PresentationAvailabilityCallbacks( 16 PresentationAvailabilityCallbacks::PresentationAvailabilityCallbacks(
16 ScriptPromiseResolver* resolver, 17 PresentationAvailabilityProperty* resolver,
17 const KURL& url) 18 const KURL& url)
18 : m_resolver(resolver), m_url(url) { 19 : m_resolver(resolver), m_url(url) {
19 ASSERT(m_resolver); 20 ASSERT(m_resolver);
20 } 21 }
21 22
22 PresentationAvailabilityCallbacks::~PresentationAvailabilityCallbacks() {} 23 PresentationAvailabilityCallbacks::~PresentationAvailabilityCallbacks() {}
23 24
24 void PresentationAvailabilityCallbacks::onSuccess(bool value) { 25 void PresentationAvailabilityCallbacks::onSuccess(bool value) {
25 if (!m_resolver->getExecutionContext() || 26 if (!m_resolver->getExecutionContext() ||
26 m_resolver->getExecutionContext()->isContextDestroyed()) 27 m_resolver->getExecutionContext()->isContextDestroyed())
27 return; 28 return;
28 m_resolver->resolve( 29 m_resolver->resolve(
29 PresentationAvailability::take(m_resolver.get(), m_url, value)); 30 PresentationAvailability::take(m_resolver.get(), m_url, value));
30 } 31 }
31 32
32 void PresentationAvailabilityCallbacks::onError( 33 void PresentationAvailabilityCallbacks::onError(
33 const WebPresentationError& error) { 34 const WebPresentationError& error) {
34 if (!m_resolver->getExecutionContext() || 35 if (!m_resolver->getExecutionContext() ||
35 m_resolver->getExecutionContext()->isContextDestroyed()) 36 m_resolver->getExecutionContext()->isContextDestroyed())
36 return; 37 return;
37 m_resolver->reject(PresentationError::take(m_resolver.get(), error)); 38 m_resolver->reject(PresentationError::take(error));
38 } 39 }
39 40
40 } // namespace blink 41 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698