Chromium Code Reviews| Index: extensions/browser/api/display_source/display_source_connection_delegate.h |
| diff --git a/extensions/browser/api/display_source/display_source_connection_delegate.h b/extensions/browser/api/display_source/display_source_connection_delegate.h |
| index dbd45538eda19d96d4b99e23b9dd177974deead2..9b140a789a258a8051557b97f16f9f30018ec7f9 100644 |
| --- a/extensions/browser/api/display_source/display_source_connection_delegate.h |
| +++ b/extensions/browser/api/display_source/display_source_connection_delegate.h |
| @@ -15,25 +15,43 @@ namespace extensions { |
| using DisplaySourceSinkInfoPtr = linked_ptr<api::display_source::SinkInfo>; |
| using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfoPtr>; |
| using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo; |
| - |
| +using DisplaySourceErrorType = api::display_source::ErrorType; |
| // The DisplaySourceConnectionDelegate interface should be implemented |
| // to provide sinks search and connection functionality for |
| // 'chrome.displaySource' API. |
| class DisplaySourceConnectionDelegate : public KeyedService { |
| public: |
| using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>; |
| - using FailureCallback = base::Callback<void(const std::string&)>; |
| + using StringCallback = base::Callback<void(const std::string&)>; |
| using SinkInfoListCallback = |
| base::Callback<void(const DisplaySourceSinkInfoList&)>; |
| const static int kInvalidSinkId = -1; |
| - struct Connection { |
| + class Connection { |
| + public: |
| + // Returns a pointer to the connected sink object. The result is |
| + // guaranteed not to be NULL. |
| + virtual DisplaySourceSinkInfoPtr GetConnectedSink() const = 0; |
| + |
| + // Returns the local address of the source. |
| + virtual std::string GetLocalAddress() const = 0; |
| + |
| + // Returns the address of the connected sink. |
| + virtual std::string GetSinkAddress() const = 0; |
| + |
| + // Sends a control message to the connected sink. |
| + // If an error occurres 'Observer::OnConnectionError' is invoked. |
|
asargent_no_longer_on_chrome
2016/01/20 19:26:17
typo: "occurres" should be "occurs"
Mikhail
2016/01/21 09:38:02
Done.
|
| + virtual void SendMessage(const std::string& message) const = 0; |
| + |
| + // Sets a callback to receive control messages from the connected sink. |
| + // If an error occurres 'Observer::OnConnectionError' is invoked. |
|
asargent_no_longer_on_chrome
2016/01/20 19:26:17
same typo: "occurres" should be "occurs"
Also, it
Mikhail
2016/01/21 09:38:02
indeed, thanks for the proposal
|
| + virtual void SetMessageReceivedCallback( |
| + const StringCallback& callback) const = 0; |
| + |
| + protected: |
| Connection(); |
| - ~Connection(); |
| - DisplaySourceSinkInfoPtr connected_sink; |
| - std::string local_ip; |
| - std::string sink_ip; |
| + virtual ~Connection(); |
| }; |
| class Observer { |
| @@ -45,6 +63,12 @@ class DisplaySourceConnectionDelegate : public KeyedService { |
| // Also this method is called to reflect current connection updates. |
| virtual void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) = 0; |
| + // This method is called during the established connection to report |
| + // a transport layer error. |
|
asargent_no_longer_on_chrome
2016/01/20 19:26:17
It might be worth mentioning if this event firing
Mikhail
2016/01/21 09:38:02
Done.
|
| + virtual void OnConnectionError(int sink_id, |
| + DisplaySourceErrorType type, |
| + const std::string& description) = 0; |
| + |
| protected: |
| virtual ~Observer() {} |
| }; |
| @@ -68,7 +92,7 @@ class DisplaySourceConnectionDelegate : public KeyedService { |
| // Queries the list of currently available sinks. |
| virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, |
| - const FailureCallback& failure_callback) = 0; |
| + const StringCallback& failure_callback) = 0; |
| // Queries the authentication method required by the sink for connection. |
| // If the used authentication method requires authentication data to be |
| @@ -77,17 +101,17 @@ class DisplaySourceConnectionDelegate : public KeyedService { |
| virtual void RequestAuthentication( |
| int sink_id, |
| const AuthInfoCallback& auth_info_callback, |
| - const FailureCallback& failure_callback) = 0; |
| + const StringCallback& failure_callback) = 0; |
| // Connects to a sink by given id and auth info. |
| virtual void Connect(int sink_id, |
| const DisplaySourceAuthInfo& auth_info, |
| - const FailureCallback& failure_callback) = 0; |
| + const StringCallback& failure_callback) = 0; |
| // Disconnects the current connection to sink, the 'failure_callback' |
| // is called if an error has occurred or if there is no established |
| // connection. |
| - virtual void Disconnect(const FailureCallback& failure_callback) = 0; |
| + virtual void Disconnect(const StringCallback& failure_callback) = 0; |
| // Implementation should start watching the available sinks updates. |
| virtual void StartWatchingAvailableSinks() = 0; |