Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1523)

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp

Issue 2435243002: [Presentation API] add 'connecting' state to WebPresentationConnectionState (Closed)
Patch Set: resolve code review comments from mlamouri Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3d2fcd2d12e39e475e5d5df9fd449a97fef2f81a 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
@@ -46,11 +46,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 +151,7 @@ PresentationConnection::PresentationConnection(LocalFrame* frame,
: DOMWindowProperty(frame),
m_id(id),
m_url(url),
+ // TODO(zhaobin): change initial state to Connecting. (crbug/659423)
m_state(WebPresentationConnectionState::Connected),
m_binaryType(BinaryTypeBlob) {}
@@ -374,8 +378,10 @@ 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;
+ }
WebPresentationClient* client = presentationClient(getExecutionContext());
if (client)
client->closeSession(m_url, m_id);
@@ -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(

Powered by Google App Engine
This is Rietveld 408576698