Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/PresentationSessionClientCallbacks.h" | 6 #include "modules/presentation/PresentationSessionClientCallbacks.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 "core/dom/DOMException.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 } | 32 } |
| 33 | 33 |
| 34 void PresentationSessionClientCallbacks::onSuccess(WebPresentationSessionClient* client) | 34 void PresentationSessionClientCallbacks::onSuccess(WebPresentationSessionClient* client) |
| 35 { | 35 { |
| 36 ASSERT(client); | 36 ASSERT(client); |
| 37 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) { | 37 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) { |
| 38 PresentationSession::dispose(client); | 38 PresentationSession::dispose(client); |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 m_resolver->resolve(PresentationSession::take(client, m_presentation)); | 42 PresentationSession* session = PresentationSession::take(client, m_presentat ion); |
| 43 session->didChangeState(WebPresentationSessionState::Connected); | |
|
whywhat
2015/06/25 17:33:45
Seems wasteful to dispatch an event to just create
haibinlu
2015/06/25 18:45:36
Make sense. Pass in the initial state.
| |
| 44 m_resolver->resolve(session); | |
| 43 } | 45 } |
| 44 | 46 |
| 45 void PresentationSessionClientCallbacks::onError(WebPresentationError* error) | 47 void PresentationSessionClientCallbacks::onError(WebPresentationError* error) |
| 46 { | 48 { |
| 47 ASSERT(error); | 49 ASSERT(error); |
| 48 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) { | 50 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) { |
| 49 PresentationError::dispose(error); | 51 PresentationError::dispose(error); |
| 50 return; | 52 return; |
| 51 } | 53 } |
| 52 | 54 |
| 53 m_resolver->reject(PresentationError::take(error)); | 55 m_resolver->reject(PresentationError::take(error)); |
| 54 } | 56 } |
| 55 | 57 |
| 56 } // namespace blink | 58 } // namespace blink |
| OLD | NEW |