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..e1a31f976a9d0c6f9311641192178ccdcea4702c 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: |
| @@ -148,6 +152,7 @@ PresentationConnection::PresentationConnection(LocalFrame* frame, |
| : DOMWindowProperty(frame), |
| m_id(id), |
| m_url(url), |
| + // TODO(zhaobin): change initial state to Connecting |
| m_state(WebPresentationConnectionState::Connected), |
| m_binaryType(BinaryTypeBlob) {} |
| @@ -374,7 +379,8 @@ void PresentationConnection::didReceiveBinaryMessage(const uint8_t* data, |
| } |
| void PresentationConnection::close() { |
| - if (m_state != WebPresentationConnectionState::Connected) |
| + if (m_state != WebPresentationConnectionState::Connecting && |
| + m_state != WebPresentationConnectionState::Connected) |
| return; |
|
mlamouri (slow - plz ping)
2016/10/25 10:17:05
style: wrap with { }
zhaobin
2016/10/25 17:40:00
Done.
|
| WebPresentationClient* client = presentationClient(getExecutionContext()); |
| if (client) |
| @@ -406,6 +412,9 @@ void PresentationConnection::didChangeState( |
| m_state = state; |
| switch (m_state) { |
| + case WebPresentationConnectionState::Connecting: |
| + NOTREACHED(); |
| + return; |
| case WebPresentationConnectionState::Connected: |
| dispatchEvent(Event::create(EventTypeNames::connect)); |
| return; |
| @@ -414,9 +423,10 @@ void PresentationConnection::didChangeState( |
| return; |
| // Closed state is handled in |didClose()|. |
| case WebPresentationConnectionState::Closed: |
| + NOTREACHED(); |
| return; |
| } |
| - ASSERT_NOT_REACHED(); |
| + NOTREACHED(); |
| } |
| void PresentationConnection::didClose( |