diff options
author | mikhail.pozdnyakov <mikhail.pozdnyakov@intel.com> | 2016-02-26 02:48:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-26 10:49:03 +0000 |
commit | ef88b05837e968daf0389fce203c81dba16c17ed (patch) | |
tree | b7c3b092eae814e263f999556c4957f4060abcf5 /extensions/browser/api | |
parent | 9c7c38629b18307b8d03e3cdeca0ebb37e2b978c (diff) | |
download | chromium_src-ef88b05837e968daf0389fce203c81dba16c17ed.zip chromium_src-ef88b05837e968daf0389fce203c81dba16c17ed.tar.gz chromium_src-ef88b05837e968daf0389fce203c81dba16c17ed.tar.bz2 |
[chrome.displaySource] further implementation of call completion callbacks
The API implementation determines when and with which
arguments the 'startSession'/'terminateSession' completion
callbacks are invoked.
The 'exceeded_session_limit_error' session error type is
eliminated and substituted with 'startSession' completion
callback call (which is more natural since this problem is
detected before a new session is started).
JS bindings code is simplified.
BUG=242107
Review URL: https://codereview.chromium.org/1730583002
Cr-Commit-Position: refs/heads/master@{#377864}
Diffstat (limited to 'extensions/browser/api')
-rw-r--r-- | extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc b/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc index 08957fe..0cad640 100644 --- a/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc +++ b/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc @@ -62,8 +62,7 @@ void WiFiDisplaySessionServiceImpl::Connect(int32_t sink_id, DCHECK(client_); // We support only one Wi-Fi Display session at a time. if (delegate_->connection()) { - client_->OnError(ERROR_TYPE_SESSION_LIMIT_ERROR, - kErrorCannotHaveMultipleSessions); + client_->OnConnectRequestHandled(false, kErrorCannotHaveMultipleSessions); return; } @@ -72,7 +71,7 @@ void WiFiDisplaySessionServiceImpl::Connect(int32_t sink_id, sinks.begin(), sinks.end(), [sink_id](DisplaySourceSinkInfoPtr ptr) { return ptr->id == sink_id; }); if (found == sinks.end() || (*found)->state != SINK_STATE_DISCONNECTED) { - client_->OnError(ERROR_TYPE_CONNECTION_ERROR, kErrorSinkNotAvailable); + client_->OnConnectRequestHandled(false, kErrorSinkNotAvailable); return; } AuthenticationInfo auth_info; @@ -87,6 +86,7 @@ void WiFiDisplaySessionServiceImpl::Connect(int32_t sink_id, sink_id_ = sink_id; sink_state_ = (*found)->state; DCHECK(sink_state_ == SINK_STATE_CONNECTING); + client_->OnConnectRequestHandled(true, ""); } void WiFiDisplaySessionServiceImpl::Disconnect() { @@ -154,10 +154,11 @@ void WiFiDisplaySessionServiceImpl::OnSinksUpdated( auto on_message = base::Bind(&WiFiDisplaySessionServiceImpl::OnSinkMessage, weak_factory_.GetWeakPtr()); connection->SetMessageReceivedCallback(on_message); - client_->OnEstablished(connection->GetLocalAddress()); + client_->OnConnected(connection->GetLocalAddress()); } if (actual_state == SINK_STATE_DISCONNECTED) { + client_->OnDisconnectRequestHandled(true, ""); client_->OnTerminated(); sink_id_ = DisplaySourceConnectionDelegate::kInvalidSinkId; } @@ -190,7 +191,7 @@ void WiFiDisplaySessionServiceImpl::OnDisconnectFailed( if (sink_id != sink_id_) return; DCHECK(client_); - client_->OnError(ERROR_TYPE_CONNECTION_ERROR, message); + client_->OnDisconnectRequestHandled(false, message); } void WiFiDisplaySessionServiceImpl::OnClientConnectionError() { |