OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "modules/presentation/PresentationSessionClientCallbacks.h" | |
7 | |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
9 #include "core/dom/DOMException.h" | |
10 #include "core/dom/ExceptionCode.h" | |
11 #include "modules/presentation/Presentation.h" | |
12 #include "modules/presentation/PresentationSession.h" | |
13 #include "public/platform/WebString.h" | |
14 #include "public/platform/modules/presentation/WebPresentationError.h" | |
15 | |
16 namespace blink { | |
17 | |
18 PresentationSessionClientCallbacks::PresentationSessionClientCallbacks( | |
19 PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, | |
20 Presentation* presentation) | |
21 : m_resolver(resolver) | |
22 , m_presentation(presentation) | |
23 { | |
24 ASSERT(m_resolver); | |
25 ASSERT(m_presentation); | |
26 } | |
27 | |
28 PresentationSessionClientCallbacks::~PresentationSessionClientCallbacks() | |
29 { | |
30 } | |
31 | |
32 // |session| takes ownership of |client| and |m_presentation| takes ownership of the session. | |
33 void PresentationSessionClientCallbacks::onSuccess(WebPresentationSessionClient* client) | |
34 { | |
35 ASSERT(client); | |
36 PresentationSession* session = PresentationSession::create(m_presentation->f rame(), client); | |
mlamouri (slow - plz ping)
2015/02/25 20:51:06
Could you rewrite that so it follows the same patt
whywhat
2015/02/25 22:46:52
I added the checks and fixed ownership of the para
| |
37 m_presentation->didCreateSession(session); | |
38 m_resolver->resolve(session); | |
39 } | |
40 | |
41 void PresentationSessionClientCallbacks::onError(WebPresentationError* error) | |
42 { | |
43 ASSERT(error); | |
44 // TODO(avayvod): figure out the mapping between WebPresentationError and | |
45 // DOMException error codes. | |
46 m_resolver->reject(DOMException::create(InvalidAccessError, error->message)) ; | |
mlamouri (slow - plz ping)
2015/02/25 20:51:06
ditto.
whywhat
2015/02/25 22:46:52
Done.
| |
47 | |
48 delete error; | |
49 } | |
50 | |
51 } // namespace blink | |
OLD | NEW |