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

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

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review Fixes 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 CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const MediaSink::Id& sink_id, 67 const MediaSink::Id& sink_id,
68 const GURL& origin, 68 const GURL& origin,
69 content::WebContents* web_contents, 69 content::WebContents* web_contents,
70 const std::vector<MediaRouteResponseCallback>& callbacks) override; 70 const std::vector<MediaRouteResponseCallback>& callbacks) override;
71 void JoinRoute( 71 void JoinRoute(
72 const MediaSource::Id& source_id, 72 const MediaSource::Id& source_id,
73 const std::string& presentation_id, 73 const std::string& presentation_id,
74 const GURL& origin, 74 const GURL& origin,
75 content::WebContents* web_contents, 75 content::WebContents* web_contents,
76 const std::vector<MediaRouteResponseCallback>& callbacks) override; 76 const std::vector<MediaRouteResponseCallback>& callbacks) override;
77 void JoinRouteByRouteId(
78 const MediaSource::Id& source,
79 const MediaRoute::Id& route_id,
80 const GURL& origin,
81 content::WebContents* web_contents,
82 const std::vector<MediaRouteResponseCallback>& callbacks) override;
77 void CloseRoute(const MediaRoute::Id& route_id) override; 83 void CloseRoute(const MediaRoute::Id& route_id) override;
78 void SendRouteMessage(const MediaRoute::Id& route_id, 84 void SendRouteMessage(const MediaRoute::Id& route_id,
79 const std::string& message, 85 const std::string& message,
80 const SendRouteMessageCallback& callback) override; 86 const SendRouteMessageCallback& callback) override;
81 void SendRouteBinaryMessage( 87 void SendRouteBinaryMessage(
82 const MediaRoute::Id& route_id, 88 const MediaRoute::Id& route_id,
83 scoped_ptr<std::vector<uint8>> data, 89 scoped_ptr<std::vector<uint8>> data,
84 const SendRouteMessageCallback& callback) override; 90 const SendRouteMessageCallback& callback) override;
85 void AddIssue(const Issue& issue) override; 91 void AddIssue(const Issue& issue) override;
86 void ClearIssue(const Issue::Id& issue_id) override; 92 void ClearIssue(const Issue::Id& issue_id) override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // giving up and draining the pending request queue. 134 // giving up and draining the pending request queue.
129 static const int kMaxWakeupAttemptCount = 3; 135 static const int kMaxWakeupAttemptCount = 3;
130 136
131 class MediaRouterMediaRoutesObserver : 137 class MediaRouterMediaRoutesObserver :
132 public media_router::MediaRoutesObserver { 138 public media_router::MediaRoutesObserver {
133 public: 139 public:
134 explicit MediaRouterMediaRoutesObserver(MediaRouterMojoImpl* router); 140 explicit MediaRouterMediaRoutesObserver(MediaRouterMojoImpl* router);
135 ~MediaRouterMediaRoutesObserver() override; 141 ~MediaRouterMediaRoutesObserver() override;
136 142
137 // media_router::MediaRoutesObserver: 143 // media_router::MediaRoutesObserver:
138 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes) 144 void OnRoutesUpdated(
145 const std::vector<media_router::MediaRoute>& routes,
146 const std::vector<media_router::MediaRoute::Id>& joinable_route_ids)
139 override; 147 override;
140 148
141 private: 149 private:
142 MediaRouterMojoImpl* const router_; 150 MediaRouterMojoImpl* const router_;
143 151
144 DISALLOW_COPY_AND_ASSIGN(MediaRouterMediaRoutesObserver); 152 DISALLOW_COPY_AND_ASSIGN(MediaRouterMediaRoutesObserver);
145 }; 153 };
146 154
147 // Represents a query to the MRPM for media sinks and holds observers for the 155 // Represents a query to the MRPM for media sinks and holds observers for the
148 // query. 156 // query.
149 struct MediaSinksQuery { 157 struct MediaSinksQuery {
150 public: 158 public:
151 MediaSinksQuery(); 159 MediaSinksQuery();
152 ~MediaSinksQuery(); 160 ~MediaSinksQuery();
153 161
154 // True if the query has been sent to the MRPM. False otherwise. 162 // True if the query has been sent to the MRPM. False otherwise.
155 bool is_active = false; 163 bool is_active = false;
156 base::ObserverList<MediaSinksObserver> observers; 164 base::ObserverList<MediaSinksObserver> observers;
157 165
158 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); 166 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery);
159 }; 167 };
160 168
169 struct MediaRoutesQuery {
170 public:
171 MediaRoutesQuery();
172 ~MediaRoutesQuery();
173
174 // True if the query has been sent to the MRPM. False otherwise.
175 bool is_active = false;
176 base::ObserverList<MediaRoutesObserver> observers;
177
178 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery);
179 };
180
161 // Standard constructor, used by 181 // Standard constructor, used by
162 // MediaRouterMojoImplFactory::GetApiForBrowserContext. 182 // MediaRouterMojoImplFactory::GetApiForBrowserContext.
163 explicit MediaRouterMojoImpl( 183 explicit MediaRouterMojoImpl(
164 extensions::EventPageTracker* event_page_tracker); 184 extensions::EventPageTracker* event_page_tracker);
165 185
166 // Binds |this| to a Mojo interface request, so that clients can acquire a 186 // Binds |this| to a Mojo interface request, so that clients can acquire a
167 // handle to a MediaRouterMojoImpl instance via the Mojo service connector. 187 // handle to a MediaRouterMojoImpl instance via the Mojo service connector.
168 // Stores the |extension_id| of the component extension. 188 // Stores the |extension_id| of the component extension.
169 void BindToMojoRequest( 189 void BindToMojoRequest(
170 mojo::InterfaceRequest<interfaces::MediaRouter> request, 190 mojo::InterfaceRequest<interfaces::MediaRouter> request,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const std::string& message, 236 const std::string& message,
217 const SendRouteMessageCallback& callback); 237 const SendRouteMessageCallback& callback);
218 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, 238 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id,
219 scoped_ptr<std::vector<uint8>> data, 239 scoped_ptr<std::vector<uint8>> data,
220 const SendRouteMessageCallback& callback); 240 const SendRouteMessageCallback& callback);
221 void DoListenForRouteMessages(const MediaRoute::Id& route_id); 241 void DoListenForRouteMessages(const MediaRoute::Id& route_id);
222 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); 242 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id);
223 void DoOnPresentationSessionDetached(const MediaRoute::Id& route_id); 243 void DoOnPresentationSessionDetached(const MediaRoute::Id& route_id);
224 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); 244 void DoStartObservingMediaSinks(const MediaSource::Id& source_id);
225 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); 245 void DoStopObservingMediaSinks(const MediaSource::Id& source_id);
226 void DoStartObservingMediaRoutes(); 246 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id);
227 void DoStopObservingMediaRoutes(); 247 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id);
228 248
229 // Invoked when the next batch of messages arrives. 249 // Invoked when the next batch of messages arrives.
230 // |route_id|: ID of route of the messages. 250 // |route_id|: ID of route of the messages.
231 // |messages|: A list of messages received. 251 // |messages|: A list of messages received.
232 // |error|: true if an error occurred. 252 // |error|: true if an error occurred.
233 void OnRouteMessagesReceived( 253 void OnRouteMessagesReceived(
234 const MediaRoute::Id& route_id, 254 const MediaRoute::Id& route_id,
235 mojo::Array<interfaces::RouteMessagePtr> messages, 255 mojo::Array<interfaces::RouteMessagePtr> messages,
236 bool error); 256 bool error);
237 257
238 // Error handler callback for |binding_| and |media_route_provider_|. 258 // Error handler callback for |binding_| and |media_route_provider_|.
239 void OnConnectionError(); 259 void OnConnectionError();
240 260
241 // interfaces::MediaRouter implementation. 261 // interfaces::MediaRouter implementation.
242 void RegisterMediaRouteProvider( 262 void RegisterMediaRouteProvider(
243 interfaces::MediaRouteProviderPtr media_route_provider_ptr, 263 interfaces::MediaRouteProviderPtr media_route_provider_ptr,
244 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& 264 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback&
245 callback) override; 265 callback) override;
246 void OnIssue(interfaces::IssuePtr issue) override; 266 void OnIssue(interfaces::IssuePtr issue) override;
247 void OnSinksReceived(const mojo::String& media_source, 267 void OnSinksReceived(const mojo::String& media_source,
248 mojo::Array<interfaces::MediaSinkPtr> sinks) override; 268 mojo::Array<interfaces::MediaSinkPtr> sinks) override;
249 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes) override; 269 void OnRoutesUpdated(const mojo::String& media_source,
270 mojo::Array<interfaces::MediaRoutePtr> routes,
271 mojo::Array<mojo::String> joinable_route_ids) override;
250 void OnSinkAvailabilityUpdated( 272 void OnSinkAvailabilityUpdated(
251 interfaces::MediaRouter::SinkAvailability availability) override; 273 interfaces::MediaRouter::SinkAvailability availability) override;
252 274
253 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() 275 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute()
254 // into a local callback. 276 // into a local callback.
255 void RouteResponseReceived( 277 void RouteResponseReceived(
256 const std::string& presentation_id, 278 const std::string& presentation_id,
257 const std::vector<MediaRouteResponseCallback>& callbacks, 279 const std::vector<MediaRouteResponseCallback>& callbacks,
258 interfaces::MediaRoutePtr media_route, 280 interfaces::MediaRoutePtr media_route,
259 const mojo::String& error_text); 281 const mojo::String& error_text);
(...skipping 16 matching lines...) Expand all
276 // the pending request queue. 298 // the pending request queue.
277 void AttemptWakeEventPage(); 299 void AttemptWakeEventPage();
278 300
279 // Pending requests queued to be executed once component extension 301 // Pending requests queued to be executed once component extension
280 // becomes ready. 302 // becomes ready.
281 std::deque<base::Closure> pending_requests_; 303 std::deque<base::Closure> pending_requests_;
282 304
283 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> 305 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>>
284 sinks_queries_; 306 sinks_queries_;
285 307
308 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>>
309 routes_queries_;
310
286 base::ObserverList<LocalMediaRoutesObserver> local_routes_observers_; 311 base::ObserverList<LocalMediaRoutesObserver> local_routes_observers_;
287 312
288 base::ObserverList<MediaRoutesObserver> routes_observers_;
289
290 using PresentationSessionMessagesObserverList = 313 using PresentationSessionMessagesObserverList =
291 base::ObserverList<PresentationSessionMessagesObserver>; 314 base::ObserverList<PresentationSessionMessagesObserver>;
292 base::ScopedPtrHashMap<MediaRoute::Id, 315 base::ScopedPtrHashMap<MediaRoute::Id,
293 scoped_ptr<PresentationSessionMessagesObserverList>> 316 scoped_ptr<PresentationSessionMessagesObserverList>>
294 messages_observers_; 317 messages_observers_;
295 // IDs of MediaRoutes being listened for messages. Note that this is 318 // IDs of MediaRoutes being listened for messages. Note that this is
296 // different from |message_observers_| because we might be waiting for 319 // different from |message_observers_| because we might be waiting for
297 // |OnRouteMessagesReceived()| to be invoked after all observers for that 320 // |OnRouteMessagesReceived()| to be invoked after all observers for that
298 // route have been removed. 321 // route have been removed.
299 std::set<MediaRoute::Id> route_ids_listening_for_messages_; 322 std::set<MediaRoute::Id> route_ids_listening_for_messages_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 base::ThreadChecker thread_checker_; 362 base::ThreadChecker thread_checker_;
340 363
341 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 364 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
342 365
343 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 366 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
344 }; 367 };
345 368
346 } // namespace media_router 369 } // namespace media_router
347 370
348 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 371 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698