OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE _H_ | |
6 #define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE _H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/observer_list.h" | |
10 #include "components/keyed_service/core/keyed_service.h" | |
11 #include "extensions/common/api/display_source.h" | |
12 | |
13 namespace extensions { | |
14 | |
15 using DisplaySourceSinkInfoPtr = linked_ptr<api::display_source::SinkInfo>; | |
16 using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfoPtr>; | |
17 using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo; | |
18 | |
19 class DisplaySourceConnectionDelegate : public KeyedService { | |
asargent_no_longer_on_chrome
2015/11/17 00:51:55
nit: please add at least a brief class overview co
Mikhail
2015/11/17 14:07:42
Done.
| |
20 public: | |
21 using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>; | |
22 using FailureCallback = base::Callback<void(const std::string&)>; | |
23 using SinkInfoListCallback = | |
24 base::Callback<void(const DisplaySourceSinkInfoList&)>; | |
25 | |
26 struct Connection { | |
27 Connection(); | |
28 ~Connection(); | |
29 DisplaySourceSinkInfoPtr connected_sink; | |
30 std::string local_ip; | |
31 std::string sink_ip; | |
asargent_no_longer_on_chrome
2015/11/17 00:51:55
I saw the discussion in the design doc around the
Mikhail
2015/11/17 14:07:42
The ip info is only needed for internal usage (wil
| |
32 }; | |
33 | |
34 class Observer { | |
35 public: | |
36 // This method is called each tiome the list of available | |
37 // sinks is updated whether after 'GetAvailableSinks' call | |
38 // or while the implementation is constantly watching the sinks | |
39 // (after 'StartWatchingSinks' was called). | |
40 virtual void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) = 0; | |
41 | |
42 protected: | |
43 virtual ~Observer() {} | |
44 }; | |
45 | |
46 DisplaySourceConnectionDelegate(); | |
47 ~DisplaySourceConnectionDelegate() override; | |
48 | |
49 virtual void AddObserver(Observer* observer); | |
50 virtual void RemoveObserver(Observer* observer); | |
51 | |
52 // Returns the list of last found available sinks | |
53 // this list may contain outdated data if the delegate | |
54 // is not watching the sinks (via 'StartWatchingSinks' | |
55 // method). The list is refreshed after 'GetAvailableSinks' | |
56 // call. | |
57 virtual DisplaySourceSinkInfoList last_found_sinks() const = 0; | |
58 | |
59 // Returns the Connection object representing the current | |
60 // connection to the sink or NULL if there is no curent connection. | |
61 virtual const Connection* connection() const = 0; | |
62 | |
63 // Queries the list of currently available sinks. | |
64 virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, | |
65 const FailureCallback& failure_callback) = 0; | |
66 | |
67 // Queries the authentication method required by the sink for connection. | |
68 // If the used authentication method requires authentication data to be | |
69 // visible on the sink's display (e.g. PIN) the implementation should | |
70 // request the sink to show it. | |
71 virtual void RequestAuthentication( | |
72 int sink_id, | |
73 const AuthInfoCallback& auth_info_callback, | |
74 const FailureCallback& failure_callback) = 0; | |
75 | |
76 // Connects to a sink by given id and auth info. | |
77 virtual void Connect(int sink_id, | |
78 const DisplaySourceAuthInfo& auth_info, | |
79 const base::Closure& connected_callback, | |
80 const FailureCallback& failure_callback) = 0; | |
81 | |
82 // Disconnects the current connection to sink, the 'failure_callback' | |
83 // is called if there is no current connection. | |
84 virtual void Disconnect(const base::Closure& disconnected_callback, | |
85 const FailureCallback& failure_callback) = 0; | |
86 | |
87 // Implementation should start watching the sinks updates. | |
88 virtual void StartWatchingSinks() = 0; | |
89 | |
90 // Implementation should stop watching the sinks updates. | |
91 virtual void StopWatchingSinks() = 0; | |
92 | |
93 protected: | |
94 base::ObserverList<Observer> observers_; | |
95 }; | |
96 | |
97 } // namespace extensions | |
98 | |
99 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEG ATE_H_ | |
OLD | NEW |