Chromium Code Reviews| Index: third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
| diff --git a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
| index 0d8b3b2d609eece6c65b98351d926e6a939aa070..2ab4ffe31d45cb73b8dccf3539c16110d89a48ce 100644 |
| --- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
| +++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
| @@ -9,6 +9,7 @@ |
| #include "core/dom/DOMArrayBufferView.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/ExceptionCode.h" |
| +#include "core/dom/ExecutionContextTask.h" |
| #include "core/events/Event.h" |
| #include "core/events/MessageEvent.h" |
| #include "core/fileapi/FileReaderLoader.h" |
| @@ -46,11 +47,14 @@ WebPresentationClient* presentationClient(ExecutionContext* executionContext) { |
| const AtomicString& connectionStateToString( |
| WebPresentationConnectionState state) { |
| + DEFINE_STATIC_LOCAL(const AtomicString, connectingValue, ("connecting")); |
| DEFINE_STATIC_LOCAL(const AtomicString, connectedValue, ("connected")); |
| DEFINE_STATIC_LOCAL(const AtomicString, closedValue, ("closed")); |
| DEFINE_STATIC_LOCAL(const AtomicString, terminatedValue, ("terminated")); |
| switch (state) { |
| + case WebPresentationConnectionState::Connecting: |
| + return connectingValue; |
| case WebPresentationConnectionState::Connected: |
| return connectedValue; |
| case WebPresentationConnectionState::Closed: |
| @@ -404,19 +408,10 @@ void PresentationConnection::didChangeState( |
| if (m_state == state) |
| return; |
| - m_state = state; |
| - switch (m_state) { |
| - case WebPresentationConnectionState::Connected: |
| - dispatchEvent(Event::create(EventTypeNames::connect)); |
| - return; |
| - case WebPresentationConnectionState::Terminated: |
| - dispatchEvent(Event::create(EventTypeNames::terminate)); |
| - return; |
| - // Closed state is handled in |didClose()|. |
| - case WebPresentationConnectionState::Closed: |
| - return; |
| - } |
| - ASSERT_NOT_REACHED(); |
| + getExecutionContext()->postTask( |
| + BLINK_FROM_HERE, |
| + createSameThreadTask(&PresentationConnection::didChangeStateInternal, |
| + wrapPersistent(this), state)); |
|
mlamouri (slow - plz ping)
2016/10/21 09:58:12
Why are you making this asynchronous?
mark a. foltz
2016/10/24 18:28:16
I believe this is to ensure the connect event is d
zhaobin
2016/10/24 19:42:39
Reverted. We used to make this async to dispatch c
zhaobin
2016/10/24 19:42:39
reverted.
|
| } |
| void PresentationConnection::didClose( |
| @@ -455,6 +450,28 @@ void PresentationConnection::didFailLoadingBlob( |
| handleMessageQueue(); |
| } |
| +void PresentationConnection::didChangeStateInternal( |
| + WebPresentationConnectionState state) { |
| + if (m_state == state) |
| + return; |
| + |
| + m_state = state; |
| + switch (m_state) { |
| + case WebPresentationConnectionState::Connecting: |
| + return; |
|
mlamouri (slow - plz ping)
2016/10/21 09:58:12
NOTREACHED() ?
zhaobin
2016/10/24 19:42:39
Done.
|
| + case WebPresentationConnectionState::Connected: |
| + dispatchEvent(Event::create(EventTypeNames::connect)); |
| + return; |
| + case WebPresentationConnectionState::Terminated: |
| + dispatchEvent(Event::create(EventTypeNames::terminate)); |
| + return; |
| + // Closed state is handled in |didClose()|. |
| + case WebPresentationConnectionState::Closed: |
| + return; |
|
mlamouri (slow - plz ping)
2016/10/21 09:58:12
NOTREACHED() ?
zhaobin
2016/10/24 19:42:39
Done.
|
| + } |
| + NOTREACHED(); |
| +} |
| + |
| void PresentationConnection::tearDown() { |
| // Cancel current Blob loading if any. |
| if (m_blobLoader) { |