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

Side by Side Diff: Source/modules/presentation/PresentationAvailabilityCallback.cpp

Issue 1212423003: Presentation API: Blink changes to allow getAvailability() to be rejected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@presentation-availability-cleanups
Patch Set: Created 5 years, 5 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 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 "config.h" 5 #include "config.h"
6 #include "modules/presentation/PresentationAvailabilityCallback.h" 6 #include "modules/presentation/PresentationAvailabilityCallback.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h"
9 #include "modules/presentation/PresentationAvailability.h" 10 #include "modules/presentation/PresentationAvailability.h"
11 #include "modules/presentation/PresentationError.h"
10 12
11 namespace blink { 13 namespace blink {
12 14
13 PresentationAvailabilityCallback::PresentationAvailabilityCallback(PassRefPtr<Sc riptPromiseResolver> resolver) 15 PresentationAvailabilityCallback::PresentationAvailabilityCallback(PassRefPtr<Sc riptPromiseResolver> resolver)
14 : m_resolver(resolver) 16 : m_resolver(resolver)
15 { 17 {
16 ASSERT(m_resolver); 18 ASSERT(m_resolver);
17 } 19 }
18 20
19 void PresentationAvailabilityCallback::onSuccess(bool* result) 21 void PresentationAvailabilityCallback::onSuccess(bool* result)
20 { 22 {
21 OwnPtr<bool> availability = adoptPtr(result); 23 OwnPtr<bool> availability = adoptPtr(result);
22 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) 24 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped())
23 return; 25 return;
24 m_resolver->resolve(PresentationAvailability::take(m_resolver.get(), *availa bility)); 26 m_resolver->resolve(PresentationAvailability::take(m_resolver.get(), *availa bility));
25 } 27 }
26 28
27 void PresentationAvailabilityCallback::onError() 29 void PresentationAvailabilityCallback::onError(WebPresentationError* result)
28 { 30 {
31 OwnPtr<WebPresentationError> error = adoptPtr(result);
29 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) 32 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped())
30 return; 33 return;
31 m_resolver->reject(); 34 m_resolver->reject(PresentationError::take(*error));
32 } 35 }
33 36
34 } // namespace blink 37 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/presentation/PresentationAvailabilityCallback.h ('k') | Source/modules/presentation/PresentationController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698