summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/api
diff options
context:
space:
mode:
authormikhail.pozdnyakov <mikhail.pozdnyakov@intel.com>2016-02-11 11:42:24 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-11 19:43:47 +0000
commitef0d3aa8a2e82e6db356e112c236ef0f8a2a8918 (patch)
treec1d439680acee131a2290b1ca36b00dac9d3ebaa /extensions/renderer/api
parent0f0f3981f6ca07546cd9208c202ee512d4c807ba (diff)
downloadchromium_src-ef0d3aa8a2e82e6db356e112c236ef0f8a2a8918.zip
chromium_src-ef0d3aa8a2e82e6db356e112c236ef0f8a2a8918.tar.gz
chromium_src-ef0d3aa8a2e82e6db356e112c236ef0f8a2a8918.tar.bz2
[chrome.displaySource] Session notification improvements
This patch provides several fixes and improvements (simplifications) to the session life cycle notification mechanism: 1) The 'startSession'/'terminateSession' call completion callbacks are invoked when the session is actually started/terminated and in accordance with 'onSessionStarted'/'onSessionTerminated' events propagating (and as per documentation). 2) The notification from the required sink is filtered out in browser process avoiding unneeded IPC calls 3) Methods in mojo interface are renamed in order to improve readability BUG=242107 Review URL: https://codereview.chromium.org/1674583002 Cr-Commit-Position: refs/heads/master@{#374929}
Diffstat (limited to 'extensions/renderer/api')
-rw-r--r--extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc38
-rw-r--r--extensions/renderer/api/display_source/wifi_display/wifi_display_session.h9
2 files changed, 18 insertions, 29 deletions
diff --git a/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc b/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc
index 67edf4b..f6d1104 100644
--- a/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc
+++ b/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc
@@ -42,6 +42,8 @@ void WiFiDisplaySession::Start() {
DCHECK(state_ == DisplaySourceSession::Idle);
service_->Connect(params_.sink_id, params_.auth_method, params_.auth_data);
state_ = DisplaySourceSession::Establishing;
+ if (!started_callback_.is_null())
+ started_callback_.Run(params_.sink_id);
}
void WiFiDisplaySession::Terminate() {
@@ -61,35 +63,26 @@ void WiFiDisplaySession::Terminate() {
}
}
-void WiFiDisplaySession::OnConnected(
- int32_t sink_id, const mojo::String& ip_address) {
- if (sink_id == params_.sink_id) {
- DCHECK(state_ != DisplaySourceSession::Established);
- ip_address_ = ip_address;
- state_ = DisplaySourceSession::Established;
- }
-
- if (!started_callback_.is_null())
- started_callback_.Run(sink_id);
+void WiFiDisplaySession::OnEstablished(const mojo::String& ip_address) {
+ DCHECK(state_ != DisplaySourceSession::Established);
+ ip_address_ = ip_address;
+ state_ = DisplaySourceSession::Established;
}
-void WiFiDisplaySession::OnDisconnected(int32_t sink_id) {
- if (sink_id == params_.sink_id) {
- DCHECK(state_ == DisplaySourceSession::Established ||
- state_ == DisplaySourceSession::Terminating);
- state_ = DisplaySourceSession::Idle;
- }
-
+void WiFiDisplaySession::OnTerminated() {
+ DCHECK(state_ != DisplaySourceSession::Idle);
+ state_ = DisplaySourceSession::Idle;
if (!terminated_callback_.is_null())
- terminated_callback_.Run(sink_id);
+ terminated_callback_.Run(params_.sink_id);
}
-void WiFiDisplaySession::OnError(
- int32_t sink_id, int32_t type, const mojo::String& description) {
+void WiFiDisplaySession::OnError(int32_t type,
+ const mojo::String& description) {
DCHECK(type > api::display_source::ERROR_TYPE_NONE
&& type <= api::display_source::ERROR_TYPE_LAST);
if (!error_callback_.is_null())
- error_callback_.Run(sink_id, static_cast<ErrorType>(type), description);
+ error_callback_.Run(params_.sink_id, static_cast<ErrorType>(type),
+ description);
}
void WiFiDisplaySession::OnMessage(const mojo::String& data) {
@@ -103,8 +96,7 @@ void WiFiDisplaySession::OnConnectionError() {
kErrorInternal);
}
- if (state_ == DisplaySourceSession::Established ||
- state_ == DisplaySourceSession::Terminating) {
+ if (state_ != DisplaySourceSession::Idle) {
// We must explicitly notify the session termination as it will never
// arrive from browser process (IPC is broken).
if (!terminated_callback_.is_null())
diff --git a/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h b/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h
index b807993..5d10308 100644
--- a/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h
+++ b/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h
@@ -26,12 +26,9 @@ class WiFiDisplaySession: public DisplaySourceSession,
void Terminate() override;
// WiFiDisplaySessionServiceClient overrides.
- void OnConnected(int32_t sink_id,
- const mojo::String& ip_address) override;
- void OnDisconnected(int32_t sink_id) override;
- void OnError(int32_t sink_id,
- int32_t type,
- const mojo::String& description) override;
+ void OnEstablished(const mojo::String& ip_address) override;
+ void OnTerminated() override;
+ void OnError(int32_t type, const mojo::String& description) override;
void OnMessage(const mojo::String& data) override;
// A connection error handler for the mojo objects used in this class.