OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE
_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE
_H_ |
6 #define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE
_H_ | 6 #define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE
_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
11 #include "extensions/common/api/display_source.h" | 11 #include "extensions/common/api/display_source.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 using DisplaySourceSinkInfoPtr = linked_ptr<api::display_source::SinkInfo>; | 15 using DisplaySourceSinkInfo = api::display_source::SinkInfo; |
16 using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfoPtr>; | 16 using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfo>; |
17 using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo; | 17 using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo; |
18 using DisplaySourceErrorType = api::display_source::ErrorType; | 18 using DisplaySourceErrorType = api::display_source::ErrorType; |
19 // The DisplaySourceConnectionDelegate interface should be implemented | 19 // The DisplaySourceConnectionDelegate interface should be implemented |
20 // to provide sinks search and connection functionality for | 20 // to provide sinks search and connection functionality for |
21 // 'chrome.displaySource' API. | 21 // 'chrome.displaySource' API. |
22 class DisplaySourceConnectionDelegate : public KeyedService { | 22 class DisplaySourceConnectionDelegate : public KeyedService { |
23 public: | 23 public: |
24 using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>; | 24 using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>; |
25 using StringCallback = base::Callback<void(const std::string&)>; | 25 using StringCallback = base::Callback<void(const std::string&)>; |
26 using SinkInfoListCallback = | 26 using SinkInfoListCallback = |
27 base::Callback<void(const DisplaySourceSinkInfoList&)>; | 27 base::Callback<void(const DisplaySourceSinkInfoList&)>; |
28 | 28 |
29 const static int kInvalidSinkId = -1; | 29 const static int kInvalidSinkId = -1; |
30 | 30 |
31 class Connection { | 31 class Connection { |
32 public: | 32 public: |
33 // Returns a pointer to the connected sink object. The result is | 33 // Returns the connected sink object. |
34 // guaranteed not to be NULL. | 34 virtual DisplaySourceSinkInfo GetConnectedSink() const = 0; |
35 virtual DisplaySourceSinkInfoPtr GetConnectedSink() const = 0; | |
36 | 35 |
37 // Returns the local address of the source. | 36 // Returns the local address of the source. |
38 virtual std::string GetLocalAddress() const = 0; | 37 virtual std::string GetLocalAddress() const = 0; |
39 | 38 |
40 // Returns the address of the connected sink. | 39 // Returns the address of the connected sink. |
41 virtual std::string GetSinkAddress() const = 0; | 40 virtual std::string GetSinkAddress() const = 0; |
42 | 41 |
43 // Sends a control message to the connected sink. | 42 // Sends a control message to the connected sink. |
44 // If an error occurs 'Observer::OnConnectionError' is invoked. | 43 // If an error occurs 'Observer::OnConnectionError' is invoked. |
45 virtual void SendMessage(const std::string& message) const = 0; | 44 virtual void SendMessage(const std::string& message) const = 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 ~DisplaySourceConnectionDelegate() override; | 79 ~DisplaySourceConnectionDelegate() override; |
81 | 80 |
82 virtual void AddObserver(Observer* observer); | 81 virtual void AddObserver(Observer* observer); |
83 virtual void RemoveObserver(Observer* observer); | 82 virtual void RemoveObserver(Observer* observer); |
84 | 83 |
85 // Returns the list of last found available sinks | 84 // Returns the list of last found available sinks |
86 // this list may contain outdated data if the delegate | 85 // this list may contain outdated data if the delegate |
87 // is not watching the sinks (via 'StartWatchingSinks' | 86 // is not watching the sinks (via 'StartWatchingSinks' |
88 // method). The list is refreshed after 'GetAvailableSinks' | 87 // method). The list is refreshed after 'GetAvailableSinks' |
89 // call. | 88 // call. |
90 virtual DisplaySourceSinkInfoList last_found_sinks() const = 0; | 89 virtual const DisplaySourceSinkInfoList& last_found_sinks() const = 0; |
91 | 90 |
92 // Returns the Connection object representing the current | 91 // Returns the Connection object representing the current |
93 // connection to the sink or NULL if there is no current connection. | 92 // connection to the sink or NULL if there is no current connection. |
94 virtual const Connection* connection() const = 0; | 93 virtual const Connection* connection() const = 0; |
95 | 94 |
96 // Queries the list of currently available sinks. | 95 // Queries the list of currently available sinks. |
97 virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, | 96 virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, |
98 const StringCallback& failure_callback) = 0; | 97 const StringCallback& failure_callback) = 0; |
99 | 98 |
100 // Queries the authentication method required by the sink for connection. | 99 // Queries the authentication method required by the sink for connection. |
(...skipping 21 matching lines...) Expand all Loading... |
122 // Implementation should stop watching the available sinks updates. | 121 // Implementation should stop watching the available sinks updates. |
123 virtual void StopWatchingAvailableSinks() = 0; | 122 virtual void StopWatchingAvailableSinks() = 0; |
124 | 123 |
125 protected: | 124 protected: |
126 base::ObserverList<Observer> observers_; | 125 base::ObserverList<Observer> observers_; |
127 }; | 126 }; |
128 | 127 |
129 } // namespace extensions | 128 } // namespace extensions |
130 | 129 |
131 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEG
ATE_H_ | 130 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEG
ATE_H_ |
OLD | NEW |