Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Side by Side Diff: extensions/browser/api/display_source/display_source_connection_delegate.h

Issue 1540563002: [chrome.displaySource] Add WiFi Display session class skeleton and mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 DisplaySourceSinkInfoPtr = linked_ptr<api::display_source::SinkInfo>;
16 using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfoPtr>; 16 using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfoPtr>;
17 using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo; 17 using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo;
18 18
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' 21 // 'chrome.displaySource'
22 // API. 22 // API.
asargent_no_longer_on_chrome 2016/01/04 23:28:14 nit: while you're in here, can these last two line
Mikhail 2016/01/11 19:39:40 sure :-)
23 class DisplaySourceConnectionDelegate : public KeyedService { 23 class DisplaySourceConnectionDelegate : public KeyedService {
24 public: 24 public:
25 using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>; 25 using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>;
26 using FailureCallback = base::Callback<void(const std::string&)>; 26 using FailureCallback = base::Callback<void(const std::string&)>;
27 using SinkInfoListCallback = 27 using SinkInfoListCallback =
28 base::Callback<void(const DisplaySourceSinkInfoList&)>; 28 base::Callback<void(const DisplaySourceSinkInfoList&)>;
29 29
30 const static int kInvalidSinkId = -1;
31
30 struct Connection { 32 struct Connection {
31 Connection(); 33 Connection();
32 ~Connection(); 34 ~Connection();
33 DisplaySourceSinkInfoPtr connected_sink; 35 DisplaySourceSinkInfoPtr connected_sink;
34 std::string local_ip; 36 std::string local_ip;
35 std::string sink_ip; 37 std::string sink_ip;
36 }; 38 };
37 39
38 class Observer { 40 class Observer {
39 public: 41 public:
40 // This method is called each tiome the list of available 42 // This method is called each time the list of available
41 // sinks is updated whether after 'GetAvailableSinks' call 43 // sinks is updated whether after 'GetAvailableSinks' call
42 // or while the implementation is constantly watching the sinks 44 // or while the implementation is constantly watching the
43 // (after 'StartWatchingSinks' was called). 45 // available sinks (after 'StartWatchingAvailableSinks' was called).
46 // Also this method is called to reflect current connection updates.
44 virtual void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) = 0; 47 virtual void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) = 0;
45 48
46 protected: 49 protected:
47 virtual ~Observer() {} 50 virtual ~Observer() {}
48 }; 51 };
49 52
50 DisplaySourceConnectionDelegate(); 53 DisplaySourceConnectionDelegate();
51 ~DisplaySourceConnectionDelegate() override; 54 ~DisplaySourceConnectionDelegate() override;
52 55
53 virtual void AddObserver(Observer* observer); 56 virtual void AddObserver(Observer* observer);
54 virtual void RemoveObserver(Observer* observer); 57 virtual void RemoveObserver(Observer* observer);
55 58
56 // Returns the list of last found available sinks 59 // Returns the list of last found available sinks
57 // this list may contain outdated data if the delegate 60 // this list may contain outdated data if the delegate
58 // is not watching the sinks (via 'StartWatchingSinks' 61 // is not watching the sinks (via 'StartWatchingSinks'
59 // method). The list is refreshed after 'GetAvailableSinks' 62 // method). The list is refreshed after 'GetAvailableSinks'
60 // call. 63 // call.
61 virtual DisplaySourceSinkInfoList last_found_sinks() const = 0; 64 virtual DisplaySourceSinkInfoList last_found_sinks() const = 0;
62 65
63 // Returns the Connection object representing the current 66 // Returns the Connection object representing the current
64 // connection to the sink or NULL if there is no curent connection. 67 // connection to the sink or NULL if there is no current connection.
65 virtual const Connection* connection() const = 0; 68 virtual const Connection* connection() const = 0;
66 69
67 // Queries the list of currently available sinks. 70 // Queries the list of currently available sinks.
68 virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, 71 virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback,
69 const FailureCallback& failure_callback) = 0; 72 const FailureCallback& failure_callback) = 0;
70 73
71 // Queries the authentication method required by the sink for connection. 74 // Queries the authentication method required by the sink for connection.
72 // If the used authentication method requires authentication data to be 75 // If the used authentication method requires authentication data to be
73 // visible on the sink's display (e.g. PIN) the implementation should 76 // visible on the sink's display (e.g. PIN) the implementation should
74 // request the sink to show it. 77 // request the sink to show it.
75 virtual void RequestAuthentication( 78 virtual void RequestAuthentication(
76 int sink_id, 79 int sink_id,
77 const AuthInfoCallback& auth_info_callback, 80 const AuthInfoCallback& auth_info_callback,
78 const FailureCallback& failure_callback) = 0; 81 const FailureCallback& failure_callback) = 0;
79 82
80 // Connects to a sink by given id and auth info. 83 // Connects to a sink by given id and auth info.
81 virtual void Connect(int sink_id, 84 virtual void Connect(int sink_id,
82 const DisplaySourceAuthInfo& auth_info, 85 const DisplaySourceAuthInfo& auth_info,
83 const base::Closure& connected_callback,
84 const FailureCallback& failure_callback) = 0; 86 const FailureCallback& failure_callback) = 0;
85 87
86 // Disconnects the current connection to sink, the 'failure_callback' 88 // Disconnects the current connection to sink, the 'failure_callback'
87 // is called if there is no current connection. 89 // is called if an error has occurred or if there is no established
88 virtual void Disconnect(const base::Closure& disconnected_callback, 90 // connection.
89 const FailureCallback& failure_callback) = 0; 91 virtual void Disconnect(const FailureCallback& failure_callback) = 0;
90 92
91 // Implementation should start watching the sinks updates. 93 // Implementation should start watching the available sinks updates.
92 virtual void StartWatchingSinks() = 0; 94 virtual void StartWatchingAvailableSinks() = 0;
93 95
94 // Implementation should stop watching the sinks updates. 96 // Implementation should stop watching the available sinks updates.
95 virtual void StopWatchingSinks() = 0; 97 virtual void StopWatchingAvailableSinks() = 0;
96 98
97 protected: 99 protected:
98 base::ObserverList<Observer> observers_; 100 base::ObserverList<Observer> observers_;
99 }; 101 };
100 102
101 } // namespace extensions 103 } // namespace extensions
102 104
103 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEG ATE_H_ 105 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEG ATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698