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

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

Issue 1410093008: Introduce chrome.displaySource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added warning message Created 5 years, 1 month 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
(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 SinkInfoPtr = linked_ptr<api::display_source::SinkInfo>;
16 using SinkInfoList = std::vector<SinkInfoPtr>;
17 using AuthInfo = api::display_source::AuthenticationInfo;
Reilly Grant (use Gerrit) 2015/11/10 18:51:34 It is okay to keep these in .cc files for brevity
Mikhail 2015/11/11 13:36:04 Good point, would it be OK if I prefix them?
18
19 class DisplaySourceConnectionDelegate : public KeyedService {
20 public:
21 using AuthInfoCallback = base::Callback<void(const AuthInfo&)>;
22 using FailureCallback = base::Callback<void(const std::string&)>;
23 using SinkInfoListCallback = base::Callback<void(const SinkInfoList&)>;
24
25 struct Connection {
26 Connection();
27 ~Connection();
28 SinkInfoPtr connected_sink;
29 std::string local_ip;
30 std::string sink_ip;
31 };
32
33 class Observer {
34 public:
35 // This method is called each tiome the list of available
36 // sinks is updated whether after 'GetAvailableSinks' call
37 // or while the implementation is constantly watching the sinks
38 // (after 'StartWatchingSinks' was called).
39 virtual void OnSinksUpdated(const SinkInfoList& sinks) = 0;
40
41 protected:
42 virtual ~Observer() {}
43 };
44
45 DisplaySourceConnectionDelegate();
46 ~DisplaySourceConnectionDelegate() override;
47
48 virtual void AddObserver(Observer* observer);
49 virtual void RemoveObserver(Observer* observer);
50
51 // Returns the list of last found available sinks
52 // this list may contain outdated data if the delegate
53 // is not watching the sinks (via 'StartWatchingSinks'
54 // method). The list is refreshed after 'GetAvailableSinks'
55 // call.
56 virtual SinkInfoList last_found_sinks() const = 0;
57
58 // Returns the Connection object representing the current
59 // connection to the sink or NULL if there is no curent connection.
60 virtual const Connection* connection() const = 0;
61
62 // Queries the list of currently available sinks.
63 virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback,
64 const FailureCallback& failure_callback) = 0;
65
66 // Queries the authentication method required by the sink for connection.
67 // If the used authentication method requires authentication data to be
68 // visible on the sink's display (e.g. PIN) the implementation should
69 // request the sink to show it.
70 virtual void RequestAuthentication(
71 int sink_id,
72 const AuthInfoCallback& auth_info_callback,
73 const FailureCallback& failure_callback) = 0;
74
75 // Connects to a sink by given id and auth info.
76 virtual void Connect(int sink_id,
77 const AuthInfo& auth_info,
78 const base::Closure& connected_callback,
79 const FailureCallback& failure_callback) = 0;
80
81 // Disconnects the current connection to sink, the 'failure_callback'
82 // is called if there is no current connection.
83 virtual void Disconnect(const base::Closure& disconnected_callback,
84 const FailureCallback& failure_callback) = 0;
85
86 // Implementation should start watching the sinks updates.
87 virtual void StartWatchingSinks() = 0;
88
89 // Implementation should stop watching the sinks updates.
90 virtual void StopWatchingSinks() = 0;
91
92 protected:
93 base::ObserverList<Observer> observers_;
94 };
95
96 } // namespace extensions
97
98 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEG ATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698