Chromium Code Reviews| Index: Source/modules/presentation/PresentationSessionClientCallbacks.cpp |
| diff --git a/Source/modules/presentation/PresentationSessionClientCallbacks.cpp b/Source/modules/presentation/PresentationSessionClientCallbacks.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c08c3f135ffb57fc54314b8867a816b2b7c1dcff |
| --- /dev/null |
| +++ b/Source/modules/presentation/PresentationSessionClientCallbacks.cpp |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "modules/presentation/PresentationSessionClientCallbacks.h" |
| + |
| +#include "bindings/core/v8/ScriptPromiseResolver.h" |
| +#include "core/dom/DOMException.h" |
| +#include "core/dom/ExceptionCode.h" |
| +#include "modules/presentation/Presentation.h" |
| +#include "modules/presentation/PresentationSession.h" |
| +#include "public/platform/WebString.h" |
| +#include "public/platform/modules/presentation/WebPresentationError.h" |
| + |
| +namespace blink { |
| + |
| +PresentationSessionClientCallbacks::PresentationSessionClientCallbacks( |
| + PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, |
| + Presentation* presentation) |
| + : m_resolver(resolver) |
| + , m_presentation(presentation) |
| +{ |
| + ASSERT(m_resolver); |
| + ASSERT(m_presentation); |
| +} |
| + |
| +PresentationSessionClientCallbacks::~PresentationSessionClientCallbacks() |
| +{ |
| +} |
| + |
| +// |session| takes ownership of |client| and |m_presentation| takes ownership of the session. |
| +void PresentationSessionClientCallbacks::onSuccess(WebPresentationSessionClient* client) |
| +{ |
| + ASSERT(client); |
| + PresentationSession* session = PresentationSession::create(m_presentation->frame(), client); |
| + m_presentation->didCreateSession(session); |
| + m_resolver->resolve(session); |
| + delete this; |
|
mlamouri (slow - plz ping)
2015/02/23 13:46:10
Do not call |delete this|. Let the embedder do it.
mlamouri (slow - plz ping)
2015/02/23 13:46:11
Do not call |delete this|. Let the embedder do it.
whywhat
2015/02/25 14:11:06
Done.
whywhat
2015/02/25 14:11:06
Done.
|
| +} |
| + |
| +void PresentationSessionClientCallbacks::onError(WebPresentationError* error) |
| +{ |
| + ASSERT(error); |
| + // TODO(avayvod): figure out the mapping between WebPresentationError and |
| + // DOMException error codes. |
| + m_resolver->reject(DOMException::create(InvalidAccessError, error->message)); |
| + |
| + delete error; |
| + delete this; |
|
mlamouri (slow - plz ping)
2015/02/23 13:46:10
ditto.
whywhat
2015/02/25 14:11:06
Done.
|
| +} |
| + |
| +} // namespace blink |