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

Side by Side Diff: chrome/browser/media/router/media_router.h

Issue 1430413003: [Media Router] Connection state change listening redesign part 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix content_unittests compile 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
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 CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/callback_list.h"
12 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
13 #include "chrome/browser/media/router/issue.h" 14 #include "chrome/browser/media/router/issue.h"
14 #include "chrome/browser/media/router/media_route.h" 15 #include "chrome/browser/media/router/media_route.h"
15 #include "chrome/browser/media/router/media_sink.h" 16 #include "chrome/browser/media/router/media_sink.h"
16 #include "chrome/browser/media/router/media_source.h" 17 #include "chrome/browser/media/router/media_source.h"
17 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "content/public/browser/presentation_service_delegate.h"
18 #include "content/public/browser/presentation_session_message.h" 20 #include "content/public/browser/presentation_session_message.h"
19 21
20 namespace content { 22 namespace content {
21 class WebContents; 23 class WebContents;
22 } 24 }
23 25
24 namespace media_router { 26 namespace media_router {
25 27
26 class IssuesObserver; 28 class IssuesObserver;
27 class LocalMediaRoutesObserver; 29 class LocalMediaRoutesObserver;
(...skipping 13 matching lines...) Expand all
41 // |error|: Empty string. 43 // |error|: Empty string.
42 // On failure: 44 // On failure:
43 // |route|: nullptr 45 // |route|: nullptr
44 // |presentation_id|: Empty string. 46 // |presentation_id|: Empty string.
45 // |error|: Non-empty string describing the error. 47 // |error|: Non-empty string describing the error.
46 using MediaRouteResponseCallback = 48 using MediaRouteResponseCallback =
47 base::Callback<void(const MediaRoute* route, 49 base::Callback<void(const MediaRoute* route,
48 const std::string& presentation_id, 50 const std::string& presentation_id,
49 const std::string& error)>; 51 const std::string& error)>;
50 52
53 // Subscription object returned by calling
54 // |AddPresentationConnectionStateChangedCallback|. See the method comments for
55 // details.
56 using PresentationConnectionStateSubscription = base::CallbackList<void(
57 content::PresentationConnectionState)>::Subscription;
58
51 // An interface for handling resources related to media routing. 59 // An interface for handling resources related to media routing.
52 // Responsible for registering observers for receiving sink availability 60 // Responsible for registering observers for receiving sink availability
53 // updates, handling route requests/responses, and operating on routes (e.g. 61 // updates, handling route requests/responses, and operating on routes (e.g.
54 // posting messages or closing). 62 // posting messages or closing).
55 class MediaRouter : public KeyedService { 63 class MediaRouter : public KeyedService {
56 public: 64 public:
57 using PresentationSessionMessageCallback = base::Callback<void( 65 using PresentationSessionMessageCallback = base::Callback<void(
58 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>)>; 66 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>)>;
59 using SendRouteMessageCallback = base::Callback<void(bool sent)>; 67 using SendRouteMessageCallback = base::Callback<void(bool sent)>;
60 68
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 123
116 // Indicates that a presentation session has detached from the underlying 124 // Indicates that a presentation session has detached from the underlying
117 // MediaRoute |route_id| (due to navigation, garbage collection, etc.) 125 // MediaRoute |route_id| (due to navigation, garbage collection, etc.)
118 virtual void OnPresentationSessionDetached( 126 virtual void OnPresentationSessionDetached(
119 const MediaRoute::Id& route_id) = 0; 127 const MediaRoute::Id& route_id) = 0;
120 128
121 // Returns whether or not there is currently an active local displayable 129 // Returns whether or not there is currently an active local displayable
122 // route. 130 // route.
123 virtual bool HasLocalDisplayRoute() const = 0; 131 virtual bool HasLocalDisplayRoute() const = 0;
124 132
133 // Adds |callback| to listen for state changes for presentation connected to
134 // |route_id|. Callback will be invoked whenever there are state changes,
135 // until the returned Subscription object is destroyed.
136 virtual scoped_ptr<PresentationConnectionStateSubscription>
137 AddPresentationConnectionStateChangedCallback(
138 const MediaRoute::Id& route_id,
139 const content::PresentationConnectionStateChangedCallback& callback) = 0;
140
125 private: 141 private:
126 friend class IssuesObserver; 142 friend class IssuesObserver;
127 friend class LocalMediaRoutesObserver; 143 friend class LocalMediaRoutesObserver;
128 friend class MediaSinksObserver; 144 friend class MediaSinksObserver;
129 friend class MediaRoutesObserver; 145 friend class MediaRoutesObserver;
130 friend class PresentationConnectionStateObserver; 146 friend class PresentationConnectionStateObserver;
131 friend class PresentationSessionMessagesObserver; 147 friend class PresentationSessionMessagesObserver;
132 148
133 // The following functions are called by friend Observer classes above. 149 // The following functions are called by friend Observer classes above.
134 150
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 PresentationSessionMessagesObserver* observer) = 0; 201 PresentationSessionMessagesObserver* observer) = 0;
186 202
187 // Adds the LocalMediaRoutesObserver |observer| to listen for newly created 203 // Adds the LocalMediaRoutesObserver |observer| to listen for newly created
188 // MediaRoutes. 204 // MediaRoutes.
189 virtual void RegisterLocalMediaRoutesObserver( 205 virtual void RegisterLocalMediaRoutesObserver(
190 LocalMediaRoutesObserver* observer) = 0; 206 LocalMediaRoutesObserver* observer) = 0;
191 207
192 // Removes the LocalMediaRoutesObserver |observer|. 208 // Removes the LocalMediaRoutesObserver |observer|.
193 virtual void UnregisterLocalMediaRoutesObserver( 209 virtual void UnregisterLocalMediaRoutesObserver(
194 LocalMediaRoutesObserver* observer) = 0; 210 LocalMediaRoutesObserver* observer) = 0;
195
196 // Registers/unregisters a PresentationConnectionStateObserver to receive
197 // updates on state changes for a PresentationConnection. MediaRouter does
198 // not own |observer|. When |observer| is about to be destroyed, it must be
199 // unregistered from MediaRouter.
200 virtual void RegisterPresentationConnectionStateObserver(
201 PresentationConnectionStateObserver* observer) = 0;
202 virtual void UnregisterPresentationConnectionStateObserver(
203 PresentationConnectionStateObserver* observer) = 0;
204 }; 211 };
205 212
206 } // namespace media_router 213 } // namespace media_router
207 214
208 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 215 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698